Argo CD is an open-source, declarative GitOps continuous delivery tool for Kubernetes. It automates the deployment and management of applications in Kubernetes clusters by using Git repositories as the single source of truth for defining and managing application configurations. Argo CD adheres to GitOps principles, emphasizing collaboration, auditability, and reproducibility.
Key Features of Argo CD
Declarative Configuration: Applications are defined using YAML manifests that describe their desired state and dependencies (e.g., deployments, services, ingress rules).
Continuous Delivery: Monitors Git repositories for changes and automatically reconciles them with the Kubernetes cluster.
Automated Synchronization: Keeps the cluster’s state aligned with the desired state defined in Git, automating deployments, updates, and deletions.
Rollback and Auditing: Supports automated rollbacks in case of failures and provides detailed audit logs and history tracking.
Multi-Environment Support: Facilitates configuration management across development, staging, and production environments, ensuring consistency.
User Interface and CLI: Offers a web-based UI and CLI for managing applications, deployments, and administrative tasks.
Example Usage of Argo CD
Consider a scenario where a team wants to deploy a microservices-based application to a Kubernetes cluster:
Application Configuration: Define configurations declaratively using YAML manifests for microservices, database connections, ingress rules, etc.
Git Repository Setup: Store configurations in a Git repository as the source of truth.
Argo CD Configuration: Configure Argo CD to monitor the Git repository for changes.
Continuous Deployment: Changes in the Git repository trigger automatic deployments or updates in the Kubernetes cluster.
Rollback and Auditing: Automatically rollback to previous states in case of failures, with access to deployment history for troubleshooting.
Monitoring: Use the Argo CD UI for deployment status, synchronization logs, and administrative tasks.
Problem Statement
Modern software development faces challenges in deploying applications to Kubernetes clusters and managing configurations across environments:
Manual Deployment: Error-prone and time-consuming.
Lack of Version Control: Difficult to track changes, leading to inconsistencies.
Environment Management Complexity: Coordinating configurations across environments can cause discrepancies.
Limited Rollback Capabilities: Challenging to revert to previous states without automation.
Solution: Argo CD
Argo CD resolves these challenges with its GitOps-based approach:
Declarative Configuration: Define application configurations in YAML.
Git Repository as Source of Truth: Enable version control and collaboration.
Continuous Deployment: Automatically synchronize Kubernetes clusters with Git repositories.
Automated Rollbacks: Ensure reliable deployments.
Multi-Environment Support: Maintain consistency across development, staging, and production.
Argo CD Workflow
Define Application Configuration: Use YAML manifests for Kubernetes resources.
Store Configuration in Git: Version and audit changes in Git repositories.
Continuous Monitoring: Detect and sync changes automatically.
Sync with Kubernetes Cluster: Align actual cluster state with desired state.
Deployment and Rollback: Automate deployments and rollbacks.
User Interface: Manage and monitor deployments via the Argo CD UI.
Hands-On: Setting Up Argo CD
Create EKS Cluster From UI
1. Create Role for EKS Cluster:
o Go to AWS Management Console.
o Navigate to IAM (Identity and Access Management).
o Click on "Roles" and then click on "Create role".
o Choose "AWS Service" as the trusted entity.
o Choose "EKS-cluster" as the use case.
o Click "Next" and provide a name for the role.
2. Create Role for EC2 Instances:
o Go to AWS Management Console.
o Navigate to IAM (Identity and Access Management).
o Click on "Roles" and then click on "Create role".
o Choose "AWS Service" as the trusted entity.
o Choose "EC2" as the use case.
o Click "Next".
o Add policies: [AmazonEC2ContainerRegistryReadOnly, AmazonEKS_CNI_Policy, AmazonEBSCSIDriverPolicy, AmazonEKSWorkerNodePolicy].
o Provide a name for the role, e.g., "myNodeGroupPolicy".
3. Create EKS Cluster:
o Go to AWS Management Console.
o Navigate to Amazon EKS service.
o Click on "Create cluster".
o Enter the desired name, select version, and specify the role created in step 1.
o Configure Security Group, Cluster Endpoint, etc.
o Click "Next" and proceed to create the cluster.(it will take around 10-15 mins)
4. Create Compute Resources:
o Go to AWS Management Console.
o Navigate to Amazon EKS service.
o Click on "Compute" or "Node groups".
o Provide a name for the compute resource.
o Select the role created in step 2.
o Select Node Type & Size.
o Click "Next" and proceed to create the compute resource.
Configure Cloud Shell:
o Open AWS Cloud Shell or AWS CLI.
o Execute the command:
o aws eks update-kubeconfig --name reddit-cluster --region ap-south-1
o Replace "reddit-cluster" with the name of your EKS cluster and "ap-south- 1" with the appropriate region if different.
These steps should help you in setting up your EKS cluster along with necessary roles and compute resources.
Install ArgoCD
Here are the steps to install ArgoCD and retrieve the admin password:
1. Create Namespace for ArgoCD:
kubectl create namespace argocd
2. Apply ArgoCD Manifests:
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo- cd/v2.4.7/manifests/install.yaml
3. Patch Service Type to LoadBalancer:
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'
Copy DNS link of loadbalancer and paste it into browser
Default username is admin
4. Retrieve Admin Password:
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
These commands will install ArgoCD into the specified namespace, set up the service as a LoadBalancer, and retrieve the admin password for you to access the ArgoCD UI.
reset new password
go to settings and set repository url
select connect repo using http
if your repo is public you don’t need to provide credentials
click on connect
create application
it will sync automatically
click on reddit service copy dns and paste into browser
Argo CD streamlines the deployment and management of applications in Kubernetes, adhering to GitOps principles. Its powerful features and automation capabilities make it an invaluable tool for modern DevOps workflows.