简体   繁体   中英

dotnet core docker container not working on kubernetes

I am trying to run the application provided on github : https://github.com/dotnet-architecture/eShopOnWeb and it works fine on my local machine.

However, when I run the same on kubernetes I am getting errors for embedded SQL server and they are intermittent. It worked once but stopped working even when I havnt changed any code.

Here are the logs when its running fine :

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  

Here are the logs when it fails running in 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'.

The running code + the code in Kubernetes are from the same container image ( checked-into repository ) and both are ubuntu images. Is this just the instability of dotnet on docker or I am missing something ?

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.

this should get your attention, if possible use sql server or other supported on platform

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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