簡體   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