Контейнер Dotnet Core не работает на Kubernetes - PullRequest
0 голосов
/ 07 апреля 2019

Я пытаюсь запустить приложение, предоставляемое на 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 на докере или я что-то упустил?

1 Ответ

0 голосов
/ 07 апреля 2019
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 или другой поддерживаемый на платформе

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...