dotnet核心docker容器不适用于kubernetes

时间:2019-04-07 18:58:43

标签: c# sql-server docker kubernetes .net-core

我正在尝试运行github:https://github.com/dotnet-architecture/eShopOnWeb上提供的应用程序,它在我的本地计算机上运行良好。

但是,当我在kubernetes上运行相同代码时,嵌入式SQL Server出现错误,并且它们是间歇性的。它曾经工作过一次,但是即使我更改了任何代码也停止了工作。

以下是正常运行时的日志:

Attaching to eshoponweb_eshopwebmvc_1
eshopwebmvc_1  | info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
eshopwebmvc_1  |       Entity Framework Core 2.2.3-servicing-35854 initialized 'CatalogContext' using provider 'Microsoft.EntityFrameworkCore.InMemory' with options: StoreName=Catalog
eshopwebmvc_1  | info: Microsoft.EntityFrameworkCore.Update[30100]
eshopwebmvc_1  |       Saved 5 entities to in-memory store.
eshopwebmvc_1  | info: Microsoft.EntityFrameworkCore.Update[30100]
eshopwebmvc_1  |       Saved 4 entities to in-memory store.
eshopwebmvc_1  | info: Microsoft.EntityFrameworkCore.Update[30100]
eshopwebmvc_1  |       Saved 12 entities to in-memory store.
eshopwebmvc_1  | info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
eshopwebmvc_1  |       User profile is available. Using '/root/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
eshopwebmvc_1  | info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
eshopwebmvc_1  |       Entity Framework Core 2.2.3-servicing-35854 initialized 'AppIdentityDbContext' using provider 'Microsoft.EntityFrameworkCore.InMemory' with options: StoreName=Identity
eshopwebmvc_1  | info: Microsoft.EntityFrameworkCore.Update[30100]
eshopwebmvc_1  |       Saved 1 entities to in-memory store.
eshopwebmvc_1  | Hosting environment: Development
eshopwebmvc_1  | Content root path: /app
eshopwebmvc_1  | Now listening on: http://[::]:80
eshopwebmvc_1  | Application started. Press Ctrl+C to shut down.
eshopwebmvc_1  | info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
eshopwebmvc_1  |       Request starting HTTP/1.1 GET http://192.168.1.33:5106/
eshopwebmvc_1  | warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3]
eshopwebmvc_1  |       Failed to determine the https port for redirect.
eshopwebmvc_1  | info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
eshopwebmvc_1  |       Executing endpoint 'Page: /Index'
eshopwebmvc_1  | info: Microsoft.AspNetCore.Mvc.RazorPages.Internal.PageActionInvoker[3]
eshopwebmvc_1  |       Route matched with {page = "/Index", action = "", controller = "", area = ""}. Executing page /Index
eshopwebmvc_1  | info: Microsoft.AspNetCore.Mvc.RazorPages.Internal.PageActionInvoker[101]
eshopwebmvc_1  |       Executing handler method Microsoft.eShopWeb.Web.Pages.IndexModel.OnGet with arguments (Microsoft.eShopWeb.Web.ViewModels.CatalogIndexViewModel, ) - ModelState is Valid
eshopwebmvc_1  | info: Microsoft.eShopWeb.Web.Services.CatalogViewModelService[0]
eshopwebmvc_1  |       GetCatalogItems called.
eshopwebmvc_1  | info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
eshopwebmvc_1  

以下是在Kubernetes中运行失败时的日志:

ubuntu@node1:~/repo/eShopOnWeb/helm$ kubectl  logs  eshopwebmvc-6dc855b6f5-rlgkr -n eshopwebmvc
warn: Microsoft.EntityFrameworkCore.Model.Validation[30000]
      No type was specified for the decimal column 'UnitPrice' on entity type 'BasketItem'. This will cause values to be silently truncated if they do not fit in the default precision and scale. Explicitly specify the SQL server column type that can accommodate all the values using 'HasColumnType()'.
warn: Microsoft.EntityFrameworkCore.Model.Validation[30000]
      No type was specified for the decimal column 'Price' on entity type 'CatalogItem'. This will cause values to be silently truncated if they do not fit in the default precision and scale. Explicitly specify the SQL server column type that can accommodate all the values using 'HasColumnType()'.
warn: Microsoft.EntityFrameworkCore.Model.Validation[30000]
      No type was specified for the decimal column 'UnitPrice' on entity type 'OrderItem'. This will cause values to be silently truncated if they do not fit in the default precision and scale. Explicitly specify the SQL server column type that can accommodate all the values using 'HasColumnType()'.
fail: Microsoft.EntityFrameworkCore.Database.Connection[20004]
      An error occurred using the connection to database 'Microsoft.eShopOnWeb.CatalogDb' on server '(localdb)\mssqllocaldb'.
System.PlatformNotSupportedException: LocalDB is not supported on this platform.
   at System.Data.SqlClient.SNI.LocalDB.GetLocalDBConnectionString(String localDbInstance)
   at System.Data.SqlClient.SNI.SNIProxy.GetLocalDBDataSource(String fullServerName, Boolean& error)
   at System.Data.SqlClient.SNI.SNIProxy.CreateConnectionHandle(Object callbackObject, String fullServerName, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Byte[]& instanceName, Byte[]& spnBuffer, Boolean flushCache, Boolean async, Boolean parallel, Boolean isIntegratedSecurity)
   at System.Data.SqlClient.SNI.TdsParserStateObjectManaged.CreatePhysicalSNIHandle(String serverName, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Byte[]& instanceName, Byte[]& spnBuffer, Boolean flushCache, Boolean async, Boolean parallel, Boolean isIntegratedSecurity)
   at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover)
   at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
   at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
   at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   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)
   at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.Open()
   at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnection(Boolean errorsExpected)
fail: Microsoft.EntityFrameworkCore.Query[10100]
      An exception occurred while iterating over the results of a query for context type 'Microsoft.eShopWeb.Infrastructure.Data.CatalogContext'.

正在运行的代码+ Kubernetes中的代码来自同一容器映像(已签入到存储库),并且都是ubuntu映像。这仅仅是docker上的dotnet不稳定还是我缺少了什么?

1 个答案:

答案 0 :(得分:0)

fail: Microsoft.EntityFrameworkCore.Database.Connection[20004]
      An error occurred using the connection to database 'Microsoft.eShopOnWeb.CatalogDb' on server '(localdb)\mssqllocaldb'.
System.PlatformNotSupportedException: LocalDB is not supported on this platform.

这应该引起您的注意,如果可能的话,请使用sql server或平台上支持的其他

相关问题