繁体   English   中英

dotnet core docker容器不在kubernetes上工作

[英]dotnet core docker container not working on kubernetes

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

但是,当我在kubernetes上运行相同的操作时,我遇到了嵌入式SQL服务器的错误,并且它们是间歇性的。 它工作了一次,但即使我改变了任何代码,它也停止了工作。

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

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映像。 这只是码头上dotnet的不稳定性还是我错过了什么?

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或平台上支持的其他服务器

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM