kubernetes-helmargocd

ArgoCD with Helm: is it possible to add more resources to application deployment?


I have created new application in ArgoCD in a path containing Chart.yaml and values.yaml, the Chart is based on a open-source remote repository in GitHub. Then problem occur, and the solution was to create a PersistentVolumeClaim and mount it to directory inside a deployed container.

I have created new pvc.yaml file but ArgoCD just ignore it during syncing. Like it was not existing in the directory. Is it impossible to add more resources if this app is based on helm? If yes, is there any workaround?


Solution

  • In scenarios where I wish to customise a public chart without cloning it and modifying it, I use Kustomize to install the helm chart.

    Note that you must enable the Helm Chart inflation feature in Argo CD, details here: Kustomizing Helm charts

    This allows you to take full advantage of the public chart, but inject any additional resources in the chart that it was not designed to configure, such as your pvc.yaml.

    You can also use patches: in kustomization.yaml to modify any aspect of the chart that had not been exposed for changing.

    Here is a simple example using the ingress-nginx chart. Your Argo App CRD needs to use the Kustomize install method instead of Helm for this to work.

    # kustomization.yaml
    apiVersion: kustomize.config.k8s.io/v1beta1
    kind: Kustomization
    
    helmCharts:
    - name: ingress-nginx
      repo: https://kubernetes.github.io/ingress-nginx
      releaseName: ingress-nginx
      namespace: ingress-nginx
      version: 4.11.3
      valuesFile: values.yaml
    
    resources:
    - pvc.yaml
    
    

    Your Git repo would look something like this:

    ingress-nginx/
    ├── kustomization.yaml
    └── pvc.yaml
    └── values.yaml
    

    In our environment, we have something more complex to handle multiple environments, ours looks more like this:

    ingress-nginx/
    ├── base/
    │   └── kustomization.yaml
    ├── dev/
    │   ├── kustomization.yaml
    │   └── pvc.yaml
    │   └── values.yaml
    ├── uat/
    │   ├── kustomization.yaml
    │   └── pvc.yaml
    │   └── values.yaml
    └── prd/
        ├── kustomization.yaml
        └── pvc.yaml
    │   └── values.yaml