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

Doublon of StatefulSet generated by Kubernetes extension #25162

Closed
tarilabs opened this issue Apr 26, 2022 · 2 comments · Fixed by #25188
Closed

Doublon of StatefulSet generated by Kubernetes extension #25162

tarilabs opened this issue Apr 26, 2022 · 2 comments · Fixed by #25188
Labels
area/kubernetes kind/bug Something isn't working
Milestone

Comments

@tarilabs
Copy link
Contributor

Describe the bug

I want to define a volumeClaimTemplates for my Quarkus app which is meant to be a StatefulSet.

I follow the documentation here: https://quarkus.io/guides/deploying-to-kubernetes#using-existing-resources
So it should be possible to have a "base template" provided I am using the expected name and container-name, which I do here: https://github.com/tarilabs/hello-pvdf/blob/8fa82c58a3d9889c75d86bd0317a4443440c2ca2/src/main/kubernetes/kubernetes.yml#L2-L18

Please notice I configured the Quarkus app as StatefulSet as described in the guide, I do so here: https://github.com/tarilabs/hello-pvdf/blob/8fa82c58a3d9889c75d86bd0317a4443440c2ca2/src/main/resources/application.properties#L11

However despite using the expected name and container-name, I end up with the file inside of target/kubernetes/kubernetes.yml to contain 2 duplicated entries of the StatefulSet.

It should be noted if I did a classic Deployment, so reflecting the change by omitting the line in the application.properties and changing the line: https://github.com/tarilabs/hello-pvdf/blob/8fa82c58a3d9889c75d86bd0317a4443440c2ca2/src/main/kubernetes/kubernetes.yml#L2
to read kind: Deployment the duplication in the generated target/kubernetes/kubernetes.yml file does not happen

Expected behavior

Only single "StatefulSet" inside of target/kubernetes/kubernetes.yml

Actual behavior

There are two StatefulSet generated inside the target/kubernetes/kubernetes.yml file, with the same "name".
Fortunately the correct one comes first, so it still "works" but using kubectl apply -f <file> will give you error on the command line for the second definition, since trying to modify a StatefulSet which was already applied.

---
apiVersion: v1
kind: Service
metadata:
  annotations:
    app.quarkus.io/commit-id: 8fa82c58a3d9889c75d86bd0317a4443440c2ca2
    app.quarkus.io/build-timestamp: 2022-04-26 - 09:00:49 +0000
  labels:
    app.kubernetes.io/name: hello-pvdf
    app.kubernetes.io/version: 1.0.0-SNAPSHOT
  name: hello-pvdf
  namespace: default
spec:
  ports:
    - name: http
      port: 80
      targetPort: 8080
  selector:
    app.kubernetes.io/name: hello-pvdf
    app.kubernetes.io/version: 1.0.0-SNAPSHOT
  type: ClusterIP
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  annotations:
    app.quarkus.io/commit-id: 8fa82c58a3d9889c75d86bd0317a4443440c2ca2
    app.quarkus.io/build-timestamp: 2022-04-26 - 09:00:49 +0000
  labels:
    app.kubernetes.io/name: hello-pvdf
    app.kubernetes.io/version: 1.0.0-SNAPSHOT
  name: hello-pvdf
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: hello-pvdf
      app.kubernetes.io/version: 1.0.0-SNAPSHOT
  serviceName: hello-pvdf
  template:
    metadata:
      labels:
        app.kubernetes.io/name: hello-pvdf
        app.kubernetes.io/version: 1.0.0-SNAPSHOT
    spec:
      containers:
        - env:
            - name: KUBERNETES_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: PVDF_DIRECTORY
              value: /mnt/data
          image: quay.io/mmortari/hello-pvdf:1.0.0-SNAPSHOT
          imagePullPolicy: Always
          livenessProbe:
            failureThreshold: 3
            httpGet:
              path: /q/health/live
              port: 8080
              scheme: HTTP
            initialDelaySeconds: 0
            periodSeconds: 30
            successThreshold: 1
            timeoutSeconds: 10
          name: hello-pvdf
          ports:
            - containerPort: 8080
              name: http
              protocol: TCP
          readinessProbe:
            failureThreshold: 3
            httpGet:
              path: /q/health/ready
              port: 8080
              scheme: HTTP
            initialDelaySeconds: 0
            periodSeconds: 30
            successThreshold: 1
            timeoutSeconds: 10
          resources:
            limits:
              cpu: 1000m
              memory: 512Mi
            requests:
              cpu: 250m
              memory: 64Mi
          volumeMounts:
            - mountPath: /mnt/data
              name: my-pvc-claim
              readOnly: false
      terminationGracePeriodSeconds: 10
  volumeClaimTemplates:
    - apiVersion: v1
      kind: PersistentVolumeClaim
      metadata:
        annotations:
          app.quarkus.io/commit-id: 8fa82c58a3d9889c75d86bd0317a4443440c2ca2
          app.quarkus.io/build-timestamp: 2022-04-26 - 09:00:49 +0000
        labels:
          app.kubernetes.io/name: hello-pvdf
          app.kubernetes.io/version: 1.0.0-SNAPSHOT
        name: my-pvc-claim
        namespace: default
      spec:
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: 10Mi
        storageClassName: standard
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  annotations:
    app.quarkus.io/commit-id: 8fa82c58a3d9889c75d86bd0317a4443440c2ca2
    app.quarkus.io/build-timestamp: 2022-04-26 - 09:00:49 +0000
  labels:
    app.kubernetes.io/name: hello-pvdf
    app.kubernetes.io/version: 1.0.0-SNAPSHOT
  name: hello-pvdf
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: hello-pvdf
      app.kubernetes.io/version: 1.0.0-SNAPSHOT
  serviceName: hello-pvdf
  template:
    metadata:
      labels:
        app.kubernetes.io/name: hello-pvdf
        app.kubernetes.io/version: 1.0.0-SNAPSHOT
    spec:
      containers:
        - env:
            - name: KUBERNETES_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: PVDF_DIRECTORY
              value: /mnt/data
          image: quay.io/mmortari/hello-pvdf:1.0.0-SNAPSHOT
          imagePullPolicy: Always
          livenessProbe:
            failureThreshold: 3
            httpGet:
              path: /q/health/live
              port: 8080
              scheme: HTTP
            initialDelaySeconds: 0
            periodSeconds: 30
            successThreshold: 1
            timeoutSeconds: 10
          name: hello-pvdf
          ports:
            - containerPort: 8080
              name: http
              protocol: TCP
          readinessProbe:
            failureThreshold: 3
            httpGet:
              path: /q/health/ready
              port: 8080
              scheme: HTTP
            initialDelaySeconds: 0
            periodSeconds: 30
            successThreshold: 1
            timeoutSeconds: 10
          resources:
            limits:
              cpu: 1000m
              memory: 512Mi
            requests:
              cpu: 250m
              memory: 64Mi
          volumeMounts:
            - mountPath: /mnt/data
              name: my-pvc-claim
              readOnly: false
      terminationGracePeriodSeconds: 10

How to Reproduce?

  1. checkout https://github.com/tarilabs/hello-pvdf
  2. mvn clean install
  3. open target/kubernetes/kubernetes.yml you will notice the doublon

Output of uname -a or ver

Darwin mmortari1-mac 20.6.0 Darwin Kernel Version 20.6.0: Tue Feb 22 21:10:41 PST 2022; root:xnu-7195.141.26~1/RELEASE_X86_64 x86_64

Output of java -version

openjdk version "18.0.1" 2022-04-19

GraalVM version (if different from Java)

No response

Quarkus version or git rev

quarkus.platform.version>2.8.1.Final

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

Apache Maven 3.8.5 (3599d3414f046de2324203b78ddcf9b5e4388aa0)

Additional information

No response

@tarilabs tarilabs added the kind/bug Something isn't working label Apr 26, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Apr 26, 2022

/cc @geoand, @iocanel

@geoand
Copy link
Contributor

geoand commented Apr 26, 2022

@Sgitario you might be interested in this as well

Sgitario added a commit to Sgitario/quarkus that referenced this issue Apr 27, 2022
When users add a StatefulSet resource and the deployment-target is set to `StatefulSet`, we need to read the StatefulSet resource from the user and populate it accordingly.

Before these changes, we were including the StatefulSet resource, but adding a new one (with the same name), so in the end, two StatefulSet resources were included in the final kubernetes.yml.

Fix quarkusio#25162
Sgitario added a commit to Sgitario/quarkus that referenced this issue Apr 27, 2022
When users add a StatefulSet resource and the deployment-target is set to `StatefulSet`, we need to read the StatefulSet resource from the user and populate it accordingly.

Before these changes, we were including the StatefulSet resource, but adding a new one (with the same name), so in the end, two StatefulSet resources were included in the final kubernetes.yml.

Fix quarkusio#25162
Sgitario added a commit to Sgitario/quarkus that referenced this issue Apr 27, 2022
When users add a StatefulSet resource and the deployment-target is set to `StatefulSet`, we need to read the StatefulSet resource from the user and populate it accordingly.

Before these changes, we were including the StatefulSet resource, but adding a new one (with the same name), so in the end, two StatefulSet resources were included in the final kubernetes.yml.

Fix quarkusio#25162
@quarkus-bot quarkus-bot bot added this to the 2.10 - main milestone Apr 27, 2022
@gsmet gsmet modified the milestones: 2.10 - main, 2.9.0.Final May 3, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue May 3, 2022
When users add a StatefulSet resource and the deployment-target is set to `StatefulSet`, we need to read the StatefulSet resource from the user and populate it accordingly.

Before these changes, we were including the StatefulSet resource, but adding a new one (with the same name), so in the end, two StatefulSet resources were included in the final kubernetes.yml.

Fix quarkusio#25162

(cherry picked from commit a892847)
@gsmet gsmet modified the milestones: 2.9.0.Final, 2.8.3.Final May 5, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue May 5, 2022
When users add a StatefulSet resource and the deployment-target is set to `StatefulSet`, we need to read the StatefulSet resource from the user and populate it accordingly.

Before these changes, we were including the StatefulSet resource, but adding a new one (with the same name), so in the end, two StatefulSet resources were included in the final kubernetes.yml.

Fix quarkusio#25162

(cherry picked from commit a892847)
gsmet pushed a commit to gsmet/quarkus that referenced this issue May 5, 2022
When users add a StatefulSet resource and the deployment-target is set to `StatefulSet`, we need to read the StatefulSet resource from the user and populate it accordingly.

Before these changes, we were including the StatefulSet resource, but adding a new one (with the same name), so in the end, two StatefulSet resources were included in the final kubernetes.yml.

Fix quarkusio#25162

(cherry picked from commit a892847)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubernetes kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants