Deploy and use ArgoCD with Portainer (Part 1)

by Neil Cresswell, CEO, on February 11, 2022

Portainer already has a good continuous delivery (CD) engine built in, one that ensures applications running in Portainer managed Kubernetes clusters are consistent with their mainifest definitions stored within a Git repo.

Portainer Advanced Redeployment

But, what if you want to use ArgoCD? Does that mean you can't use Portainer for your centralized Kubernetes management? The answer is 'no'.  This two-part blog shows you how to set it up.

Part 1 is deploying an ArgoCD management instance on a Kubernetes cluster. Part 2 is connecting that management instance to additional Kubernetes clusters. This blog focuses on Part 1, with Part 2 linked at the end.

 

The easiest way to get ArgoCD installed is to use the helm chart provided in Portainer, under our HELM page.

Jump Into Portainer and connect to the Kubernetes environment that you want to host the ArgoCD server. In my case, it's my laptop, but for an organization, this will likely be an instance in your data center.

Click on namespaces, and create a namespace called argocd (note it has to be called this to work, else you need to modify the argo manifests)

Portainer Create a Namespace

Now, click on "HELM", and then "Argo-CD"

Portainer Helm

Select the "argocd" namespace, and give the deployment a name, argocd, then click the "show custom values".

In the web editor, scroll to lines 1041 and change the service type to NodePort, then on lines 1046/1047 and replace the " " with two free nodeports in your system. I used 30080 and 30443 (dont forget to remove the speechmarks), then click "Install"

Switch to "Applications" view, and wait for all 5 components go green.

Portainer Applications screenshot

Click on the "argocd-argo-cd-server" component and see the 2x NodePorts you assigned.

Portainer Application Details screenshot

Now let's open the ArgoCD UI. In my case, its https://localhost:30443

ArgoCD UI

Ah, but what's the username and password? Well that was auto-generated by ArgoCD at install time, so let's retrieve it.

Go back to Portainer, and click on ConfigMaps&Secrets. Click on the secret called "argocd-secret".  Look for "clearPassword". Copy the value, as that's the password for the "admin" user.

Portainer ConfigMaps&Secrets screenshot

Now, login to ArgoCD UI as admin, with that password.

ArgoCD UI

ArgoCD is now installed, and ready to be used. You can use this instance to deploy applications on this local cluster. Here's how:

Click on Settings and then Repositories.

Add credentials for your Git repo. In my case, I am connecting to a repo using https. Click "Connect"

Connect Repo screenshot

Make sure your repo has connected successfully.

Successful Repo Connection screenshot

Now that's done, you can deploy your first gitops app. Click on Apps, then "Create Application" and fill in the details for your Git repo.

Give your app a name, select the default project (unless you are using custom projects). Select "prune resources" and "self heal" if you want Kubernetes to ALWAYS reflect the settings you have for your app in Git.

Portainer Deply your first GitOps App

Now select the repository URL you defined previously, set the branch revision from git (in my case, its just HEAD), and set the path to the manifest files (in my case, demo).

Select the Repository URL

Set your destination cluster (we only have the local one defined at the moment), then select the target namespace. Note the namespace needs to exist first, else Argo will fail.

Set Your Destination Cluster

In my case, I selected a namespace that doesn't exist, and this is what you see in Argo UI.

View in ArgoCD

So let's go back into Portainer and create the namespace.

Click on "Namespaces", then click "Add namespace from form"

Name it demoapp (as used in your Argo deployment),disable resource assignment, and then click create.

Portainer Create a Namespace

Go back into Argo UI, click Applications, find your app, and click "Refresh"

ArgoCD Apps screenshot

See that it now switches to "Healthy" and "Synced"

Back in Portainer, click on Applications, and see the app is deployed and running.

Portainer Application List screenshot

Now, go into Git, edit your deployment file, and then wait for the change to propagate. In my case, I will increase replicas to 2.

Portainer demo Git deployment

in a few minutes, Portainer will reflect 2 replicas.

Portainer reflects 2 replicas

This is how you use Portainer and ArgoCD together. Easy.

In PART 2 of the blog, I will show how to add Portainer Managed Kubernetes Clusters to this ArgoCD instance.

 

 

 

 

Interested in running Portainer in a business environment?

Portainer Business is our fully featured, fully supported business product. It is used by some of the largest organizations in the world to deliver a powerful self-service container management experience for developers and IT teams. With more than 500,000 active users, Portainer is proven to be the simplest and most effective way of managing Docker, Swarm, and Kubernetes environments.

GET 5 NODES OF PORTAINER BUSINESS FREE TALK TO SALES

Topics:Lifecycle ManagementGitOps

Comments