Skip to content

PodDisruptionBudget helm template bug with maxUnavailable #4832

@linusyong

Description

@linusyong

Describe the bug
The an override values.yaml is provided with podDisruptionBudget.maxUnavailable, the podDisruptionBudget.minAvailable will still be rendered in spec.minAvailable of PodDisruptionBudget CR and cause a failure.

To Reproduce
Steps to reproduce the behavior:

  1. Create values-test.yaml file with
    podDisruptionBudget:
      enabled: true
      maxUnavailable: 1
    
  2. Use helm template to render the PodDisruptionBudget CR
    helm template -s templates/poddisruptionbudget.yaml test external-secrets/external-secrets -f values-test.yaml
    ---
    # Source: external-secrets/templates/poddisruptionbudget.yaml
    apiVersion: policy/v1
    kind: PodDisruptionBudget
    metadata:
      name: test-external-secrets-pdb
      namespace: kube-system
      labels:
        helm.sh/chart: external-secrets-0.17.0
        app.kubernetes.io/name: external-secrets
        app.kubernetes.io/instance: test
        app.kubernetes.io/version: "v0.17.0"
        app.kubernetes.io/managed-by: Helm
    spec:
      minAvailable: 1
      maxUnavailable: 1
      selector:
        matchLabels:
          app.kubernetes.io/name: external-secrets
          app.kubernetes.io/instance: test
    
  3. The same issue should exists in cert-controller-poddisruptionbudget.yaml and webhook-poddisruptionbudget.yaml
  4. The issue should be easily fixed by updating the poddisruptionbudget.yaml with:
    diff --git a/deploy/charts/external-secrets/templates/poddisruptionbudget.yaml b/deploy/charts/external-secrets/templates/poddisruptionbudget.yaml
    index 7b75ca3f4..a563ca0fe 100644
    --- a/deploy/charts/external-secrets/templates/poddisruptionbudget.yaml
    +++ b/deploy/charts/external-secrets/templates/poddisruptionbudget.yaml
    @@ -7,11 +7,12 @@ metadata:
       labels:
         {{- include "external-secrets.labels" . | nindent 4 }}
     spec:
    -  {{- if .Values.podDisruptionBudget.minAvailable }}
    -  minAvailable: {{ .Values.podDisruptionBudget.minAvailable }}
    -  {{- end }}
       {{- if .Values.podDisruptionBudget.maxUnavailable }}
       maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }}
    +  {{- else }}
    +    {{- if .Values.podDisruptionBudget.minAvailable }}
    +  minAvailable: {{ .Values.podDisruptionBudget.minAvailable }}
    +    {{- end }}
       {{- end }}
       selector:
         matchLabels:
    
  5. The full poddisruptionbudget.yaml should be as follows
    {{- if .Values.podDisruptionBudget.enabled }}
    apiVersion: policy/v1
    kind: PodDisruptionBudget
    metadata:
      name: {{ include "external-secrets.fullname" . }}-pdb
      namespace: {{ template "external-secrets.namespace" . }}
      labels:
        {{- include "external-secrets.labels" . | nindent 4 }}
    spec:
      {{- if .Values.podDisruptionBudget.maxUnavailable }}
      maxUnavailable: {{ .Values.podDisruptionBudget.maxUnavailable }}
      {{- else }}
      {{- if .Values.podDisruptionBudget.minAvailable }}
      minAvailable: {{ .Values.podDisruptionBudget.minAvailable }}
      {{- end }}
      {{- end }}
      selector:
        matchLabels:
          {{- include "external-secrets.selectorLabels" . | nindent 6 }}
    {{- end }}
    
  6. Kubernetes version 1.32
  7. ESO version v0.17.0
    The expectation is that with specifying podDisruptionBudget.maxUnavailable, the helm chart should render a correct PodDisruptionBudget CR.

Screenshots
Image

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions