Sping Boot Pod不在kubernetes中出现

5cnsuln7  于 2023-08-03  发布在  Kubernetes
关注(0)|答案(2)|浏览(94)

几天前,我已经在AWS Kubernetes集群中部署了我的应用程序,它已经成功部署,应用程序已经启动并运行。最近我们更改了db密码。现在有4个应用程序连接到同一个数据库。我们重新启动了所有4个应用程序。3个应用程序出现了,但其中一个应用程序没有出现。它总是重新启动,我捕获了以下日志:

[l-1 housekeeper] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Pool stats (total=10, active=1, idle=9, waiting=0)
[l-1 housekeeper] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Fill pool skipped, pool is at sufficient level.
[nnection-reaper] h.i.c.PoolingHttpClientConnectionManager : Closing connections idle longer than 60000 MILLISECONDS
[nnection-reaper] h.i.c.PoolingHttpClientConnectionManager : Closing connections idle longer than 60000 MILLISECONDS
[alina-utility-2] org.apache.catalina.session.ManagerBase  : Start expire sessions StandardManager at 1689843028211 sessioncount 0
[alina-utility-2] org.apache.catalina.session.ManagerBase  : End expire sessions StandardManager processingTime 1 expired sessions: 0
[l-1 housekeeper] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Pool stats (total=10, active=1, idle=9, waiting=0)
[l-1 housekeeper] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Fill pool skipped, pool is at sufficient level.
[l-1 housekeeper] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Pool stats (total=10, active=1, idle=9, waiting=0)
[l-1 housekeeper] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Fill pool skipped, pool is at sufficient level.
[nnection-reaper] h.i.c.PoolingHttpClientConnectionManager : Closing connections idle longer than 60000 MILLISECONDS
[nnection-reaper] h.i.c.DefaultManagedHttpClientConnection : http-outgoing-1: Close connection
[nnection-reaper] com.amazonaws.internal.SdkSSLSocket      : closing ssm.us-east-1.amazonaws.com/52.46.145.233:443
[nnection-reaper] h.i.c.PoolingHttpClientConnectionManager : Closing connections idle longer than 60000 MILLISECONDS
[nnection-reaper] h.i.c.DefaultManagedHttpClientConnection : http-outgoing-0: Close connection
[nnection-reaper] com.amazonaws.internal.SdkSSLSocket      : closing sts.us-east-1.amazonaws.com/67.220.245.46:443
[alina-utility-2] org.apache.catalina.session.ManagerBase  : Start expire sessions StandardManager at 1689843088214 sessioncount 0
[alina-utility-2] org.apache.catalina.session.ManagerBase  : End expire sessions StandardManager processingTime 0 expired sessions: 0

字符串
正在添加相关的光池初始化日志:

[           main] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@4dd90166
[           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
[           main] o.h.e.j.e.i.JdbcEnvironmentInitiator     : Database ->
2023-07-20T12:15:50.405833777Z stdout F        name : PostgreSQL
2023-07-20T12:15:50.405837321Z stdout F     version : 13.8
2023-07-20T12:15:50.405840197Z stdout F       major : 13
2023-07-20T12:15:50.405843007Z stdout F       minor : 8
[           main] o.h.e.j.e.i.JdbcEnvironmentInitiator     : Driver ->
2023-07-20T12:15:50.405900698Z stdout F        name : PostgreSQL JDBC Driver
2023-07-20T12:15:50.405904562Z stdout F     version : 42.3.7
2023-07-20T12:15:50.405907398Z stdout F       major : 42
2023-07-20T12:15:50.405910368Z stdout F       minor : 3
[           main] o.h.e.j.e.i.JdbcEnvironmentInitiator     : JDBC version : 4.2
[l-1 housekeeper] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Pool stats (total=1, active=1, idle=0, waiting=0)
[onnection adder] org.postgresql.Driver                    : Connecting with URL: jdbc:postgresql://XXXXXX:5432/ics?useSSL=true
[onnection adder] org.postgresql.jdbc.PgConnection         : PostgreSQL JDBC Driver 42.3.7
[onnection adder] org.postgresql.jdbc.PgConnection         :   setDefaultFetchSize = 0

[onnection adder] o.p.core.v3.ConnectionFactoryImpl        : Trying to establish a protocol version 3 connection to XXXXXX
[onnection adder] o.p.core.v3.ConnectionFactoryImpl        : Receive Buffer Size is 65,536
[onnection adder] o.p.core.v3.ConnectionFactoryImpl        : Send Buffer Size is 166,400
[onnection adder] org.postgresql.ssl.MakeSSL               : converting regular socket connection to ssl
[           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL10Dialect
[           main] o.h.e.j.env.spi.IdentifierHelperBuilder  : JDBC driver metadata reported database stores quoted identifiers in 
                                                              neither upper, lower nor mixed case
[onnection adder] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@a1713f8
[onnection adder] org.postgresql.Driver                    : Connecting with URL: jdbc:postgresql://XXXXXX:5432/ics?useSSL=true
[onnection adder] org.postgresql.jdbc.PgConnection         : PostgreSQL JDBC Driver 42.3.7
[onnection adder] org.postgresql.jdbc.PgConnection         :   setDefaultFetchSize = 0
[onnection adder] org.postgresql.jdbc.PgConnection         :   setPrepareThreshold = 5
[onnection adder] o.p.core.v3.ConnectionFactoryImpl        : Trying to establish a protocol version 3 connection to XXXXXX:5432
[onnection adder] o.p.core.v3.ConnectionFactoryImpl        : Receive Buffer Size is 65,536
[onnection adder] o.p.core.v3.ConnectionFactoryImpl        : Send Buffer Size is 166,400

[           main] o.h.type.spi.TypeConfiguration$Scope     : Scoping TypeConfiguration [org.hibernate.type.spi.TypeConfiguration@7c369270] to MetadataBuildingContext [org.hibernate.boot.internal.MetadataBuildingContextRootImpl@9f86dc3]
[           main] org.hibernate.type.BasicTypeRegistry     : HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType@25f15f50
[           main] org.hibernate.type.BasicTypeRegistry     : Adding type registration java.util.UUID -> org.hibernate.type.PostgresUUIDType@4ed15347
[           main] org.hibernate.type.BasicTypeRegistry     : Adding type registration pg-uuid -> org.hibernate.type.PostgresUUIDType@4ed15347


[onnection adder] org.postgresql.ssl.MakeSSL               : converting regular socket connection to ssl

[           main] o.h.boot.model.relational.Namespace      : Created database namespace [logicalName=Name{catalog=null, schema=null}, physicalName=Name{catalog=null, schema=null}]
[onnection adder] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@4d0fcca
[onnection adder] org.postgresql.Driver                    : Connecting with URL: jdbc:postgresql://XXXXXX:5432/ics?useSSL=true
[onnection adder] org.postgresql.jdbc.PgConnection         : PostgreSQL JDBC Driver 42.3.7
[onnection adder] org.postgresql.jdbc.PgConnection         :   setDefaultFetchSize = 0
[onnection adder] org.postgresql.jdbc.PgConnection         :   setPrepareThreshold = 5
[onnection adder] o.p.core.v3.ConnectionFactoryImpl        : Trying to establish a protocol version 3 connection to XXXXXX:5432
[onnection adder] o.p.core.v3.ConnectionFactoryImpl        : Receive Buffer Size is 65,536
[onnection adder] o.p.core.v3.ConnectionFactoryImpl        : Send Buffer Size is 166,400

[           main] org.hibernate.cfg.AnnotationBinder       : Binding entity from annotated class: x.y.z.entity.MyEntity
[onnection adder] org.postgresql.ssl.MakeSSL               : converting regular socket connection to ssl
[           main] org.hibernate.cfg.Ejb3Column             : Binding column: Ejb3DiscriminatorColumn{logicalColumnName'DTYPE', discriminatorTypeName='string'}
[           main] o.h.cfg.annotations.EntityBinder         : Import with entity name MyEntity
[           main] o.h.cfg.annotations.EntityBinder         : Bind entity x.y.z.entity.MyEntity on table my_table


因此,可以肯定的是,数据库连接不是问题。
没有例外,也没有错误。当我检查pod事件时,我可以看到:

Event : Warning
Reason : Unhealthy
Message : Liveness probe failed. Get " http:// ...." dial tcp : ....:8080 connect : connection refused.
        : Readiness probe failed. Get " http:// ...." dial tcp : ....:8080 connect : connection refused.
        : Backoff restarting failed container.


这是我的liveness-readiness配置:

- op: add
    path: /spec/template/spec/containers/0/readinessProbe/initialDelaySeconds
    value: 180
  - op: add
    path: /spec/template/spec/containers/0/livenessProbe/initialDelaySeconds
    value: 180


应用特性:

management.endpoints.web.exposure.include=health,info,metrics,env,flyway
management.endpoint.health.probes.enabled=true
management.health.livenessState.enabled=true
management.health.readinessState.enabled=true


我也禁用了活性和准备,但结果仍然相同。

Sping Boot 版本:2.7.5

相同的配置,应用程序在dev和preprod集群中启动并运行,但在prod集群中失败。同样的配置,其他应用程序运行良好。有人能帮我找出这里的问题吗?

djp7away

djp7away1#

请按照以下步骤解决问题:
从部署中删除活动性和就绪性探测器以缩小问题范围。检查更改后Pod是否出现。如果问题得到解决,则探测的时间可能有问题。
如果上一步不能解决问题,请在调试模式下部署应用程序。然后,检查日志,看看它是否能够获得JDBC连接。

q3aa0525

q3aa05252#

在prod中设置以下内容为我解决了这个问题。

spring.jpa.hibernate.ddl-auto=none

字符串
这阻止了ddl生成,很可能是应用程序卡住并重新启动的地方。

相关问题