我无法从kubernetes容器中连接我的Prem SQLSERVER数据库。(裸机) 日志:建立与SQL Server的连接时发生与网络相关或特定于实例的错误。服务器未找到或无法访问。验证实例名称正确并且已将SQL Server配置为允许远程连接
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)
代码:
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;
}
我的Pod无法与外部IP通信 我有kubernetes 1.14,并使用weaver进行集群网络连接。 另外,我已经使用traefik作为我的入口控制器。
所有防火墙均已禁用,因此这不是防火墙问题。