Deploy Apps Across Clusters Using Argo CD

TL;DR: Enabling GitOps is easy on Devtron. Select ArgoCD to begin to sync with your Git repository and deploy code across clusters. Devtron provides additional control and visibility for your GitOps

2 years ago   •   5 min read

By Prakarsh

Introduction

GitOps is becoming popular for Kubernetes app deployment, and the GitOps tool for Argo CD is getting widely adopted. The most important reason for the paradigm shift is that many advanced and fast-growing enterprises use Kubernetes. They want to win the market by releasing features faster (using GitOps methodology) with no roadblocks. And Argo CD helps them achieve that. The developers often must deploy their code into multiple Kubernetes clusters in the same or different data centers. The question developers, DevOps, and platform engineers ask is, can Argo CD help in multicluster deployments?

In this article, we will see how Argo CD can be used to deploy code into multiple clusters.

Prerequisite

We have used the open-source Devtron platform to use the enterprise version on Argo CD. We have used Devtron v0.6.14. Please install the Devtron platform into your Kubernetes cluster. Review the installation guide to set up Devtron with CI/CD and GitOps Argo CD.

Please note: Devtron provides a modified way of GitOps while using Argo CD under the hood to make the implementation less resource-exhaustive.

Steps to deploy apps into multicluster using Argo CD

  1. Enable Argo CD from the Devtron stack manager
  2. Configure Git repository in Devtron
  3. Create a new application
  4. Create GitOps pipeline for deployment
  5. Execute the GitOps pipeline and deploy using Argo CD
  6. Monitor application health and deployment status
  7. Enable auto-sync in Argo CD (optional)

Step-1: Enable Argo CD from the Devtron stack manager

Once you open the Devton application, go to the stack manager menu -> Integration -> Discover.

You can install GitOps Argo CD from the stack. You can also choose to install other famous open-source software in the CNCF landscape, such as Clair, Grafana, Prometheus, etc.

Step-2: Configure Git to allow infrastructure configuration for deployment

Provide the essential information to allow Devtron to fetch the configurations from your Git repository. As of today, Devtron supports major Git providers such as GitHub, GitLab, Azure, and Bitbucket. We recommend creating a separate GitHub repository for GitOps and avoiding using the GitHub organization for source code.

Step-3: Create a new application for GitOps deployment

You can create a new application in the Devtron app by providing details such as app name, project name, owner name, etc. In this case, I have created gitops-demo app.

Step-4: Create a GitOps pipeline for deploying applications into multiple clusters

Assuming the environment of your applications, dev/qa/pre-prod and prod, are in different clusters, you have to create a pipeline based on that. In this case, we have created a single pipeline to deploy applications into multiple clusters of non-production environments.

Step 4.1: Create a pipeline with the build and deploy stage

You can go to app configuration -> workflow editor of Devtron application to create the GitOps pipeline. Whenever you create a new pipeline for an application, an Argo CD object will be created in the background.

In the dev pipeline below, we have created a few stages: Build (to generate the image for the applications) and Deploy ( to deploy into one of the Kubernetes clusters. You can also select the cluster configurations by selecting the environment, namespace, and deployment strategy from the UI itself. We have selected 'Automatic' deployment to let Argo CD know if there is a new image, then consider it for deployment.

Step-5: Execute the GitOps pipeline

Once you execute the GitOps pipeline, the build stage will be completed, and a new container image will be created. Once a new image is created, the deployment stage of the GitOps pipeline will be triggered. Devtron deployment pipeline will change the Kubernetes manifest files with the latest deployment. If you are using HELM-based deployment, then Devtron will update the values.yaml file with the recently created image. And after that, it will deploy your application into the cluster.
Note: Devtron also allows selecting an image for deployment in the run-time instead of running the entire GitOps pipeline. In the below image, the playground-dev stage is executed by selecting an image from the options available to Devtron.

Step-5.1: Monitor the deployment status of the application in the real-time

You can find out what's happening during the deployment process in real time. Once you click on the details on the deployment stage, you will be directed to the application dashboard (refer to the below image).

The above image of the Devtron dashboard showcases the application's health and deployment status. The application health will provide the CPU and memory usage of the application along with other details such as the health of the pods, underlying K8s resources, pods, etc. The deployment status in the dashboard would provide information about the sub-process executed during the application deployment and whether the process is stuck somewhere. Below is the screenshot of the deployment status of the application.

In the above image, there are three crucial sub-process executed by Devtron in the deployment phase:

  1. The manifest files or the HELM values got updated and pushed to Git automatically
  2. Then using Argo CD, Devtron applied the manifest to the cluster
  3. And finally, the K8s resources, such as pods, are created in the cluster.

Step-6: Enable auto-sync in Argo CD (Optional)

We have discussed how enabling full GitOps can be resource exhaustive, where the reconciliation happens in the right of the SDLC process, i.e., constantly checking for drift in the cluster and automatically healing by looking into the declared in the Git. We recommend not enabling auto-sync for non-production environments to save on cloud bills. You can go to the Application resource (an Argo CD custom resource) for the production environment and change the selfHeal parameter to true. You can refer to an Application kind in Git.

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: go-app-argo-config
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://github.com/Abhinav-26/ArgoCD-Config-Test.git
    targetRevision: HEAD
    path: yamls
  destination:
    server: https://kubernetes.default.svc
    namespace: argocd-test
  syncPolicy:
    syncOptions:
    - CreateNamespace=true
    automated:
      selfHeal: true
      prune: true
visibility-guide

Conclusion

Many companies want a single tool to deploy the code into multiple clusters across environments seamlessly. Argo CD fits the bill and is suitable for small to large enterprise software development teams. For large enterprises, platform engineers can consider Devtron to enable Argo CD for their developers to deploy their changes. In smaller teams, developers can activate Argo CD in seconds.
If you want to use Argo CD with enterprise features and for free, try (open-source) Devtron. Contact us if you plan to implement an enterprise-grade software delivery workflow for your Kubernetes ecosystem.

Spread the word

Keep reading