Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException on k8s:resource #578

Closed
shaohme opened this issue Feb 17, 2021 · 6 comments · Fixed by #670
Closed

NullPointerException on k8s:resource #578

shaohme opened this issue Feb 17, 2021 · 6 comments · Fixed by #670

Comments

@shaohme
Copy link

shaohme commented Feb 17, 2021

Description

Info

  • Eclipse JKube version : v1.1.0
  • Maven version (mvn -v) :
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /home/mkj/.sdkman/candidates/maven/current
Java version: 11.0.10, vendor: AdoptOpenJDK, runtime: /home/mkj/.sdkman/candidates/java/11.0.10.hs-adpt
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.10.0-3-amd64", arch: "amd64", family: "unix"
  • Kubernetes / Red Hat OpenShift setup and version :
    minikube version: v1.17.1
    commit: 043bdca07e54ab6e4fc0457e3064048f34133d7e
    Client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.2", GitCommit:"faecb196815e248d3ecfb03c680a4507229c2a56", GitTreeState:"clean", BuildDate:"2021-01-13T13:28:09Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"linux/amd64"}
    Server Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.2", GitCommit:"faecb196815e248d3ecfb03c680a4507229c2a56", GitTreeState:"clean", BuildDate:"2021-01-13T13:20:00Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"linux/amd64"}

  • If it's a bug, how to reproduce :

Running "mvn -Dkubernetes k8s:resource" I get a NullPointerException in org.eclipse.jkube.enricher.generic.ContainerEnvJavaOptionsMergeEnricher$ContainerEnvJavaOptionsMergeVisitor.lambda$visit$1 . creating an empty tag solves the problem, but that hinders me using an already build and existing Docker image.

[ERROR] Failed to execute goal org.eclipse.jkube:kubernetes-maven-plugin:1.1.0:resource (default-cli) on project K8sTesting: Execution default-cli of goal org.eclipse.jkube:kubernetes-maven-plugin:1.1.0:resource failed. NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.eclipse.jkube:kubernetes-maven-plugin:1.1.0:resource (default-cli) on project K8sTesting: Execution default-cli of goal org.eclipse.jkube:kubernetes-maven-plugin:1.1.0:resource failed.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.eclipse.jkube:kubernetes-maven-plugin:1.1.0:resource failed.
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.lang.NullPointerException
    at org.eclipse.jkube.enricher.generic.ContainerEnvJavaOptionsMergeEnricher$ContainerEnvJavaOptionsMergeVisitor.lambda$visit$1 (ContainerEnvJavaOptionsMergeEnricher.java:80)
    at java.util.stream.ReferencePipeline$2$1.accept (ReferencePipeline.java:176)
    at java.util.stream.ReferencePipeline$2$1.accept (ReferencePipeline.java:177)
    at java.util.Collections$2.tryAdvance (Collections.java:4747)
    at java.util.stream.ReferencePipeline.forEachWithCancel (ReferencePipeline.java:127)
    at java.util.stream.AbstractPipeline.copyIntoWithCancel (AbstractPipeline.java:502)
    at java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:488)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:474)
    at java.util.stream.FindOps$FindOp.evaluateSequential (FindOps.java:150)
    at java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.findFirst (ReferencePipeline.java:543)
    at org.eclipse.jkube.enricher.generic.ContainerEnvJavaOptionsMergeEnricher$ContainerEnvJavaOptionsMergeVisitor.visit (ContainerEnvJavaOptionsMergeEnricher.java:83)
    at org.eclipse.jkube.enricher.generic.ContainerEnvJavaOptionsMergeEnricher$ContainerEnvJavaOptionsMergeVisitor.visit (ContainerEnvJavaOptionsMergeEnricher.java:66)
    at io.fabric8.kubernetes.api.builder.BaseFluent.acceptInternal (BaseFluent.java:135)
    at io.fabric8.kubernetes.api.builder.BaseFluent.accept (BaseFluent.java:110)
    at io.fabric8.kubernetes.api.builder.BaseFluent.accept (BaseFluent.java:13)
    at io.fabric8.kubernetes.api.builder.BaseFluent.acceptInternal (BaseFluent.java:132)
    at io.fabric8.kubernetes.api.builder.BaseFluent.accept (BaseFluent.java:110)
    at io.fabric8.kubernetes.api.builder.BaseFluent.accept (BaseFluent.java:13)
    at io.fabric8.kubernetes.api.builder.BaseFluent.acceptInternal (BaseFluent.java:132)
    at io.fabric8.kubernetes.api.builder.BaseFluent.accept (BaseFluent.java:110)
    at io.fabric8.kubernetes.api.builder.BaseFluent.accept (BaseFluent.java:13)
    at io.fabric8.kubernetes.api.builder.BaseFluent.acceptInternal (BaseFluent.java:132)
    at io.fabric8.kubernetes.api.builder.BaseFluent.accept (BaseFluent.java:110)
    at io.fabric8.kubernetes.api.builder.BaseFluent.accept (BaseFluent.java:13)
    at io.fabric8.kubernetes.api.builder.BaseFluent.acceptInternal (BaseFluent.java:132)
    at io.fabric8.kubernetes.api.builder.BaseFluent.accept (BaseFluent.java:110)
    at io.fabric8.kubernetes.api.builder.BaseFluent.accept (BaseFluent.java:13)
    at io.fabric8.kubernetes.api.builder.BaseFluent.acceptInternal (BaseFluent.java:132)
    at io.fabric8.kubernetes.api.builder.BaseFluent.accept (BaseFluent.java:110)
    at org.eclipse.jkube.enricher.generic.ContainerEnvJavaOptionsMergeEnricher.enrich (ContainerEnvJavaOptionsMergeEnricher.java:62)
    at org.eclipse.jkube.maven.plugin.enricher.DefaultEnricherManager.lambda$enrich$2 (DefaultEnricherManager.java:90)
    at org.eclipse.jkube.maven.plugin.enricher.DefaultEnricherManager.loop (DefaultEnricherManager.java:105)
    at org.eclipse.jkube.maven.plugin.enricher.DefaultEnricherManager.enrich (DefaultEnricherManager.java:89)
    at org.eclipse.jkube.maven.plugin.enricher.DefaultEnricherManager.enrich (DefaultEnricherManager.java:79)
    at org.eclipse.jkube.kit.resource.service.DefaultResourceService.generateAppResources (DefaultResourceService.java:95)
    at org.eclipse.jkube.kit.resource.service.DefaultResourceService.generateResources (DefaultResourceService.java:59)
    at org.eclipse.jkube.maven.plugin.mojo.build.ResourceMojo.generateResources (ResourceMojo.java:345)
    at org.eclipse.jkube.maven.plugin.mojo.build.ResourceMojo.executeInternal (ResourceMojo.java:232)
    at org.eclipse.jkube.maven.plugin.mojo.build.AbstractJKubeMojo.execute (AbstractJKubeMojo.java:92)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR] 
[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
@shaohme
Copy link
Author

shaohme commented Feb 23, 2021

error seems to disappear if adding an empty build env-vars, like so:

<build>
   <env>
   </env>
</build>

@manusa
Copy link
Member

manusa commented Mar 23, 2021

Duplicate of #618

@manusa manusa marked this as a duplicate of #618 Mar 23, 2021
@rohanKanojia
Copy link
Member

rohanKanojia commented Apr 14, 2021

When I use an ImageConfiguration with no XML configuration as provided in https://github.com/shaohme/k8stest like this:

                <image>
                  <name>local/my-image</name>
                  <alias>local-my-image</alias>
                  <watch>
                    <mode>none</mode>
                  </watch>
                  <run>
                    <wait>
                      <http>
                        <url>http://localhost:8080/status</url>
                        <method>GET</method>
                        <status>200</status>
                      </http>
                      <time>6000</time>
                      <shutdown>500</shutdown>
                    </wait>
                    <log>
                      <enabled>true</enabled>
                      <color>green</color>
                    </log>
                  </run>
                </image>

No image is built using build goal:

k8stest : $ mvn k8s:build -Papp-kubernetes
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------< org.test:K8sTesting >-------------------------
[INFO] Building K8sTesting 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- kubernetes-maven-plugin:1.2.0:build (default-cli) @ K8sTesting ---
[INFO] k8s: Running in Kubernetes mode
[INFO] k8s: Building Docker image in Kubernetes mode
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.252 s
[INFO] Finished at: 2021-04-14T18:47:30+05:30
[INFO] ------------------------------------------------------------------------

On running k8s:resource goal I'm able to see NPE:

k8stest : $ mvn k8s:resource -Papp-kubernetes
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------< org.test:K8sTesting >-------------------------
[INFO] Building K8sTesting 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- kubernetes-maven-plugin:1.2.0:resource (default-cli) @ K8sTesting ---
[INFO] k8s: Using resource templates from /home/rohaan/work/repos/jkube-testing-samples/k8stest/src/main/jkube
[INFO] k8s: jkube-controller: Adding a default Deployment
[INFO] k8s: jkube-revision-history: Adding revision history limit to 2
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.186 s
[INFO] Finished at: 2021-04-14T18:47:49+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.jkube:kubernetes-maven-plugin:1.2.0:resource (default-cli) on project K8sTesting: Execution default-cli of goal org.eclipse.jkube:kubernetes-maven-plugin:1.2.0: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

When I add empty <build></build> tags in XML configuration like this:

            <configuration>
              <imagePullPolicy>Never</imagePullPolicy>
              <namespace>testing-ns</namespace>
              <images>
                <image>
                  <name>local/my-image</name>
                  <alias>local-my-image</alias>
                  <watch>
                    <mode>none</mode>
                  </watch>
                  <run>
                    <wait>
                      <http>
                        <url>http://localhost:8080/status</url>
                        <method>GET</method>
                        <status>200</status>
                      </http>
                      <time>6000</time>
                      <shutdown>500</shutdown>
                    </wait>
                    <log>
                      <enabled>true</enabled>
                      <color>green</color>
                    </log>
                  </run>
                  <build>
                    <env>
                    </env>
                  </build>
                </image>
              </images>
            </configuration>

With this configuration, I'm not able to build using mvn k8s:build:

k8stest : $ mvn k8s:build -Papp-kubernetes
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------< org.test:K8sTesting >-------------------------
[INFO] Building K8sTesting 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- kubernetes-maven-plugin:1.2.0:build (default-cli) @ K8sTesting ---
[INFO] k8s: Running in Kubernetes mode
[INFO] k8s: Building Docker image in Kubernetes mode
[ERROR] k8s: Failed to execute the build [Error while trying to build the image: No image 'busybox:latest' found and pull policy 'Never' is set. Please chose another pull policy or pull the image yourself)]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.095 s
[INFO] Finished at: 2021-04-14T18:53:53+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.jkube:kubernetes-maven-plugin:1.2.0:build (default-cli) on project K8sTesting: Failed to execute the build: Error while trying to build the image: No image 'busybox:latest' found and pull policy 'Never' is set. Please chose another pull policy or pull the image yourself) -> [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/MojoExecutionException

I think for XML configuration, <build> section is compulsory for building images. It's even stated in our docs:
Screenshot_20210414_185727

@manusa
Copy link
Member

manusa commented Apr 15, 2021

These are several scenarios:

  • User wants to run the k8s:resource goal without configuring a custom build and needs to override the Deployment/Controller Pod template image name. Why does the property configuration flag jkube.generator.name work and providing a <images><image><name></name></image></images> doesn't?

  • What happens when a user provides a custom image configuration (valid) and then specifies the jkube.generator.name configuration flag? ---> [ ] Image XML configuration takes precedence ----> flag is not applicable in this context (is documentation aligned with this fact?)

  • What happens when a user provides several images as XML configuration. Which one is included in the Deployment? Is this included in the documentation?

@rohanKanojia
Copy link
Member

User wants to run the k8s:resource goal without configuring a custom build and needs to override the Deployment/Controller Pod template image name. Why does the property configuration flag jkube.generator.name work and providing a doesn't?

jkube.generator.name
Configuring image name via jkube.generator.name only works when generators are applicable and they generate an opinionated image configuration. In case available generators are not applicable, no opinionated ImageConfiguration would be generated hence no Kubernetes manifests would be generated either.

XML image configuration
Providing image name via XMl configuration just to configure image name like this results in NullPointerException at this line in ContainerEnvJavaOptionsMergeEnricher:

            <configuration>
              <images>
                <image>
                  <name>rohankanojia/image-configured-xml:latest</name>
                </image>
              </images>
            </configuration>

However, if I add another filter .filter(ic -> ic.getBuild() != null) it starts working as expected ✔️

What happens when a user provides a custom image configuration (valid) and then specifies the jkube.generator.name configuration flag? ---> [ ] Image XML configuration takes precedence ----> flag is not applicable in this context (is documentation aligned with this fact?)

When I have image name configured via both properties and XML configuration, image name configured via XML takes precedence. Generators automatically get disabled in case someone provides imageconfiguration with buildconfiguration(see BaseGenerator). I couldn't really find any documentation for precedence order. jkube.generator.name flag being inside Generator section makes sense since it's only applicable in context of generators.

What happens when a user provides several images as XML configuration. Which one is included in the Deployment? Is this included in the documentation?

When I provide two imageconfiguration via XML, it created Deployment with two containers:
input XML configuration

            <configuration>
              <images>
                <image>
                  <name>rohankanojia/firstimage:latest</name>
                  <build>
                      <from>openjdk:latest</from>
                      <cmd>java -jar maven/${project.artifactId}-${project.version}.jar</cmd>
                  </build>
                </image>
                <image>
                  <name>rohankanojia/secondimage:latest</name>
                  <build>
                      <from>openjdk:latest</from>
                      <cmd>java -jar maven/${project.artifactId}-${project.version}.jar</cmd>
                  </build>
                </image>
              </images>
            </configuration>

Generated Deployment manifest:

k8stest : $ cat target/classes/META-INF/jkube/kubernetes/k8stesting-deployment.yml 
---
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    jkube.io/git-url: [email protected]:shaohme/k8stest.git
    jkube.io/git-commit: fa8fab33d590d92f143bf404fb241f9bda4fff9e
    jkube.io/git-branch: main
  labels:
    app: K8sTesting
    provider: jkube
    version: 1.0-SNAPSHOT
    group: org.test
  name: k8stesting
spec:
  replicas: 1
  revisionHistoryLimit: 2
  selector:
    matchLabels:
      app: K8sTesting
      provider: jkube
      group: org.test
  template:
    metadata:
      annotations:
        jkube.io/git-url: [email protected]:shaohme/k8stest.git
        jkube.io/git-commit: fa8fab33d590d92f143bf404fb241f9bda4fff9e
        jkube.io/git-branch: main
      labels:
        app: K8sTesting
        provider: jkube
        version: 1.0-SNAPSHOT
        group: org.test
    spec:
      containers:
      - env:
        - name: KUBERNETES_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: HOSTNAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        image: rohankanojia/firstimage:latest
        imagePullPolicy: IfNotPresent
        name: rohankanojia-K8sTesting
        securityContext:
          privileged: false
      - env:
        - name: KUBERNETES_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        - name: HOSTNAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        image: rohankanojia/secondimage:latest
        imagePullPolicy: IfNotPresent
        name: rohankanojia-K8sTesting
        securityContext:
          privileged: false

Similarly if I add three images in XML config, it results in Deployment with three containers

@manusa
Copy link
Member

manusa commented Apr 16, 2021

However, if I add another filter .filter(ic -> ic.getBuild() != null) it starts working as expected heavy_check_mark

  • Makes sense adding this extra filter, so that k8s:resource goal can get the image name customization via XML.
  • Improve documentation to state that the jkube.generator.** flags only apply to Generators ----> XML config
  • Improve documentation to clearly state that Generators won't apply if customized XML image configuration is provided. i.e. Custom images take precedence over generators, and are not the same thing; clear distinction between ZeroConfig mode and custom XML for images (k8s:build)

rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Apr 16, 2021
…sMergeEnricher

+ Fix NullPointerException in ContainerEnvJavaOptionsMergeEnricher
+ Add FAQ for image name configuration in docs
+ Add note in docs for image precedence of XML configuration over
  generators
+ Added sentence in `jkube.generator.name` flag description that it's
  only applicable in scope of generators
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Apr 16, 2021
…sMergeEnricher

+ Fix NullPointerException in ContainerEnvJavaOptionsMergeEnricher
+ Add FAQ for image name configuration in docs
+ Add note in docs for image precedence of XML configuration over
  generators
+ Added sentence in `jkube.generator.name` flag description that it's
  only applicable in scope of generators
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Apr 20, 2021
…sMergeEnricher

+ Fix NullPointerException in ContainerEnvJavaOptionsMergeEnricher
+ Add FAQ for image name configuration in docs
+ Add note in docs for image precedence of XML configuration over
  generators
+ Added sentence in `jkube.generator.name` flag description that it's
  only applicable in scope of generators
manusa pushed a commit to rohanKanojia/jkube that referenced this issue Apr 23, 2021
…sMergeEnricher

+ Fix NullPointerException in ContainerEnvJavaOptionsMergeEnricher
+ Add FAQ for image name configuration in docs
+ Add note in docs for image precedence of XML configuration over
  generators
+ Added sentence in `jkube.generator.name` flag description that it's
  only applicable in scope of generators
manusa pushed a commit that referenced this issue Apr 23, 2021
+ Fix NullPointerException in ContainerEnvJavaOptionsMergeEnricher
+ Add FAQ for image name configuration in docs
+ Add note in docs for image precedence of XML configuration over
  generators
+ Added sentence in `jkube.generator.name` flag description that it's
  only applicable in scope of generators
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants