Search code examples
kubernetes-helmargocd

Declarative approach to deploy Helm chart by Argocd to multiple environments


I’m using Argocd with helm charts. I have two environments: uat, prod.

As far as I understand, proper approach for helm is to have base folder with commons + per env folder.

So I have single branch with 3 folders:

base # for commons: Chart.yaml, templates, etc.
uat  # for uat values.yaml
prod # for prod values.yaml

In my helm chart I have following Chart.yaml (stored in base folder):

apiVersion: v1
appVersion: 1.0.11 
name: my-nice-app
version: 1.0.11

With every release I increase appVersion and version (version is used as image tag version in charts).

I use declarative approach to deploy helm chart (this is uat application resource, similar is for prod):

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: my-nice-app
  namespace: argocd
spec:
  project: default

  source:
    repoURL: some-url
    targetRevision: HEAD
    path: base

    helm:
      version: v3
      valueFiles:
        - uat/values.yaml

  destination:
    server: https://kubernetes.default.svc
    namespace: uat

  syncPolicy:
    syncOptions:
    - CreateNamespace=false

    automated:
      selfHeal: true
      prune: true

Question:

I do update uat values file.

I do update Chart.yaml with new version.

I would like to deploy uat only (but when I update base prod would also triggers).

Where or how should I store Chart.yaml? Should I change Argocd Application resource? Or only option is to duplicate charts per env?

I prefer also not to store any version related info in Argocd Application resource (so not to change it every time).

It would be nice not to apply kustomized.io.


Solution

  • You should split it into 2 charts (base chart and value chart)
    base chart is chart dependency of value chart, like that if you update base chart, value chart won't be affected if you don't update chart dependency.

    File Chart.yaml of value-chart will look like this.

    apiVersion: v2
    name: my-nice-app-prod
    description: Chart for production
    
    type: application
    
    version: 0.0.1
    
    appVersion: "1.0.0"
    
    dependencies:
    - name: my-nice-app-chart
      version: 0.1.9
    

    Link references:
    https://helm.sh/docs/helm/helm_dependency/