Blog

Multi-Cloud deployments made easy with Argo CD

CloudCover + Argo CD

by Abhishek Anand & Sagar Patil

tl;dr

  • Adopting multi-cloud/hybrid cloud strategies for cloud-native application development.
  • Challenges faced with Continuous Integration, Continuous Delivery, continuous Security, etc.
  • Argo CD, a preferred choice of for continuous deployments across a multi-cloud environment.
  • Argo CD is designed for continuous deployments in a Kubernetes ecosystem while following the principles of GitOps.

What is Argo CD?

Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes

It follows the GitOps pattern of using Git repositories as the source of truth for defining the desired application state. Argo CD helps automate the deployment of the desired application states in the specified target environments while tracking updates to branches, tags, or pinned to a specific version of manifests at a Git commit.

How does Argo CD work?

Complex problems require sophisticated solutions,

Argo CD is implemented as a Kubernetes controller which continuously monitors running applications and compares the current, live state against the desired target state (as specified in the Git repo). A deployed application whose live state deviates from the target state is considered OutOfSync.

Argo CD reports & visualizes the differences while automatically or manually syncing the live state back to the desired target state. Any modifications made to the desired target state in the Git repo can be automatically applied and reflected in the specified target environments.

What’s in the box

The high-level architecture of Argo CD

Argo CD

Installing Argo CD

Argo CD can be installed using the below commands

Step 1

This will create a new namespace, argocd, where Argo CD services and application resources will live.

kubectl create namespace argocd
kubectl apply -n argocd -f
https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
Step 2

By default, the Argo CD API server can be accessed from an external IP. To access the API server, change the argocd-server service type to LoadBalancer

kubectl patch svc argocd-server -n argocd -p ‘{“spec”: {“type”: “LoadBalancer”}}’
Step 3

Access the Argo CD external UI via your default browser window and login by visiting the IP/hostname. The Admin account password is auto-generated and stored in a secret named argocd-initial-admin-secret in your Argo CD installation namespace. This initial password is stored as clear text in the field password in the secret mentioned above and is retrieved using kubectl

kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath=“{.data.password}” | base64 -D
Login Using The CLI

Download the CLI tool using the following command (for Mac users):

brew install argocd

Download the CLI tool using the following command (for Mac users):

argocd login <ARGOCD_SERVER>:443
WARNING: server certificate had error: x509: cannot validate certificate <ARGOCD_SERVER> because it doesn’t contain any IP SANs. 
Proceed insecurely (y/n)?: y
Username: admin
Password:
‘admin:login’ logged in successfullyContext ‘<ARGOCD_SERVER>:443’ updated

continuous deployments

Multi-Cloud Setup

To perform continuous deployments (CD) on multi-cloud clusters we can add individual clusters using the CLI commands. The commands used to add a cluster to Argo CD

Step 1

Connect to a new cluster. Then rename its config. Use the following command to add a new cluster to ArgoCD

az account set —subscription xxxxxx-yyyy-zzzz-xyzz-1111111
az aks get-credentials —resource-group argo-rsg —name argocd-aks-cluster
kubectl config get-contexts -o name
argocd-aks-cluster
argocd-eks-cluster
argocd-gke-cluster
argocd cluster add argocd-aks-cluster
Step 2

Argo CD creates the following resources on the added cluster

INFO[0001] ServiceAccount “argocd-manager” created in namespace “kube-system”
INFO[0001] ClusterRole “argocd-manager-role” created
INFO[0001] ClusterRoleBinding “argocd-manager-role-binding” created
Step 3

Once done confirm the same using the UI

Step 4

Deploy/create any application on different clusters using the cluster option to select the desired cluster

Multi-Cloud Deployments

Deploying Sample Application

After adding different Kubernetes clusters under ArgoCD, we can follow the below-mentioned steps for application deployment per cloud.

Creating Apps via CLI

We will now create a sample guestbook application using Argo CD CLI Change the kubectl config set-context to the k8s cluster on which Argo CD is deployed. Execute the following command to create an application:

argocd app create guestbook —repo https://github.com/argoproj/argocd-example-apps.git —path guestbook —dest-server https://kubernetes.default.svc —dest-namespace default

—repo: Github code repository link —dest-server: Value is always https://kubernetes.default.svc in case the application is to be deployed on the same cluster on which Argo CD is setup —path: Location of the k8s manifest files

Takeaway

Argo CD is designed for continuous deployments in a Kubernetes ecosystem while following the principles of GitOps. The convenience of deploying on multi-cloud/hybrid cloud Kubernetes with minimal challenges makes it a preferred tool.

References

https://argoproj.github.io/argo-cd/