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

create namespace failure #403

Closed
Danipiario opened this issue Sep 24, 2020 · 7 comments
Closed

create namespace failure #403

Danipiario opened this issue Sep 24, 2020 · 7 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@Danipiario
Copy link
Contributor

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

@rohanKanojia
Copy link
Member

rohanKanojia commented Dec 9, 2020

Looks like we need to check what's wrong in ApplyService to see what's wrong.
Related to #511

@rohanKanojia rohanKanojia added the bug Something isn't working label Dec 9, 2020
@manusa manusa added this to the 1.1.0 milestone Dec 9, 2020
@rohanKanojia
Copy link
Member

@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

@Danipiario
Copy link
Contributor Author

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

@rohanKanojia
Copy link
Member

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.

@rohanKanojia
Copy link
Member

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

@rohanKanojia
Copy link
Member

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>

@rohanKanojia
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants