The Talent500 Blog
ArgoCD: A GitOps CD. 1

ArgoCD: A GitOps CD.

Introduction

Argo CD is a free and open-source program that aids in automating the software release process via continuous delivery and deployment. Argo CD automatically installs any updates needed to conform the system to its ideal condition. To deploy applications in a declarative manner, it uses YAML files to store information about the intended environment and the current state of the application. 

This blog will closely examine Argo CD, discussing its functionality, features, and benefits.

What is Argo CD?

Argo CD is a declarative continuous delivery tool that automates the deployment of applications to a Kubernetes cluster. It uses GitOps to keep the desired state of the application in a Git repository and automatically updates the application when changes are made. Argo CD is built on top of Kubernetes and works natively with Kubernetes objects, allowing it to deploy applications with complex dependencies and rolling updates.

Argo CD provides a web UI and a CLI for managing the deployment of applications. The web UI allows users to monitor the status of deployments, view the history of deployments, and roll back to a previous version of an application. The CLI provides advanced functionality for automating the deployment process, including the ability to automate the creation of applications, promote applications between environments, and roll back to a previous version of an application.

Why use Argo CD?

Argo CD provides several benefits to organizations looking to manage the deployment of applications on Kubernetes:

Declarative Configuration

Argo CD uses a declarative approach to application configuration, which means that the desired state of the application is defined in a configuration file. This configuration file is stored in a Git repository and used by Argo CD to deploy and manage the application. This approach ensures that the deployment process is consistent and repeatable, making it easier to address complex application deployments.

GitOps Approach

Argo CD uses a GitOps approach to application deployment, which means that the desired state of the application is stored in a Git repository. Any changes to the application are made in the Git repository, and Argo CD automatically updates the application based on the changes. This approach provides a simple and scalable way to manage the application delivery process, making it easier to manage and deploy applications across multiple environments.

Scalability

Argo CD is designed to be highly scalable, making it ideal for organizations that need to manage large and complex application deployments. It uses Kubernetes as its underlying infrastructure, allowing it to scale horizontally and vertically to meet the organization’s needs. This scalability ensures that the deployment process remains fast and reliable, even as the number of applications and the complexity of the deployment process grows.

ArgoCD Installation 

Installing Argo CD involves setting up its server component and its CLI. The server component is responsible for managing the state of the applications and their respective configuration, and the CLI is used for interacting with the server.

The following steps can be used to install Argo CD:

Prerequisites:

  • Kubernetes cluster (version 1.11 or later)
  • kubectl
  • helm (version 3 or later)

Add the Argo CD repository to Helm:

helm repo add argo https://argoproj.github.io/argo-helm

helm repo update

 

Install Argo CD using the Helm chart:

helm install argocd argo/argo-cd –version 3.18.2 \

–namespace argued \

–create-namespace \

–set server.extraArgs={–insecure} \

–set controller. image.tag=v2.14.0 \

–set dex. image.tag=v2.29.0

 

This command installs Argo CD in a new namespace called argocd. It also sets some extra arguments for the server component and the image tags for the controller and dex components.

Once the installation is complete, you can access the Argo CD web UI by port-forwarding the service:

kubectl port-forward svc/argocd-server -n argocd 8080:443

This command forwards the service port to port 8080 on your local machine. You can then access the Argo CD web UI by navigating to https://localhost:8080 in your web browser.

Finally, you can log in to the Argo CD web UI using the default username and password. The username is admin, and the password is the name of the server pod:

kubectl get pods -n argocd -l app.kubernetes.io/name=argocd-server -o name | cut -d’/’ -f 2

 

This command gets the name of the server pod, which is used as the password for the initial login. Once logged in, you can configure Argo CD to deploy your applications.

ArgoCD: A GitOps CD. 2

How to use Argo CD?

To use Argo CD, you must set up a Kubernetes cluster and install the Argo CD operator, which we covered in the section above. Once installed, you can use the Argo CD web UI or CLI to create and manage applications. Here are the high-level steps to get started:

  1. Install the Argo CD operator on your Kubernetes cluster.
  2. Create a Git repository to store the application configuration.
  3. Create an Argo CD application, specifying the Git repository and the configuration file.
  4. Argo CD will automatically deploy the application based on the configuration file in the Git repository.
  5. Use the Argo CD web UI or CLI to monitor the status of deployments, view deployment history, and roll back to a previous version of an application.

The specific steps for using Argo CD will depend on the needs of your organization and the complexity of your application deployment process.

ArgoCD Concepts and Terminologies

Argo CD has several essential concepts and terminology crucial to understanding how it works. Some of the key ones are:

Application: An Argo CD application is a declarative definition of a set of Kubernetes resources, along with the desired state of those resources. An application can be considered a set of configurations, policies, and rules that dictate how particular Kubernetes resources should be managed.

Project: A project is a logical grouping of Argo CD applications. Projects provide a way to organize and manage many applications and enable defining policies and access controls at the project level.

Sync: A sync is a process by which Argo CD ensures that the state of the Kubernetes resources matches the desired shape defined in the application. Syncs can be triggered manually or configured to run automatically on a schedule or in response to a webhook.

Rollout: A rollout is a process of deploying a new version of an application to a cluster. Argo CD supports several different rollouts, including blue-green, canary, and automated rollouts.

Sync Status: The sync status provides information about the current state of a sync, including the status of individual Kubernetes resources and any errors or warnings that have occurred.

Health Status: The health status provides information about the overall health of an application, including any issues impacting its availability or performance.

Application Set: An application set is a way to create multiple similar applications from a single configuration file. This can be useful for managing many similar applications that share standard configurations.

GitOps: GitOps is a methodology for managing Kubernetes applications using Git as the source of truth. Argo CD is a GitOps tool that automatically syncs the Kubernetes resources state with the state defined in Git.


ArgoCD Architecture 

ArgoCD: A GitOps CD. 3

Argo CD Server: This core component manages the application’s state and synchronizes it with the desired state defined in a Git repository. It continuously monitors the Git repository and applies changes to the Kubernetes cluster.

Argo CD API Server: This provides a RESTful API to interact with the Argo CD Server. Clients use this API to access the application and project resources.

Argo CD UI: This is the web-based user interface for Argo CD. It allows users to manage the application and project resources, monitor their status, and troubleshoot issues.

Argo CD CLI: This is the command-line interface for Argo CD. It provides a way to interact with the Argo CD Server using the command line.

Repository: This is the Git repository that stores the application manifests, along with the Argo CD configuration files. The repository must be accessible by the Argo CD Server and contain the application source code and manifest files.

Kubernetes Cluster: This is the target environment where the application is deployed. The Argo CD Server deploys the application to the Kubernetes cluster by communicating with the Kubernetes API server.

Argo CD Controller: This component runs within the Kubernetes cluster and is responsible for reconciling the desired state of the application with the actual state. It continuously monitors the Kubernetes API server for changes and updates the Argo CD Server accordingly.

Argo CD Webhook: This Kubernetes Admission Controller validates and approves deployment manifests before they are applied to the cluster. It helps to prevent unauthorized changes to the cluster.

The Argo CD architecture provides a simple and intuitive way to manage Kubernetes applications using GitOps principles. Its modular design allows easy integration with other tools and systems, making it a flexible and extensible solution for continuous delivery in Kubernetes environments.

Create your first ArgoCD Project.

To create an ArgoCD project, follow these steps:

Log in to the ArgoCD web UI.

Click on the “New App” button in the upper right corner.

In the “Create New Application” dialog box, enter the following information:

ArgoCD: A GitOps CD. 4

Application Name: A unique name for the application you are creating.

Project: The project in which you want to create this application. If you haven’t created a project yet, click the “New Project” button to create a new one.

ArgoCD: A GitOps CD. 5

ArgoCD: A GitOps CD. 6

Repository URL: The URL of the Git repository where the application’s code is stored.

Path: The path within the Git repository where the application’s configuration files are located.

Cluster: The Kubernetes cluster where you want to deploy the application.

Click the “Create” button to create the application. ArgoCD will automatically start deploying the application to the specified Kubernetes cluster.

Note that ArgoCD uses GitOps to manage your applications. Any changes to your application’s configuration files should be made in your Git repository, and ArgoCD will automatically deploy those changes to your Kubernetes cluster.

ArgoCD Sync and App of Apps

Argo CD provides various synchronization strategies to ensure the desired state of your application matches the actual state. These sync strategies include:

Automatic Sync: In this strategy, Argo CD continuously monitors the state of your application, and any changes detected are automatically synchronized.

Manual Sync: In this strategy, you need to manually initiate our application’s synchronization.

Hook Sync: In this strategy, Argo CD initiates the synchronization of your application after executing custom scripts or hooks.

Prune Sync: In this strategy, any resources that exist in the actual state but not in the desired state are deleted during synchronization.

Sync Wave: In this strategy, the synchronization of your application is performed in waves, with each wave including a set of resources that depend on one another.

Sync Options: In this strategy, Argo CD allows you to specify various options, such as the timeout duration, for synchronization.

Argo CD also provides an App of Apps feature, which allows you to define and manage a group of applications as a single entity. This feature is useful for managing complex deployments with multiple applications.

In the App of Apps model, you define a parent application that acts as a controller for one or more child applications. The parent application includes a list of all the child applications it controls, and it can be used to deploy or update all the child applications simultaneously. This makes it easier to manage and track changes across multiple applications.

In summary, Argo CD provides a flexible set of synchronization strategies to help you ensure that your application is always in the desired state. The App of Apps feature further enhances the management of complex deployments by allowing you to group multiple applications into one entity.

ArgoCD Multi Cluster Deployment

Argo CD supports multi-cluster deployment, which is particularly useful when you deploy the same application across multiple clusters. It allows you to manage and deploy applications across various Kubernetes clusters as if they were a single cluster.

To deploy an application across multiple clusters using Argo CD, you will need to set up a Git repository that contains the Kubernetes manifests for the application and then configure Argo CD to deploy the application to the desired clusters. Here are the high-level steps to deploy an application across multiple clusters using Argo CD:

Configure Argo CD: Next, you will need to configure Argo CD to deploy the application across multiple clusters. You can do this by defining an application in Argo CD and specifying the source repository and target clusters for the application.

Define the target clusters: You will need to define the target clusters for your application in Argo CD. This involves creating a Kubernetes custom resource called a Cluster in the Argo CD namespace for each target cluster. The Cluster resource specifies the cluster name, the Kubernetes API server endpoint, and the credentials to authenticate with the cluster.

ArgoCD: A GitOps CD. 7

ArgoCD: A GitOps CD. 8

Define the application: Once you have set up the source repository and defined the target clusters, you can determine the application in Argo CD. This involves creating a Kubernetes custom resource called an Application in the Argo CD namespace. The Application resource specifies the source repository and path to the Kubernetes manifests for the application and the target clusters where the application should be deployed.

Deploy the application: Finally, you can deploy the application by syncing the Application resource in Argo CD. Argo CD will retrieve the manifests from the source repository, package them as a Helm chart or Kustomize overlay, and deploy the application to the specified target clusters. You can monitor the deployment status using the Argo CD web UI or the ArgoCd CLI.

Argo CD also supports deploying applications to multiple clusters using the App of Apps pattern. This involves creating a separate Application resource for each cluster, and then creating a top-level Application resource that refers to the cluster-specific Application resources as dependencies. This approach allows you to manage the configuration of multiple applications across multiple clusters from a single App of Apps resource.

Conclusion 

Argo CD is a powerful and flexible tool for managing applications’ deployment and continuous delivery in Kubernetes clusters. With its user-friendly interface, advanced synchronization features, and support for multi-cluster deployments, Argo CD can help teams streamline their workflows and increase productivity. Its extensive documentation and active community make it easy to get started with and learn. At the same time, its rich feature set and customizable settings allow for fine-tuning and scaling as needed.

Argo CD can help you automate and optimize your application deployment and delivery processes, whether you manage a single-cluster deployment or a complex multi-cluster environment. By simplifying the management and synchronization of your deployments, Argo CD can help your team focus on delivering high-quality applications with ease and confidence. With its powerful features and intuitive user interface, Argo CD is a must-have tool for any Kubernetes administrator or developer looking to streamline workflows and improve productivity.

 

0
Shubham Singh

Shubham Singh

He is a SDE-2 DevOps Engineer, with demonstrated history in working with scaling startup. A problem solver by mettle, who loves watching anime when he is not working. He is a learner and educator by heart.

Add comment