ArgoCD Deep Dives...
ArgoCD is a GitOps tool for Kubernetes that automates application deployment from Git repositories, ensuring they match the declared configuration while providing secure and scalable lifecycle management.
Traditional continuous delivery methods often encounter various challenges.
1. Managing configurations across multiple environments can be complex, cumbersome, and prone to errors.
2. Ensuring consistency between environments like development, staging, and production is challenging.
3. Manual interventions are often needed for deployments, causing inefficiencies and possible errors.
4.Poor visibility into the deployment state and application status complicates quick troubleshooting.
GitOps
GitOps is a method for continuous delivery and operations that uses Git as the single source of truth, offering various benefits.
1. The desired state of the system is described using declarative descriptions.
2. Git's version control features allow every change to be tracked and audited.
3. Tools like ArgoCD automatically sync the desired state in Git with the actual state in the cluster.
4. GitOps enhances collaboration by using Git's pull request workflow for team reviews.
Difference between GitOps and Traditional CD
Traditional CD relies on push-based deployments, while GitOps uses pull-based deployments.
Most CI/CD processes use a push-based approach, where code is moved to its destination when triggered by an event, requiring developers to run commands for deployment and configure Kubernetes clusters with tools like Kubectl and Helm.
Argo is a CD tool that uses a pull-based mechanism, meaning the destination triggers an event to pull data from the source (Git) for deployment, with Argo CD residing inside the cluster to pull the latest verified code version, offering benefits like improved security and ease of use, in a model called GitOps where Git is the single source of truth for application and configuration data.
structure of Argo CD ArgoCD consists of several key components
1. The API Server offers a REST API to manage applications and get the current state.
2. Controller Ensures the Git repository and the cluster state are synchronized by monitoring both.
3. The Repository Server clones the Git repository and supplies the manifests to the controller.
4. Web UI: A web-based interface for managing and viewing application states and deployments.
5. A command-line interface for managing ArgoCD applications and configurations.
Working
Argo CD operates within a Kubernetes cluster by pulling changes from Git and applying them, enhancing security by keeping sensitive information inside the cluster, unlike traditional CI/CD tools that push changes from outside.
Argo CD is set up by deploying the ArgoCD agent to the cluster and configuring it to track a Git repository for changes.
When Argo CD detects changes, it automatically updates the Kubernetes cluster by tracking new code commits in the Git repository, triggering CI pipelines to build container images, updating Kubernetes manifest files, and deploying the new image version to the target cluster.
When the Kubernetes cluster is ready, Argo CD reports the application's status and synchronization completion, while also monitoring and discarding any cluster changes that don't match the Git configuration.
ArgoCD continuously monitors Git repositories for changes, synchronizes the cluster state with the desired state, assesses application health, and can roll back to the last known good state if issues arise.
Constraints
ArgoCD offers many benefits but comes with challenges like complex initial setup, a learning curve for Kubernetes and GitOps, scalability issues with large or complex environments, and difficulties in ensuring proper access control and security policies.
Setting up ArgoCD
Create EKS Cluster From UI
1.To create a role for an EKS Cluster, go to the AWS Management Console, navigate to IAM, click "Roles," select "Create role," choose "AWS Service" as the trusted entity, pick "EKS-cluster" as the use case, click "Next," and provide a name for the role.
2. To create a role for EC2 instances, go to the AWS Management Console, navigate to IAM, click "Roles," then "Create role," select "AWS Service" as the trusted entity, choose "EC2" as the use case, click "Next," add the policies [AmazonEC2ContainerRegistryReadOnly, AmazonEKS_CNI_Policy, AmazonEBSCSIDriverPolicy, AmazonEKSWorkerNodePolicy], and provide a name for the role, such as "myNodeGroupPolicy."
3. To create an EKS Cluster, go to the AWS Management Console, navigate to the Amazon EKS service, click "Create cluster," enter the desired name, select the version, specify the role from step 1, configure the Security Group and Cluster Endpoint, and then click "Next" to proceed with creating the cluster.
4.To create compute resources, go to the AWS Management Console, navigate to the Amazon EKS service, click on "Compute" or "Node groups," provide a name, select the role from step 2, choose the node type and size, and click "Next" to proceed.
To configure Cloud Shell, open AWS Cloud Shell or AWS CLI and run the command
aws eks update-kubeconfig --name shack-eks --region ap-south-1
, replacing "shack-eks" with your EKS cluster name and "ap-south-1" with the correct region, to help set up your EKS cluster with the necessary roles and compute resources.To install ArgoCD and get the admin password, create a namespace with
kubectl create namespace argocd
and apply the ArgoCD manifests usingkubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argocd/v2.4.7/manifests/install.yaml
.Retrieve the admin password by running
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
, which installs ArgoCD in the specified namespace, sets up the service as a Load Balancer, and provides access to the ArgoCD UI.
Configuring ArgoCD and Creating an Application
1.To select a repository, access the ArgoCD UI, go to Settings > Repositories, click on Connect Repo using HTTPS, choose Git as the type, enter the repository URL https://github.com/N4si/tetrisgame.git, and click Connect.
2. In the ArgoCD UI, go to Applications, click on Create Application, fill in the details like Application Name, select default for Project Name, choose Automatic for Sync Policy with Prune resources and Self heal checked, ensure Auto Create Namespace is checked, enter your repository URL for Repo URL, provide the Manifest file name, and for Destination, enter https://kubernetes.default.svc for Cluster URL and the desired namespace for deployment.
3. Click Create to make the application, and ArgoCD will automatically sync the application state with the repository state.
These steps show how to set up ArgoCD, link a repository, and create an application with automatic sync and self-healing features
Thanks for the visiting my page …!
Happy Learning….!