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

Default Values in Helm Templates Cause ArgoCD Sync Issue #626

Open
fjammes opened this issue Dec 6, 2024 · 1 comment
Open

Default Values in Helm Templates Cause ArgoCD Sync Issue #626

fjammes opened this issue Dec 6, 2024 · 1 comment

Comments

@fjammes
Copy link

fjammes commented Dec 6, 2024

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.

@Maleware
Copy link

Maleware commented Dec 9, 2024

Hi fjammes,

thanks for bringing this up. We are aware of the problems and are trying to provide a fix in the next release.
This might take a couple of month though.

However, if you want you can provide a fix in operator-templating. Let us know if you're interested and/or need some guidance.

Kind regards,
Maxi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants