My WEP API hosted in kubernetes pods are unable to communicate to external IP

0

I am not able to connect my on prem SQLSERVER database from the kubernetes pods.(Bare metal) logs: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections

Tried connecting to my SQL SERVER from other applications hosted on IIS 
and was able to connect.

warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
      No XML encryptor configured. Key {62fbf1ac-6c22-433a-97f7-d25509c980a9} may be persisted to storage in unencrypted form.
Hosting environment: Production
Content root path: /app
Now listening on: http://[::]:5055



Application started. Press Ctrl+C to shut down.
fail: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id "0HLLK9N3BSU0K", Request id "0HLLK9N3BSU0K:00000002": An unhandled exception was thrown by the application.
System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 40 - Could not open a connection to SQL Server)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)

Code:

public class DBFactory
    {
        public static List<T> Fetch<T>(Expression<Func<T, bool>> predicate, out long totalRecords) where T : class
        {
            List<T> response = new List<T>();
            using (var db = new ProviderMasterConnection())
            {
                totalRecords = db.GetTable<T>().Where(predicate).Count();
                if (totalRecords > 0)
                    response = db.GetTable<T>().Where(predicate) .ToList();
            }
            return response;
        }

My pod is not able to communicate to outside IP I have kubernetes 1.14 and used weaver for cluster networking. Also I have used traefik as my ingress-controller.

Firewalls are all disabled so this can't be a firewall issue.

kubernetes
asked on Stack Overflow Mar 29, 2019 by Prasann Garhwalia • edited Mar 29, 2019 by Kalamarico

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0