我正在尝试通过以下命令生成我的Kubernetes清单(deployment.yml和service.yml),使用JKube:mvn k8s:resource
但我发现了一个错误:
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< io.social.carpooling:trips-api >-------------------
[INFO] Building trips-api 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- kubernetes-maven-plugin:1.1.1:resource (default-cli) @ trips-api ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.979 s
[INFO] Finished at: 2021-03-18T19:11:24+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.jkube:kubernetes-maven-plugin:1.1.1:resource (default-cli) on project trips-api: Execution default-cli of goal org.eclipse.jkube:kubernetes-maven-plugin:1.1.1:resource failed.: NullPointerException -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException下面是我的pom.xml的样子:
<properties>
...
<jkube.version>1.1.1</jkube.version>
<jkube.generator.name>my-dockerhub-username/${project.artifactId}:${project.version}</jkube.generator.name>
...
</properties>
...
<plugin>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<version>${jkube.version}</version>
<configuration>
<images>
<image>
<name>my-dockerhub-username/${project.artifactId}:${project.version}</name>
</image>
</images>
</configuration>
</plugin>我试着用插件文档获得更多的细节,但是我没有找到太多的细节。是否有人成功地生成yaml文件并部署到Kubernetes集群。
发布于 2021-03-21 10:02:57
更新
显然,这是Eclipse (JKubeeclipse/jkube#624)中的一个bug,它不允许用户在简单的Dockerfile模式下使用提供的属性配置映像名。这个问题已经在新版本v1.2.0中得到了修正。
现在,您应该能够使用jkube.generator.name配置映像名。不需要提供XML配置就可以覆盖默认的图像名称。更早的时候,您提供的XML配置没有任何<build>配置,这导致了这个NPE。根据Kuberntes Maven插件文档,在提供图像XML配置时,该字段是必需的。配置

我们也将在即将发布的版本中修复这个NPE(eclipse/jkube#618),这样用户就可以在没有提供映像构建时得到通知。
https://stackoverflow.com/questions/66697161
复制相似问题