What Is Argo CD?
Argo CD is a declarative, GitOps-based continuous delivery tool for Kubernetes. It leverages Git repositories as a source of truth for Kubernetes resources and applications. With Argo CD, any changes to applications are automatically detected and synced to a specified target environment.
Argo CD follows the Infrastructure as Code (IaC) principle, where the entire state of your system is described declaratively. The actual state of the system is automatically updated to match the described state, allowing for easy and efficient management of system resources. Argo CD’s application definitions, configurations, and environments are declaratively specified, making them easy to customize.
Using Argo CD in DevOps practices enables teams to maintain high velocity, assist in managing complex deployments, and ensure reliability and stability of applications with centralized deployment control and visibility.
What Is AWS EKS?
Amazon Elastic Kubernetes Service (EKS) is a managed container service that makes it easy to deploy, manage, and scale containerized applications using Kubernetes on AWS. EKS manages the Kubernetes control plane for each cluster, which eliminates the need to install and operate your own Kubernetes control plane.
EKS provides a scalable and highly available control plane that runs across multiple AWS availability zones. This eliminates a single point of failure and makes your applications highly available. It also integrates natively with AWS services like Amazon RDS, AWS Identity and Access Management (IAM), and Amazon S3.
Amazon EKS is fully compatible with applications running on any standard Kubernetes environment. This means you can migrate any standard Kubernetes application to EKS without needing to refactor your code. This compatibility makes EKS a suitable choice for teams looking to move their Kubernetes workloads to the cloud.
Options for Installing Argo CD on EKS
Manual Installation
Manually installing Argo CD on AWS EKS involves configuring your EKS cluster, setting up the Argo CD server, and deploying your applications. A manual approach gives you the most control over the installation process and allows you to understand each step in detail.
There are three main steps in manual installation:
- Creating a namespace for Argo CD.
- Installing Argo CD components by applying a manifest provided by the Argo Project in your EKS cluster. You can follow the regular Argo CD installation instructions.
- Installing the Argo CD CLI.
Using Terraform
Terraform is an open-source infrastructure as code software tool that allows you to define and provide data center infrastructure using a declarative configuration language. You can use Terraform to automate the installation of Argo CD on AWS EKS.
Using Terraform to install Argo CD on EKS involves writing a Terraform script that describes the desired state of your EKS cluster and Argo CD installation. Once the script is written, you can use the terraform apply command to create your resources. For more details see this blog post.
Using EKS Blueprint
EKS Blueprint is a framework provided by AWS that helps you set up a secure, multi-account AWS environment based on AWS best practices. With EKS Blueprint, you can automate the setup of Argo CD on EKS, along with other AWS services and resources.
Using EKS Blueprint involves configuring a series of AWS CloudFormation templates that describe your desired AWS environment. Once the templates are configured, you can use the AWS Management Console, AWS CLI, or SDKs to create your resources. Learn more about deploying Argo CD on EKS using a blueprint here.
Quick Tutorial: Deploying Argo CD on AWS EKS
Step 1: Create an AWS CodeCommit Repository
AWS CodeCommit is a fully managed source control service that makes it easy for companies to host secure and highly scalable private Git repositories.
To start off, navigate to the AWS Management Console and open the CodeCommit service. Click on Create repository and fill in the necessary details such as repository name and description. Once you’ve done that, click on Create to finalize your repository.
After the repository is created, you’ll be provided with connection instructions. You can connect to the repository using HTTPS or SSH. For HTTPS connections, AWS provides you with a Git credentials file that you’ll need to download. For SSH connections, you need to upload an SSH public key to IAM, which then returns an SSH key ID that you’ll use when configuring Git to connect to the repository.
Before continuing to the next step, clone the repository to your local workspace. You can do this by running the git clone command followed by the repository URL. You’ll be prompted to enter your AWS credentials. After successful authentication, the repository will be cloned to your local workspace.
Step 2: Install ArgoCD in the Amazon EKS Cluster
Now that you have your CodeCommit repository up and running, it’s time to install Argo CD on your EKS cluster. To begin the installation process, you first need to create a namespace for Argo CD. You can do this by running the following command in your terminal:
kubectl create namespace argocd
Next, you’ll use the official Argo CD installation manifests from the GitHub repository to install Argo CD. Run the following command to do this:
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
Once the installation is complete, you can access the Argo CD API server using the command:
kubectl --namespace argocd port-forward argocd-server 80
If you don’t want to add namespace flag in each command, you can switch namespace to argocd using the following command:
kubectl config set-context --current --namespace=argocd
Now you can run a port forwarding command without a namespace argument.
kubectl port-forward argocd-server 80
Because source and destination ports are the same, we use a short form for port forwarding (with only a single port in the command). Alternatively we can rewrite the command as:
kubectl --namespace argocd port-forward argocd-server 80:80
For a more user-friendly experience, you can expose the Argo CD API server using LoadBalancer, but be aware this incurs extra costs. To do this, run the command:
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'
Deploying an Application
For this tutorial, we’ll be deploying a simple Hello World application.
Start by creating a new folder in our CodeCommit repository to store the Kubernetes manifests for our application. Here is a sample YAML manifest. It needs to be customized as per your requirements:
apiVersion: apps/v1 kind: Deployment metadata: name: first-app-deployment spec: replicas: 1 selector: matchLabels: app: first-app template: metadata: labels: app: first-app spec: containers: - name: firstapp-container image: first-app-image:latest imagePullPolicy: Always ports: - containerPort: 5312
Once your manifests are ready, commit and push them to your CodeCommit repository. Then, create an application in Argo CD that points to the folder in the CodeCommit repository where your manifests are located.
To create the application, run the following command:
argocd app create <app-name> --repo <repo-url> --path <path-to-manifests> --dest-namespace <namespace> --dest-server https://kubernetes.default.svc
After running this command, Argo CD will continuously monitor the specified path in the CodeCommit repository and automatically deploy any changes to the EKS cluster.
Updating an Application
To update an application, you just need to update the Kubernetes manifests in your CodeCommit repository. Once you’ve made your changes, commit and push them to the repository. Argo CD will detect the changes and automatically deploy them to the EKS cluster.
Finally, don’t forget to clean up the cluster if you don’t need it anymore. Delete the cluster using the tool or method you used to create it.
Learn More in the Manning Report: GitOps with ArgoCD
Software teams that adopt GitOps deploy more often, have fewer regressions and recover from failures more quickly. GitOps works, as evidenced by many success stories we at Codefresh have seen first hand. Learn more about GitOps in an in-depth guide by Alexander Matyushentsev, one of the founders of the Argo project. Argo is the world’s fastest growing and most popular open-source GitOps tool in the world today. Usres love it, and that is the reason Codefresh has based its enterprise platform on the beloved tool.
Learn to practice GitOps with ArgoCD in the Manning Report: GitOps with ArgoCD
Deploy more and fail less with Codefresh and Argo