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

Wrong generation of kubernetes.yml depending on <resources> #43780

Closed
antoniomacri opened this issue Oct 9, 2024 · 4 comments
Closed

Wrong generation of kubernetes.yml depending on <resources> #43780

antoniomacri opened this issue Oct 9, 2024 · 4 comments
Labels
area/kubernetes kind/question Further information is requested

Comments

@antoniomacri
Copy link

antoniomacri commented Oct 9, 2024

Describe the bug

The generation of the file kubernetes.yml is incomplete if resources are defined in the pom and do not include application.properties

Expected behavior

The generated kubernetes.yml is the same independently on resources I've defined in the pom. For instance:

---
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    app.quarkus.io/quarkus-version: 3.15.1
    app.quarkus.io/commit-id: c4fdc9650b0fd7eefb4e99d6bfcdc94bf96cda7c
    app.quarkus.io/build-timestamp: 2024-10-09 - 08:49:28 +0000
  labels:
    app.kubernetes.io/name: code-with-quarkus
    app.kubernetes.io/version: 1.0.0-SNAPSHOT
    app.kubernetes.io/managed-by: quarkus
  name: code-with-quarkus
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/version: 1.0.0-SNAPSHOT
      app.kubernetes.io/name: code-with-quarkus
  template:
    metadata:
      annotations:
        app.quarkus.io/quarkus-version: 3.15.1
        app.quarkus.io/commit-id: c4fdc9650b0fd7eefb4e99d6bfcdc94bf96cda7c
        app.quarkus.io/build-timestamp: 2024-10-09 - 08:49:28 +0000
      labels:
        app.kubernetes.io/managed-by: quarkus
        app.kubernetes.io/version: 1.0.0-SNAPSHOT
        app.kubernetes.io/name: code-with-quarkus
    spec:
      containers:
        - env:
            - name: KUBERNETES_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: B
              value: BB
            - name: C
              value: CC
            - name: A
              value: AA
            - name: QUARKUS_PROFILE
              value: develop
            - name: TZ
              value: Europe/Rome
            - name: D
              value: DD
          image: docker.io/antonio/code-with-quarkus:1.0.0-SNAPSHOT
          imagePullPolicy: Always
          name: code-with-quarkus
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    app.quarkus.io/quarkus-version: 3.15.1
    app.quarkus.io/commit-id: c4fdc9650b0fd7eefb4e99d6bfcdc94bf96cda7c
    app.quarkus.io/build-timestamp: 2024-10-09 - 08:49:28 +0000
  labels:
    app.kubernetes.io/name: code-with-quarkus
    app.kubernetes.io/version: 1.0.0-SNAPSHOT
    app.kubernetes.io/managed-by: quarkus
  name: code-with-quarkus
spec:
  rules:
    - host: example.net

Actual behavior

The generate yaml is incomplete (missing env and ingress):

---
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    app.quarkus.io/quarkus-version: 3.15.1
    app.quarkus.io/commit-id: c4fdc9650b0fd7eefb4e99d6bfcdc94bf96cda7c
    app.quarkus.io/build-timestamp: 2024-10-09 - 08:54:46 +0000
  labels:
    app.kubernetes.io/name: code-with-quarkus
    app.kubernetes.io/version: 1.0.0-SNAPSHOT
    app.kubernetes.io/managed-by: quarkus
  name: code-with-quarkus
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: code-with-quarkus
      app.kubernetes.io/version: 1.0.0-SNAPSHOT
  template:
    metadata:
      annotations:
        app.quarkus.io/quarkus-version: 3.15.1
        app.quarkus.io/commit-id: c4fdc9650b0fd7eefb4e99d6bfcdc94bf96cda7c
        app.quarkus.io/build-timestamp: 2024-10-09 - 08:54:46 +0000
      labels:
        app.kubernetes.io/managed-by: quarkus
        app.kubernetes.io/name: code-with-quarkus
        app.kubernetes.io/version: 1.0.0-SNAPSHOT
    spec:
      containers:
        - env:
            - name: KUBERNETES_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          image: docker.io/antonio/code-with-quarkus:1.0.0-SNAPSHOT
          imagePullPolicy: Always
          name: code-with-quarkus

How to Reproduce?

  1. Generate a project from https://code.quarkus.io with the kubernetes extension
  2. Add this (as an example) to the application properties:
    quarkus.kubernetes.env.vars.quarkus-profile=develop
    quarkus.kubernetes.env.vars.A=AA
    quarkus.kubernetes.env.vars.B=BB
    quarkus.kubernetes.env.vars.C=CC
    quarkus.kubernetes.env.vars.D=DD
    quarkus.kubernetes.env.vars.TZ=Europe/Rome
    quarkus.kubernetes.ingress.expose=true
    quarkus.kubernetes.ingress.host=example.net
  3. As a preliminary check, run ./mvnw clean package and look at the generate kubernetes.yml: it correctly contains all the env and the ingress.
  4. Now add this to the pom.xml under <build>:
         <resources>
             <resource>
                 <directory>src/main/resources</directory>
                 <filtering>false</filtering>
                 <includes>
                     <include>META-INF/resources/**</include>
                 </includes>
             </resource>
         </resources>
  5. Run ./mvnw clean package (clean also!)
  6. Look at the generate kubernetes.yml: the env contains only KUBERNETES_NAMESPACE and the ingress is gone.
  7. After adding the application.properties as a resource the generation is correct again:
             <resource>
                 <directory>src/main/resources</directory>
                 <filtering>true</filtering>
                 <includes>
                     <include>application.properties</include>
                 </includes>
             </resource>

Output of uname -a or ver

No response

Output of java -version

21

Quarkus version or git rev

3.15.1

Build tool (ie. output of mvnw --version or gradlew --version)

mvnw

Additional information

No response

@antoniomacri antoniomacri added the kind/bug Something isn't working label Oct 9, 2024
Copy link

quarkus-bot bot commented Oct 9, 2024

/cc @geoand (kubernetes), @iocanel (kubernetes)

@geoand
Copy link
Contributor

geoand commented Nov 28, 2024

This seems very odd to me.

Mind attaching the reproducer so we can play around with it?

@antoniomacri
Copy link
Author

antoniomacri commented Nov 28, 2024

Sure: quarkus-kubernetes-app-props-reproducer.zip

Look at:

<resources>
    <resource>
        <directory>src/main/resources</directory>
        <filtering>false</filtering>
        <includes>
            <include>META-INF/resources/**</include>
        </includes>
    </resource>
    <!-- Comment the previous resource or uncomment the following -->
    <!--<resource>-->
    <!--    <directory>src/main/resources</directory>-->
    <!--    <filtering>true</filtering>-->
    <!--    <includes>-->
    <!--        <include>application.properties</include>-->
    <!--    </includes>-->
    <!--</resource>-->
</resources>

@geoand geoand added kind/question Further information is requested and removed kind/bug Something isn't working labels Nov 29, 2024
@geoand
Copy link
Contributor

geoand commented Nov 29, 2024

Actually this is standard maven behavior.

By doing:

             <includes>
                 <include>META-INF/resources/**</include>
             </includes>

you are essentially ignoring application.properties

@geoand geoand closed this as completed Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubernetes kind/question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants