Jkube: create namespace failure

Created on 24 Sep 2020  路  7Comments  路  Source: eclipse/jkube

Description

Setup minimal pom with kubernetes plugin and namespace specified (namespace is new).
Command mvn k8s:resource k8s:apply -X generate this error:

[ERROR] Failed to execute goal org.eclipse.jkube:kubernetes-maven-plugin:1.0.0:apply (create kubernetes resources) on project datalab: Failed to create na
mespace: datalab-jkube due Namespace mismatch. Item namespace:datalab-jkube. Operation namespace:default. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.eclipse.jkube:kubernetes-maven-plugin:1.0.0:apply (create kubernetes re
sources) on project datalab: Failed to create namespace: datalab-jkube due Namespace mismatch. Item namespace:datalab-jkube. Operation namespace:default.
    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.MojoExecutionException: Failed to create namespace: datalab-jkube due Namespace mismatch. Item namespace:datalab-jkube.
 Operation namespace:default.
    at org.eclipse.jkube.maven.plugin.mojo.build.ApplyMojo.executeInternal (ApplyMojo.java:251)
    at org.eclipse.jkube.maven.plugin.mojo.build.AbstractJKubeMojo.execute (AbstractJKubeMojo.java:100)
    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)
Caused by: java.lang.RuntimeException: Failed to create namespace: datalab-jkube due Namespace mismatch. Item namespace:datalab-jkube. Operation namespace
:default.
    at org.eclipse.jkube.kit.config.service.ApplyService.onApplyError (ApplyService.java:1292)
    at org.eclipse.jkube.kit.config.service.ApplyService.applyNamespace (ApplyService.java:1036)
    at org.eclipse.jkube.maven.plugin.mojo.build.ApplyMojo.executeInternal (ApplyMojo.java:223)
    at org.eclipse.jkube.maven.plugin.mojo.build.AbstractJKubeMojo.execute (AbstractJKubeMojo.java:100)
    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)
Caused by: io.fabric8.kubernetes.client.KubernetesClientException: Namespace mismatch. Item namespace:datalab-jkube. Operation namespace:default.
    at io.fabric8.kubernetes.client.dsl.base.OperationSupport.checkNamespace (OperationSupport.java:185)
    at io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleCreate (OperationSupport.java:251)
    at io.fabric8.kubernetes.client.dsl.base.BaseOperation.handleCreate (BaseOperation.java:844)
    at io.fabric8.kubernetes.client.dsl.base.BaseOperation.create (BaseOperation.java:352)
    at io.fabric8.kubernetes.client.dsl.base.BaseOperation.create (BaseOperation.java:79)
    at org.eclipse.jkube.kit.config.service.ApplyService.applyNamespace (ApplyService.java:1032)
    at org.eclipse.jkube.maven.plugin.mojo.build.ApplyMojo.executeInternal (ApplyMojo.java:223)
    at org.eclipse.jkube.maven.plugin.mojo.build.AbstractJKubeMojo.execute (AbstractJKubeMojo.java:100)
    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)

If I remove namespace inside context in kubernetes config the command is completed with no error and namespace is created.

ORIGINAL (KO)

...
- context:
    cluster: api-devops-okd-icteam-it:6443
    namespace: default
    user: d.pirola
  name: default/api-devops-okd-icteam-it:6443/d.pirola
...

MODIFIED (OK)

...
- context:
    cluster: api-devops-okd-icteam-it:6443
    user: d.pirola
  name: default/api-devops-okd-icteam-it:6443/d.pirola
...

Info

  • Eclipse JKube version : 1.0.0
  • Maven version (mvn -v) : 3.6.3
  • Kubernetes / Red Hat OpenShift setup and version :

Client Version: 4.5.0-0.okd-2020-08-12-020541
Server Version: 4.5.0-0.okd-2020-09-18-202631
Kubernetes Version: v1.18.3
```

bug

All 7 comments

Looks like we need to check what's wrong in ApplyService to see what's wrong.
~Related to https://github.com/eclipse/jkube/issues/511~

@Danipiario: Hello, Sorry for the late reply. How are you specifying namespace? Via some resource fragment or jkube.namespace property? I was facing a similar issue while fixing #511 . In my case, culprit was DefaultNamespaceEnricher appending metadata.namespace for Namespace resource too(which is a Cluster scoped resource).

https://github.com/eclipse/jkube/blob/bf88230a5c110d686ea02ffb45dba8a294f5e2e9/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/DefaultNamespaceEnricher.java#L106-L130

Hi Rohan,
I specified the namespace inside the pom, under configuration section. I think it's the same as specifying the property jkube.namespace

ohk, I think most probably this issue should be fixed with #511 . I'll test with your pom configuration again whenever I revisit this and provide update.

ohk, I tested with namespace inside plugin configuration. I think this issue would be fixed with my PR

I tested again with merged changes in master with this configuration and it seemed to be working for me. I think it's fixed via #511.

      <plugin>
        <groupId>org.eclipse.jkube</groupId>
        <artifactId>kubernetes-maven-plugin</artifactId>
        <version>${project.version}</version>
        <configuration>
          <namespace>jkube-test12345</namespace>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>resource</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

Closing this issue. Feel free to re-open if you face this again in upcoming releases

Was this page helpful?
0 / 5 - 0 ratings