在 Kubernetes 上启动 Quarkus 时出现 NumberFormatException
NumberFormatException when starting Quarkus on Kubernetes
我正在尝试将 Quarkus 应用程序部署到 Kubernetes 集群,但我得到了以下堆栈跟踪:
exec java -Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager -XX:+ExitOnOutOfMemoryError -cp . -jar /deployments/quarkus-run.jar
__ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2021-05-11 16:47:19,455 ERROR [io.qua.run.Application] (main) Failed to start application (with profile prod): java.lang.NumberFormatException: SRCFG00029: Expected an integer value, got "tcp://10.233.12.82:80"
at io.smallrye.config.Converters.lambda$staticdb1e39(Converters.java:104)
at io.smallrye.config.Converters$EmptyValueConverter.convert(Converters.java:949)
at io.smallrye.config.Converters$TrimmingConverter.convert(Converters.java:970)
at io.smallrye.config.Converters$BuiltInConverter.convert(Converters.java:872)
at io.smallrye.config.Converters$OptionalConverter.convert(Converters.java:790)
at io.smallrye.config.Converters$OptionalConverter.convert(Converters.java:771)
at io.smallrye.config.SmallRyeConfig.getValue(SmallRyeConfig.java:225)
at io.smallrye.config.SmallRyeConfig.getOptionalValue(SmallRyeConfig.java:270)
at io.quarkus.arc.runtime.ConfigRecorder.validateConfigProperties(ConfigRecorder.java:37)
at io.quarkus.deployment.steps.ConfigBuildStep$validateConfigProperties1249763973.deploy_0(ConfigBuildStep$validateConfigProperties1249763973.zig:328)
at io.quarkus.deployment.steps.ConfigBuildStep$validateConfigProperties1249763973.deploy(ConfigBuildStep$validateConfigProperties1249763973.zig:40)
at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:576)
at io.quarkus.runtime.Application.start(Application.java:90)
at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:100)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:66)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:42)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:119)
at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.quarkus.bootstrap.runner.QuarkusEntryPoint.doRun(QuarkusEntryPoint.java:48)
at io.quarkus.bootstrap.runner.QuarkusEntryPoint.main(QuarkusEntryPoint.java:25)
我用 default dockerfile 构建了 Docker 图像,我的 quarkus 相关依赖项如下:
dependencies {
implementation(enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}"))
implementation("org.optaplanner:optaplanner-quarkus")
implementation("io.quarkus:quarkus-resteasy")
implementation("io.quarkus:quarkus-vertx")
implementation("io.quarkus:quarkus-resteasy-jackson")
implementation("io.quarkus:quarkus-undertow-websockets")
implementation("io.quarkus:quarkus-smallrye-health")
}
我正在使用 Quarkus 1.13。3.Final,我已经为我的部署手动编写了一个 helm 图表。部署的 dockerfile 在我的机器上运行良好,而 kubernetes 部署描述符中没有该 IP 地址。我认为IP是集群的一个ClusterIP。
有什么想法吗?谢谢
这是由于 kubernetes 在范围内模仿 Service
名称的 docker link variables;当人们使用诸如 { apiVersion: v1, kind: Service, metadata: { name: http }, ...
之类的通用命名服务时,它会很烦人,因为它会在 Pod 中愉快地生成形式为 HTTP_PORT=tcp://10.233.12.82:80
的环境变量,以及诸如 Spring boot 或显然是 Quarkus 之类的东西强制环境变量进入配置覆盖可能会导致您遇到的确切结果
解决方案是 (a) 不要使用乏味的名称来命名 Services
(b) “屏蔽”Pod 的攻击性环境变量:
...
containers:
- ...
env:
- name: HTTP_PORT
# it doesn't need a value:, it just needs the name to be specified
# so it hides the injected version
- ... any remaining env-vars you really want
我正在尝试将 Quarkus 应用程序部署到 Kubernetes 集群,但我得到了以下堆栈跟踪:
exec java -Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager -XX:+ExitOnOutOfMemoryError -cp . -jar /deployments/quarkus-run.jar
__ ____ __ _____ ___ __ ____ ______
--/ __ \/ / / / _ | / _ \/ //_/ / / / __/
-/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2021-05-11 16:47:19,455 ERROR [io.qua.run.Application] (main) Failed to start application (with profile prod): java.lang.NumberFormatException: SRCFG00029: Expected an integer value, got "tcp://10.233.12.82:80"
at io.smallrye.config.Converters.lambda$staticdb1e39(Converters.java:104)
at io.smallrye.config.Converters$EmptyValueConverter.convert(Converters.java:949)
at io.smallrye.config.Converters$TrimmingConverter.convert(Converters.java:970)
at io.smallrye.config.Converters$BuiltInConverter.convert(Converters.java:872)
at io.smallrye.config.Converters$OptionalConverter.convert(Converters.java:790)
at io.smallrye.config.Converters$OptionalConverter.convert(Converters.java:771)
at io.smallrye.config.SmallRyeConfig.getValue(SmallRyeConfig.java:225)
at io.smallrye.config.SmallRyeConfig.getOptionalValue(SmallRyeConfig.java:270)
at io.quarkus.arc.runtime.ConfigRecorder.validateConfigProperties(ConfigRecorder.java:37)
at io.quarkus.deployment.steps.ConfigBuildStep$validateConfigProperties1249763973.deploy_0(ConfigBuildStep$validateConfigProperties1249763973.zig:328)
at io.quarkus.deployment.steps.ConfigBuildStep$validateConfigProperties1249763973.deploy(ConfigBuildStep$validateConfigProperties1249763973.zig:40)
at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:576)
at io.quarkus.runtime.Application.start(Application.java:90)
at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:100)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:66)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:42)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:119)
at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.quarkus.bootstrap.runner.QuarkusEntryPoint.doRun(QuarkusEntryPoint.java:48)
at io.quarkus.bootstrap.runner.QuarkusEntryPoint.main(QuarkusEntryPoint.java:25)
我用 default dockerfile 构建了 Docker 图像,我的 quarkus 相关依赖项如下:
dependencies {
implementation(enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}"))
implementation("org.optaplanner:optaplanner-quarkus")
implementation("io.quarkus:quarkus-resteasy")
implementation("io.quarkus:quarkus-vertx")
implementation("io.quarkus:quarkus-resteasy-jackson")
implementation("io.quarkus:quarkus-undertow-websockets")
implementation("io.quarkus:quarkus-smallrye-health")
}
我正在使用 Quarkus 1.13。3.Final,我已经为我的部署手动编写了一个 helm 图表。部署的 dockerfile 在我的机器上运行良好,而 kubernetes 部署描述符中没有该 IP 地址。我认为IP是集群的一个ClusterIP。
有什么想法吗?谢谢
这是由于 kubernetes 在范围内模仿 Service
名称的 docker link variables;当人们使用诸如 { apiVersion: v1, kind: Service, metadata: { name: http }, ...
之类的通用命名服务时,它会很烦人,因为它会在 Pod 中愉快地生成形式为 HTTP_PORT=tcp://10.233.12.82:80
的环境变量,以及诸如 Spring boot 或显然是 Quarkus 之类的东西强制环境变量进入配置覆盖可能会导致您遇到的确切结果
解决方案是 (a) 不要使用乏味的名称来命名 Services
(b) “屏蔽”Pod 的攻击性环境变量:
...
containers:
- ...
env:
- name: HTTP_PORT
# it doesn't need a value:, it just needs the name to be specified
# so it hides the injected version
- ... any remaining env-vars you really want