How to Deploy ArgoCD with Portainer

How to Deploy ArgoCD with Portainer

This is a consolidation of my understanding from the video “How to Deploy ArgoCD” with Portainer on the official Portainer IO YouTube channel.

YouTube link: How to Deploy ArgoCD with Portainer

In this blog, We will see how Portainer can help facilitate to deploy and use Argo CD. What we have got here is a running Portainer instance managing a local Kubernetes cluster and one remote Kubernetes cluster. You can have a different set of them up and running. We are going to use Portainer to deploy ArgoCD to our local Kubernetes cluster, and then we are going to use ArgoCD to deploy demo applications to both the local and remote clusters.

Setting up our local cluster for ArgoCD

This is our PortainerIO home:

Capture.PNG

  1. Select the local cluster in home, then click on namespaces to the left pane for creating a namespace for ArgoCD to live in. Give a name, then click on add “namespace with form” on top. Give a name and turn off resource assignment, as it is out of scope for this tutorial. Finally, click on create Namespace. Refer to the below image. 1.PNG

  2. Now you’ll see the ArgoCD namespace in the list. Now we are going to install ArgoCD. For this, Click on Helm in the left tab. If this is your first time in this section, then you probably don’t have any application to choose from. For this, just add the Bitnami repository- charts.bitnami.com/bitnami in the additional repository section. The page will now refresh, and you’ll have your list. 2.PNG

  3. Now in charts section find and click on ArgoCD helm chart. Now in configuration tab add the ArgoCD namespace and in the name section give a string value, in my case I have given it argocd. Click on show custom values, here on the file that pops up below scroll down and go to the section “#Argo CD server service parameters” Here we have to change the service type from “ClusterIp” to “NodePort”. Specify the NodePort values that you have given while creating the cluster, and click install. 1.PNG

  4. Now go to Applications in the left panel, and you’ll be seeing different components of ArgoCD. Wait until the status of everything becomes green, which will indicate that the installation is complete.

2.PNG

Setting up ArgoCD and Deploying the application:

Here we are setting up ArgoCD and Deploying our application in the local cluster. These are the steps to achieve this:

  1. Now that the installation is done, we are going to try to hit ArgoCD by browsing the IP address of my cluster on the Nodeport which we have specified during the installation. In my case, it’s “demo.local.net:32443”. You’ll land up on the below page. 3.PNG

  2. Here, the username is admin. To get the password which was generated during install, go back to Portainer, click on “ConfigMaps and Secrets” in the left tab. Here a secret will be generated during the helm install which is named “argocd-secret” for me. Here, the value for key “clearPassword” is our default-admin-password. Go back to ArgoCD and copy the password. 4.PNG 5.PNG

  3. Now you can see the ArgoCD dashboard after signing in. Now the first step is to add the repository where our application is available. Click on connect the repository using HTTPS. Now fill up the details. Type will be git > select default in project > add your project’s repo URL> give your GitHub Username> Whereas in password give the Personal Access Token of GitHub account> Click Connect. 6.PNG 7.PNG

  4. Now go to manage Application in the left pane > Click on create Application> In General Give a name> Select Project as default> Sync Policy as “Automatic” > Select “Prune Resources” and “Self Heal”> In Sync options select “Auto-Create Namespace”> In source give your apps repo URL> In revision, give HEAD otherwise the specific branch you want to run the app from> In the Path add the directory where you have kept the Kubernetes YAML file in the project > Now give the local cluster URL and a Namespace in destination where you want to deploy > Click Create and wait for installation. 8.PNG 9.PNG

  5. We can see the demo app running and check its status. The number of pods can be seen running as per the nginx file. We can see how ArgoCD piece on continuous delivery by changing the replicas value in our project’s nginx and seeing the number of pods vary simultaneously. 10.PNG

  6. Hence, our app is deployed in the local cluster. In the next section, we will deploy our app in the second remote cluster.

Deploying the application in the remote Cluster

Here we are deploying our application in the remote cluster. These are the steps to be followed:

  1. First, we have to let ArgoCD know about the second cluster by adding a Kubernetes secret for it. For that, we will create a manifest file for our secret. Take a template manifest file as shown below in the image. 11.PNG

  2. In this we need to add the server URL and bearer token which can be obtained from the portainer by clicking on the remote cluster to manage > Go to Kube config in the left pane and click on it to open it. Here you’ll find a token and a server URL, copy and paste it in our manifest file. 12.PNG

  3. Now this manifest file can be used in portainer to add a secret. Click on “ConfigMaps & Secrets” (make sure you’re managing the local cluster where ArgoCD is running). Click on “Create from Manifest” button at the top > Use the namespace given for ArgoCD that we have created and that is exactly where we want the secret to be placed.

  4. Now, in the Build Method, Click on the Web Editor. Paste the manifest file that you have created here and click on deploy. Now ArgoCD knows about the second cluster. 13.PNG

  5. Go to ArgoCD, click on settings in the left pane > click on clusters. You’ll see the second cluster here. So now you can deploy to this. 14.PNG

  6. Go back to manage your Applications > Click on New App >fill up the details as per instructions in the previous section, 4th point > Click on Create. 15.PNG

  7. Now you’ll see the status where it’ll pull it down, then sync and bring it online. Hence, we have deployed our application in the second cluster. 16.PNG

Summary

So Finally, we have configured ArgoCD with a portainer and had our application deployed on both clusters. You can do the same in case of multiple clusters. In case of any errors, please do comment here, I’ll rectify them immediately. And for more intuition into this, please visit the linked source YouTube video on the official PortainerIO channel at the top here.