eclipse-jkube / jkube

Build and Deploy java applications on Kubernetes
https://www.eclipse.dev/jkube/
Eclipse Public License 2.0
755 stars 494 forks source link

Inconsistency when merging a route.yml fragment with two different profiles (commons, demo) #2758

Open vmarzal opened 7 months ago

vmarzal commented 7 months ago

Describe the bug

Problem merging a 'route.yml' common configuration with a environment one. The result is not displaying several annotations placed in the common file.

Eclipse JKube version

1.16.1

Component

OpenShift Maven Plugin

Apache Maven version

other (please specify in additional context)

Gradle version

None

Steps to reproduce

I was trying to extract a common configuration from the metadata.annotations route.yml files of two environments.

Common configuration:

metadata:
  annotations:
    cert-manager.io/issuer-kind: ClusterIssuer
    cert-manager.io/issuer-name: letsencrypt-prod
  1. I put that piece in the /common/route.yml:
metadata:
  annotations:
    cert-manager.io/issuer-kind: ClusterIssuer
    cert-manager.io/issuer-name: letsencrypt-prod
spec:
  tls:
    insecureEdgeTerminationPolicy: Redirect
    termination: edge
  1. And delete it from the environment files (example from de /demo/route.yml) getting simple fragments like these:
metadata:
  namespace: demo-namespace
spec:
  host: demo-namespace.apps.ocpdes.es
  1. The profile activation is performed with the configuration provided and the directories exist in src/main/jkube.
<profile>
    <id>demo</id>
    <properties>
        <spring.profiles.active>demo</spring.profiles.active>
        <jkube.environment>common,demo</jkube.environment>
    </properties>
</profile>

With the command 'mvn oc:resource -Pdemo' I get that merged route.yml file with no trace of my custom annotations.

---
apiVersion: route.openshift.io/v1
kind: Route
metadata:
  annotations:
    jkube.eclipse.org/scm-url: ...
    jkube.eclipse.org/scm-tag: HEAD
    jkube.eclipse.org/git-commit: 22ec86b77b032234a5a4d9c70bbda3f2e5e910a0
    jkube.eclipse.org/git-url: ...
    app.openshift.io/vcs-ref:...
    app.openshift.io/vcs-uri: ...
    jkube.eclipse.org/git-branch: ....
  labels:

Expected behavior

The expected behavior is a route.yml file with the common annotations (in addition to the opinionated defaults):

---
apiVersion: route.openshift.io/v1
kind: Route
metadata:
  annotations:
    cert-manager.io/issuer-name: letsencrypt-prod
    cert-manager.io/issuer-kind: ClusterIssuer
    jkube.eclipse.org/scm-url: ...
    jkube.eclipse.org/scm-tag: HEAD
    ....

Runtime

OpenShift

Kubernetes API Server version

1.22.15

Environment

Windows

Eclipse JKube Logs

No response

Sample Reproducer Project

No response

Additional context

Maven 3.9.4

arsenalzp commented 5 months ago

Hello colleagues, Can I work on this issue?

rohanKanojia commented 5 months ago

Umm, it's not decided yet how to approach this problem. But if you want to give it a try and propose something, feel free to go ahead.

arsenalzp commented 5 months ago

Could you please assign it to me?

rohanKanojia commented 5 months ago

@arsenalzp : Sorry, we don't have any bot running for these kind of project chores.

Thanks for showing interest in fixing this issue.

rohanKanojia commented 3 months ago

@arsenalzp : Hello, are you still working on this issue?

arsenalzp commented 3 months ago

Hello, I have two more issues and PRs which are being reviewed right now. Let me manage with them then I proceed with this issue.

arsenalzp commented 1 month ago

Hello, Some of my PRs were accepted so I'm ready to work for this issue!

arsenalzp commented 1 month ago

Oh, I spent a couple of hours to troubleshoot the issue. The main question: how should it work, what is the expectation? Enricher creates two resources based on the given resources fragments; requestor of this particular issue used two files named identically for two different resource/profile. Name should be different based on environment names: common/common-route.yml and demo/demo-route.yml for common and demo environments respectively, then two different files are produced:

target/classes/META-INF/jkube/openshift/common-route.yml:

apiVersion: v1
kind: Route
metadata:
  annotations:
    cert-manager.io/issuer-name: letsencrypt-prod
    cert-manager.io/issuer-kind: ClusterIssuer
  labels:
    testProject: spring-boot-sample
    app: spring-boot
    provider: jkube
    version: 1.17.0
    group: org.eclipse.jkube.quickstarts.maven
    app.kubernetes.io/part-of: org.eclipse.jkube.quickstarts.maven
    app.kubernetes.io/managed-by: jkube
    app.kubernetes.io/name: spring-boot
    app.kubernetes.io/version: 1.17.0
  name: common
spec:
  tls:
    insecureEdgeTerminationPolicy: Redirect
    termination: edge

and

target/classes/META-INF/jkube/openshift/demo-route.yml:

apiVersion: v1
kind: Route
metadata:
  labels:
    testProject: spring-boot-sample
    app: spring-boot
    provider: jkube
    version: 1.17.0
    group: org.eclipse.jkube.quickstarts.maven
    app.kubernetes.io/part-of: org.eclipse.jkube.quickstarts.maven
    app.kubernetes.io/managed-by: jkube
    app.kubernetes.io/name: spring-boot
    app.kubernetes.io/version: 1.17.0
  name: demo
  namespace: demo-namespace
spec:
  host: demo-namespace.apps.ocpdes.es

Otherwise, enricher produces two files named like route.yml and route-1.yml withe the identical content.