Skip to content

Default Values in Helm Templates Cause ArgoCD Sync Issue #626

Open
@fjammes

Description

@fjammes

Problem

Helm charts often include explicit default values for certain parameters in the rendered templates. However, when Kubernetes stores these resources in etcd, it removes these default values from the actual state. This discrepancy causes ArgoCD sync issues, as it detects differences between the desired state (explicit defaults) and the actual state (defaults removed).

For example, in the provided ArgoCD configuration file, jqPathExpressions are used to ignore these discrepancies:

ignoreDifferences:
- group: "apiextensions.k8s.io"
  kind: "CustomResourceDefinition"
  jqPathExpressions:
  - .spec.names.categories | select(. == [])
  - .spec.names.shortNames | select(. == [])
  - .spec.versions[].additionalPrinterColumns | select(. == [])

While this workaround resolves sync errors, it adds complexity to the configuration.

In addition, here is the full ArgoCD file which allow to install a bunck of stackable operators:

{{ if and .Values.e2e.enabled .Values.stackable.enabled }}
{{- range $.Values.stackable.operators }}
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: "{{ . }}-operator"
  namespace: argocd
  labels:
    app.kubernetes.io/name: "{{ . }}-operator"
    app.kubernetes.io/part-of: fink
    app.kubernetes.io/component: operator
  finalizers:
  - resources-finalizer.argocd.argoproj.io
spec:
  project: default
  ignoreDifferences:
  - group: "apiextensions.k8s.io"
    kind: "CustomResourceDefinition"
    # Default values for these fields appears explicitely in desired state but are removed from actual state
    jqPathExpressions:
    - .spec.names.categories | select(. == [])
    - .spec.names.shortNames | select(. == [])
    - .spec.versions[].additionalPrinterColumns | select(. == [])
  source:
    chart: "{{ . }}-operator"
    repoURL: https://repo.stackable.tech/repository/helm-stable/
    targetRevision: 24.11.0
    helm:
      releaseName: "{{ . }}-operator"
      valuesObject:
        resources:
          requests:
            cpu: "0"
            memory: "0"
  destination:
    server: "https://kubernetes.default.svc"
    namespace: stackable-operators
  syncPolicy:
    syncOptions:
      - CreateNamespace=true
      - ServerSideApply=true
      - RespectIgnoreDifferences=true
---
{{- end }}
{{ end }}

Desired Behavior

Helm templates should avoid explicitly rendering default values that Kubernetes automatically assigns. This would eliminate the need for jqPathExpressions in ArgoCD configurations, simplifying setup and maintenance.

Proposed Solution

  • Update the Helm chart templates to conditionally omit parameters that match Kubernetes' default values.
    For instance:
    {{- if .Values.someParameter }}
    someField: {{ .Values.someParameter }}
    {{- end }}
  • Ensure that the templates only render non-default values when explicitly provided.

Benefits

  • Simplified ArgoCD Configurations: Removing the need for jqPathExpressions in the ignoreDifferences section.
  • Improved Sync Behavior: Avoid unnecessary diffs between desired and actual states.
  • Better Alignment with Kubernetes Practices: Align Helm templates with Kubernetes behavior regarding default values.

Impact

This change would enhance compatibility with ArgoCD and improve usability for teams relying on GitOps workflows to manage Helm-based deployments.

Additional Context

For example, with this change, the provided ArgoCD configuration could omit the ignoreDifferences block, as the sync issues caused by explicit defaults would no longer occur.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions