quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.8k stars 2.68k forks source link

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

Open antoniomacri opened 1 month ago

antoniomacri commented 1 month ago

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

quarkus-bot[bot] commented 1 month ago

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