This article explains how to manage multi-cluster deployments using ArgoCD, including configuring external Kubernetes clusters and deploying applications across them.
ArgoCD simplifies managing multi-cluster deployments by allowing you to deploy applications either within its own cluster or across external clusters. In this guide, we’ll walk you through configuring an external Kubernetes cluster and deploying applications across clusters using ArgoCD.
Before deploying applications to multiple clusters, you need to have an external Kubernetes cluster. ArgoCD integrates external clusters by reading their credential details from the kubeconfig file. This allows ArgoCD to manage deployments outside its own cluster.
After defining the external cluster in your kubeconfig, add it to ArgoCD by referencing the appropriate context name:
Copy
Ask AI
$ argocd cluster add <context-name>
This command creates a service account on the external cluster with full cluster-level administrator access. Ensure you understand the security implications before proceeding.
Once you confirm, ArgoCD automatically creates the necessary service account, cluster role, and cluster role binding, thus validating the external cluster as a deployment target.
Below is a comprehensive example that illustrates all the essential steps to add an external cluster:
Copy
Ask AI
$ kubectl config set-cluster prod --server=https://1.2.3.4 --certificate-authority=prod.crtCluster "prod" set.$ kubectl config set-credentials admin --client-certificate=admin.crt --client-key=admin.keyUser "admin" set.$ kubectl config set-context admin-prod --cluster=prod --user=admin --namespace=prod-appContext "admin-prod" set.$ argocd cluster add admin-prodWARNING: This will create a service account `argocd-manager` on the cluster referenced by context `admin-prod` with full cluster level admin privileges. Do you want to continue [y/N]? yINFO[0011] ServiceAccount "argocd-manager" created in namespace "kube-system"INFO[0011] ClusterRole "argocd-manager-role" createdINFO[0011] ClusterRoleBinding "argocd-manager-role-binding" createdCluster 'https://1.2.3.4' added$ argocd cluster listSERVER NAME VERSION STATUS MESSAGE PROJECThttps://1.2.3.4 admin-prod 1.21 Successful <none>https://kubernetes.default.svc in-cluster 1.20 Successful <none>
You can verify the list of clusters available for deployment by executing the argocd cluster list command. Note that credentials for external clusters (or API servers) are securely stored as secrets within the ArgoCD namespace.For further information on configuring multi-cluster deployments and additional ArgoCD commands, please refer to the ArgoCD Documentation.Happy deploying!