2

I'm trying to generate my Kubernetes manifests (deployment.yml and service.yml) using JKube via this command : mvn k8s:resource

But I'm getting this error :

[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

Here is what my pom.xml looks like :

<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>

I tried to get more details using the plugin documentation but I didn't found so much. Is there anyone who successfully generated the yaml files and deployed to Kubernetes cluster.

Ghassen
  • 591
  • 1
  • 15
  • 33
  • Could you please remove `` section and try again? I think it's caused by `` field with no `` configuration. It's a bug and we should fix this NPE – Rohan Kumar Mar 19 '21 at 05:55
  • it doesn't let me to rename my generated Docker image. Strangely when I put : `docker.io/ghassenkhalil/${project.artifactId}:${project.version}` `k8s:build` generates under `target/docker/carpooling/trips-api` and the image is tagged like `carpooing/trips-api:latest instead of ghassenkhalil/trips-api` and more, when I do `mvn k8s:push`, I get : `Error while trying to push the image: Unable to push 'carpooling/trips-api:latest' : denied: requested access to the resource is denied` because `carpooling/` is not the right path – Ghassen Mar 19 '21 at 16:00
  • Do you have some reproducer project which I can try out? – Rohan Kumar Mar 20 '21 at 03:30
  • @RohanKumar here is the link for a reproducer project : https://github.com/ghassen1khalil/jkube-error-reproducer – Ghassen Mar 20 '21 at 18:57
  • Hello, I tried out your reproducer but couldn't reproduce NullPointerException. I could see `Deployment` getting generated but no `Service`. I noticed that there is no `EXPOSE` statement in your `Dockerfile`. You were not exposing any port in Docker image that's why jkube was not creating any service – Rohan Kumar Mar 21 '21 at 09:54

1 Answers1

1

Update:

Apparently this was a bug in Eclipse JKube(eclipse/jkube#624) that wasn't allowing users to configure image name using provided properties in simple Dockerfile mode. This has been fixed in new release v1.2.0.

Now you should be able to configure image name using jkube.generator.name. You don't need to provide XML configuration in order to override default image name. Earlier you're providing XML configuration without any <build> configuration which was causing this NPE. As per Kuberntes Maven Plugin Documentation this field is mandatory when providing image XML configuration. configuration image configuration docs table

We're going to fix this NPE(eclipse/jkube#618) in upcoming releases too so that users can be informed when they don't provide a image build

Rohan Kumar
  • 5,427
  • 8
  • 25
  • 40
  • Are you sure with this `pom.xml` you were able to override the image name ? For me I didn't work and it kept generating under `target/reproducer/` instead of `target/ghassenkhalil` – Ghassen Mar 23 '21 at 19:28
  • Hi, After cloning your project I only changed Dockerfile to include `EXPOSE` statement. Could you please try again by doing `mvn clean install` and then `mvn k8s:build`? – Rohan Kumar Mar 23 '21 at 19:55
  • The build phase runs without problems but when I try to generate the yaml files even with the `EXPOSE` instruction I'm getting this error : `[ERROR] Failed to execute goal org.eclipse.jkube:kubernetes-maven-plugin:1.1.1:resource (default-cli) on project jkube-error-reproducer: Execution default-cli of goal org.eclipse.jkube:kubernetes-maven-plugin:1.1.1:resource failed.: NullPointerException -> [Help 1] ` But when I add an empty `` under `` it runs correctly but now the problem is that the POD on my K8S cluster shows a `CrashLoopBackOff` error – Ghassen Mar 24 '21 at 00:08
  • ah, strange. Are you sure it's the same project as the one you shared https://github.com/ghassen1khalil/jkube-error-reproducer – Rohan Kumar Mar 24 '21 at 08:20
  • Could you please join us on our gitter chat so that we can debug your problem better: https://gitter.im/eclipse/jkube – Rohan Kumar Mar 24 '21 at 08:20
  • Actually my main project is not github.com/ghassen1khalil/jkube-error-reproducer but I shared this once as you asked for the bug reproducer. I will share the problem in the discussion at gitter. You already told me to create an issue on Github previously and it was done :) – Ghassen Mar 24 '21 at 17:40