helm github argocd kubernetes multiple sources deployment

Last updated on November 6th, 2024 at 08:28 am

In this tutorial I will walk you through how simple it is to define multiple sources for helm chart deployment in Argo CD.
Lets say for instance you need to pull multiple values from different git repositories. This can be accomplished easily using Argo CD.

For example, if I have 2 external github repos, one that manages replicacount and other which manages labels. I want the application configured in such a way that when I deploy the helm chart Argo CD should read these repos and override the replicacount as well as add a custom labels to the deployment.

Step 1 Connect to Argo CD Dashboard

I have already installed ArgoCD and here is how my services looks like. As you noticed I have enabled NodePort to connect to the argocd-server service

% kubectl get svc -n=argocd
NAME                                      TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                      AGE
argocd-applicationset-controller          ClusterIP   10.100.27.32     <none>        7000/TCP,8080/TCP            27d
argocd-dex-server                         ClusterIP   10.100.168.67    <none>        5556/TCP,5557/TCP,5558/TCP   27d
argocd-metrics                            ClusterIP   10.100.40.154    <none>        8082/TCP                     27d
argocd-notifications-controller-metrics   ClusterIP   10.100.124.173   <none>        9001/TCP                     27d
argocd-redis                              ClusterIP   10.100.253.246   <none>        6379/TCP                     27d
argocd-repo-server                        ClusterIP   10.100.96.207    <none>        8081/TCP,8084/TCP            27d
argocd-server                             NodePort    10.100.59.100    <none>        80:32521/TCP,443:30760/TCP   27d
argocd-server-metrics                     ClusterIP   10.100.18.254    <none>        8083/TCP                     27d

In my case I have firewall blocking direct port 80 access hence used port-forward. You will be able to directly access the node_ip:port if you don’t have any firewall in your setup. Using port-forward is not a mandatory step.

% kubectl port-forward svc/argocd-server -n=argocd 8082:80
Forwarding from 127.0.0.1:8082 -> 8080
Forwarding from [::1]:8082 -> 8080

Once done I hit the URL https://localhost:8082, login using your own credentials

Step 2 Configure Argo CD Application

Argo CD Application object by default can be used to define resources from a single source and a cluster. Application resource type also have the ability to define multiple sources for a single application deployment.

As of 9/20/2024 feature of specifying multiple sources of an application is still in beta.

It is not marked as stable feature yet.

Lets take a look at the Application manifest below and walk through some of the major configuration. Save this file as argo_application.yaml

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: 'custom-nginx-helm-values-test'
spec:
  project: custom-helm
  syncPolicy:
    automated:
      prune: false
      selfHeal: false
  destination:
    server: https://kubernetes.default.svc
    namespace: default
  sources:
  - repoURL: 'https://github.com/myrepo1/custom_nginx.git'
    targetRevision: HEAD
    path: my-nginx-helm
    helm:
      valueFiles:
      - $values/values.yaml
      - $customval/argocd-second-value/values.yaml
  - repoURL: 'https://github.com/myrepo2/replica_settings.git'
    targetRevision: HEAD
    ref: values
  - repoURL: 'https://github.com/myrepo3/label_settings.git'
    targetRevision: HEAD
    ref: customval

Under sources there are 3 repos, myrepo1,myrepo2,myrepo3

I am installing a helm chart of custom nginx package owned by me in Git Repo 1 and pulling replica count for the deployment from myrepo2 values.yaml . Also adding labels from my repo3

To get more idea on what my values.yaml files look like in each repo

Git Repo 2

Git Repo 3

As you may have noticed for myrepo3 the values.yaml file reside under the folder argocd-second-value

Step 3 Deploy the Application

At the time of writing this tutorial you cannot install multi source application using the web dashboard. For installing the multi source application you need to use argocd CLI. Here is the document on installing argocd CLI on Linux / MAC etc.,

% argocd app create custom-nginx-helm-values-test --file argo_application.yaml

Once you run the above script you will get a message similar to “application ‘custom-nginx-helm-values-test’ created“.

Note: On the web dashboard you should see something like the screenshot below, we are not syncing it by default so you have to manually sync.

Click on the application and you should see a similar output. There are 3 replicas.

Also lets confirm that the label was also added as part of the deployment