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

Can't seem to override the use of project.artifactId as the application reference in the deployment descriptor #273

Closed
TueDissingWork opened this issue Jul 2, 2020 · 24 comments · Fixed by #325
Labels
enhancement New feature or request

Comments

@TueDissingWork
Copy link
Contributor

Description

This is likely just a configuration issue, but can't figure it out. Hence this ticket.

As part of our build we would like to control the application reference use across the different files generated from the resource goal.
Here's an example:

spec:
    ports:
    - name: http
      port: 8080
      protocol: TCP
      targetPort: 8080
    selector:
      app: greetings-api
      provider: jkube
      group: dk.something.someting.rest

The plugin doesn't seem to let us control the spec:selector:app reference - at least I can't figure out how. This defaults to the project.artifactId. This makes sense,, but we would like to have it a difference value, in order for us to deploy our application in different version; within the same namespace (running on OpenShift). Any way we could add the version or some other property to this string?
What happens now is that we get different applications deployed, but they seem to share their individual services and routes between them. Which isn't what we are looking for.

So how can we control the value ending up in the .yaml files under spec:selector:app?

Info

  • Eclipse JKube version: 1.0.0-alpha-4
  • Maven version (mvn -v) :
Apache Maven 3.6.0
Maven home: /usr/share/maven
Java version: 11.0.7, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-17763-microsoft", arch: "amd64", family: "unix"
  • Kubernetes / Red Hat OpenShift setup and version:
OpenShift Master:
    v3.11.216 
Kubernetes Master:
    v1.11.0+d4cacc0 
@rohanKanojia
Copy link
Member

Looks like ProjectLabelEnricher which is responsible for adding these selector doesn't support customizing them in the configuration:

https://github.com/eclipse/jkube/blob/d8b763722c64fe09e1738da1825bab00df7ab228/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/ProjectLabelEnricher.java#L159-L165

I think we should add some more configuration options in enricher config which can be used to customize generated selector labels:

https://github.com/eclipse/jkube/blob/d8b763722c64fe09e1738da1825bab00df7ab228/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/ProjectLabelEnricher.java#L55-L62

@TueDissingWork
Copy link
Contributor Author

N

Looks like ProjectLabelEnricher which is responsible for adding these selector doesn't support customizing them in the configuration:

https://github.com/eclipse/jkube/blob/d8b763722c64fe09e1738da1825bab00df7ab228/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/ProjectLabelEnricher.java#L159-L165

I think we should add some more configuration options in enricher config which can be used to customize generated selector labels:

https://github.com/eclipse/jkube/blob/d8b763722c64fe09e1738da1825bab00df7ab228/jkube-kit/enricher/generic/src/main/java/org/eclipse/jkube/enricher/generic/ProjectLabelEnricher.java#L55-L62

Nice rohanKanojia. That explains why it doesn't work for me :-)

@rohanKanojia
Copy link
Member

@TueDissingWork : Would you like to submit a PR to add options in Config if you have some time?

@TueDissingWork
Copy link
Contributor Author

@rohanKanojia Sure. Why not, but it will not be in the foreseeable future, as vacation time hits now.

@rohanKanojia
Copy link
Member

np, We would take this up in coming sprint

@rohanKanojia rohanKanojia added the enhancement New feature or request label Jul 2, 2020
@manusa
Copy link
Member

manusa commented Jul 13, 2020

Blocked by #248

@TueDissingWork
Copy link
Contributor Author

just merged back all changes from master, and now I can't bulid the project.
I am met with the following problems:

[INFO] --- maven-enforcer-plugin:1.4.1:enforce (dependency-convergence) @ jkube-kit-common-maven ---
[WARNING]
Dependency convergence error for org.apache.maven:maven-model:3.0 paths to dependency are:
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-archiver:3.2.0
    +-org.apache.maven:maven-model:3.0
and
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-core:3.5.4
    +-org.apache.maven:maven-model:3.5.4
and
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-core:3.5.4
    +-org.apache.maven:maven-plugin-api:3.5.4
      +-org.apache.maven:maven-model:3.5.4
and
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-core:3.5.4
    +-org.apache.maven:maven-model-builder:3.5.4
      +-org.apache.maven:maven-model:3.5.4
and
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-core:3.5.4
    +-org.apache.maven:maven-resolver-provider:3.5.4
      +-org.apache.maven:maven-model:3.5.4

[WARNING]
Dependency convergence error for org.apache.maven:maven-artifact:3.0 paths to dependency are:
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-archiver:3.2.0
    +-org.apache.maven:maven-artifact:3.0
and
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-core:3.5.4
    +-org.apache.maven:maven-artifact:3.5.4
and
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-core:3.5.4
    +-org.apache.maven:maven-plugin-api:3.5.4
      +-org.apache.maven:maven-artifact:3.5.4
and
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-core:3.5.4
    +-org.apache.maven:maven-model-builder:3.5.4
      +-org.apache.maven:maven-artifact:3.5.4
and
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven.plugin-tools:maven-plugin-annotations:3.6.0
    +-org.apache.maven:maven-artifact:3.0

[WARNING]
Dependency convergence error for org.codehaus.plexus:plexus-interpolation:1.22 paths to dependency are:
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-archiver:3.2.0
    +-org.codehaus.plexus:plexus-interpolation:1.22
and
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-core:3.5.4
    +-org.apache.maven:maven-settings-builder:3.5.4
      +-org.codehaus.plexus:plexus-interpolation:1.24
and
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-core:3.5.4
    +-org.apache.maven:maven-model-builder:3.5.4
      +-org.codehaus.plexus:plexus-interpolation:1.24
and
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven.shared:maven-filtering:3.1.1
    +-org.codehaus.plexus:plexus-interpolation:1.22

[WARNING]
Dependency convergence error for org.apache.maven.shared:maven-shared-utils:3.2.0 paths to dependency are:
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-archiver:3.2.0
    +-org.apache.maven.shared:maven-shared-utils:3.2.0
and
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-core:3.5.4
    +-org.apache.maven.shared:maven-shared-utils:3.2.1
and
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven.shared:maven-filtering:3.1.1
    +-org.apache.maven.shared:maven-shared-utils:3.0.0

[WARNING] Rule 0: org.apache.maven.plugins.enforcer.DependencyConvergence failed with message:
Failed while enforcing releasability the error(s) are [
Dependency convergence error for org.apache.maven:maven-model:3.0 paths to dependency are:
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-archiver:3.2.0
    +-org.apache.maven:maven-model:3.0
and
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-core:3.5.4
    +-org.apache.maven:maven-model:3.5.4
and
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-core:3.5.4
    +-org.apache.maven:maven-plugin-api:3.5.4
      +-org.apache.maven:maven-model:3.5.4
and
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-core:3.5.4
    +-org.apache.maven:maven-model-builder:3.5.4
      +-org.apache.maven:maven-model:3.5.4
and
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-core:3.5.4
    +-org.apache.maven:maven-resolver-provider:3.5.4
      +-org.apache.maven:maven-model:3.5.4
,
Dependency convergence error for org.apache.maven:maven-artifact:3.0 paths to dependency are:
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-archiver:3.2.0
    +-org.apache.maven:maven-artifact:3.0
and
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-core:3.5.4
    +-org.apache.maven:maven-artifact:3.5.4
and
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-core:3.5.4
    +-org.apache.maven:maven-plugin-api:3.5.4
      +-org.apache.maven:maven-artifact:3.5.4
and
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-core:3.5.4
    +-org.apache.maven:maven-model-builder:3.5.4
      +-org.apache.maven:maven-artifact:3.5.4
and
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven.plugin-tools:maven-plugin-annotations:3.6.0
    +-org.apache.maven:maven-artifact:3.0
,
Dependency convergence error for org.codehaus.plexus:plexus-interpolation:1.22 paths to dependency are:
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-archiver:3.2.0
    +-org.codehaus.plexus:plexus-interpolation:1.22
and
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-core:3.5.4
    +-org.apache.maven:maven-settings-builder:3.5.4
      +-org.codehaus.plexus:plexus-interpolation:1.24
and
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-core:3.5.4
    +-org.apache.maven:maven-model-builder:3.5.4
      +-org.codehaus.plexus:plexus-interpolation:1.24
and
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven.shared:maven-filtering:3.1.1
    +-org.codehaus.plexus:plexus-interpolation:1.22
,
Dependency convergence error for org.apache.maven.shared:maven-shared-utils:3.2.0 paths to dependency are:
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-archiver:3.2.0
    +-org.apache.maven.shared:maven-shared-utils:3.2.0
and
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven:maven-core:3.5.4
    +-org.apache.maven.shared:maven-shared-utils:3.2.1
and
+-org.eclipse.jkube:jkube-kit-common-maven:1.0.0-SNAPSHOT
  +-org.apache.maven.shared:maven-filtering:3.1.1
    +-org.apache.maven.shared:maven-shared-utils:3.0.0

Any advise on how to move past these checkers?

@manusa
Copy link
Member

manusa commented Jul 27, 2020

Compare your pom files with the master branch to see diffs. It seems that some dependencies are colliding. Did your branch include any changes to pom.xml files?

@TueDissingWork
Copy link
Contributor Author

no changes to pom. manually skipping the enforcer for now. Will compare pom.
Thanks

@TueDissingWork
Copy link
Contributor Author

pom.xml are identical. Maybe a maven cache issue?

@manusa
Copy link
Member

manusa commented Jul 27, 2020

That's really weird. Try with mvn -U... but it's really strange.
You are running mvn clean.... from the root directory, right?

@TueDissingWork
Copy link
Contributor Author

mvn -U clean install results in the above error.
[INFO] JKube Kit :: Common Maven .......................... FAILURE [ 3.618 s]

@TueDissingWork
Copy link
Contributor Author

Just performed a fresh checkout of master, but still can't build the project. Same error in Common Maven.
Running under WSL, but should not really matter.

@manusa
Copy link
Member

manusa commented Jul 27, 2020

Since poms are configured to ignore snapshots since the 3rd of June, myabe something got there in the middle.
Could you try removing any JKube artifact from your .m2 (./org/eclipse/jkube/**/*) directory and recheck?

@TueDissingWork
Copy link
Contributor Author

Hhmmm, no difference either. I can work for now. Let's address this if its still a problem when I'm ready with some code. If others can build, then it must be something at my end.

@TueDissingWork
Copy link
Contributor Author

Can anyone point me to where I need to update the documentation, to make sure this new parameter gets documeted.
Have looked, but can't seem to find it.

@rohanKanojia
Copy link
Member

I think it's here:

https://github.com/eclipse/jkube/tree/master/kubernetes-maven-plugin/doc/src/main/asciidoc/inc

@TueDissingWork
Copy link
Contributor Author

I want to add some tests to the written code, but can't seem to figure out where the /jkube-kit-enricher-generic/src/main/java/org/eclipse/jkube/enricher/generic/ProjectLabelEnricher.java class is tested.
Found /jkube-kit-enricher-generic/src/test/java/org/eclipse/jkube/enricher/generic/MavenProjectEnricherTest.java, but that doesn't seem to test the project label part.

Is there a good example that I can look at?

@rohanKanojia
Copy link
Member

rohanKanojia commented Jul 28, 2020

It appears that ProjectLabelEnricher doesn't have any test right now. You can have a look at tests for this package:

https://github.com/eclipse/jkube/tree/master/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic

@TueDissingWork
Copy link
Contributor Author

OK. Thanks.

@rohanKanojia
Copy link
Member

So basically, you want to assert stuff inside .spec . I think you can provide a list of Deployment object and pass it to enricher as argument. Then you can assert the list returned and build Deployment using buildFirstItem() method, then assert generated Deployment object:

https://github.com/eclipse/jkube/blob/68ac53f4546610f05fbced4b75b49868a58556d7/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/openshift/DeploymentConfigEnricherTest.java#L50-L70

@TueDissingWork TueDissingWork mentioned this issue Jul 28, 2020
12 tasks
@TueDissingWork
Copy link
Contributor Author

So basically, you want to assert stuff inside .spec . I think you can provide a list of Deployment object and pass it to enricher as argument. Then you can assert the list returned and build Deployment using buildFirstItem() method, then assert generated Deployment object:

https://github.com/eclipse/jkube/blob/68ac53f4546610f05fbced4b75b49868a58556d7/jkube-kit/enricher/generic/src/test/java/org/eclipse/jkube/enricher/generic/openshift/DeploymentConfigEnricherTest.java#L50-L70

I found an example of the project label parameter, so it ended up being super simple.

I naturally forgot to sign off my commits :-( so now I'm fighting Git to let me change only my own commit messages.

@rohanKanojia
Copy link
Member

Maybe you could use git commit --amend ?

@TueDissingWork
Copy link
Contributor Author

Maybe you could use git commit --amend ?

Need to use git rebase...but yes the --amend option is nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants