DEV Community

Cover image for How to Deploy ArgoCD in EKS cluster For Continuous Deployment
Ian Kiprotich
Ian Kiprotich

Posted on

How to Deploy ArgoCD in EKS cluster For Continuous Deployment

In this blog, we will be able to deploy ArgoCd in an EKS cluster and use it for Continuous Deployment process

Prerequisites

  1. Have an EKS cluster running

  2. Have your yaml configuration microservices in a git repository

What is ArgoCD?

Argo CD is a declarative continuous delivery tool for Kubernetes applications. It helps automate the deployment of applications to Kubernetes clusters by providing a GitOps approach to managing and deploying applications.

With Argo CD, you can define the desired state of your application in a Git repository and have it automatically synced with your Kubernetes cluster. This allows you to easily manage your application deployments across multiple environments, such as development, staging, and production.

Argo CD provides a web-based user interface as well as a command-line interface for managing your application deployments. It also integrates with other tools in the Kubernetes ecosystem, such as Helm charts, Kustomize, and Jsonnet.

Overall, Argo CD helps simplify the deployment process for Kubernetes applications and provides a reliable, scalable, and secure way to manage your deployments.

Demo overview steps

  1. Install ArgoCD in K8s cluster

  2. Configure ArgoCD with “Applicatin” CRD

  3. Install the ArgoCD CLI.

  4. Test our setup by updating Deployment.yaml files

Let's get started by first installing ArgoCd

First, create a namespace

kubectl create namespace argocd
Enter fullscreen mode Exit fullscreen mode

Next, let's apply the yaml configuration files for ArgoCd

kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
Enter fullscreen mode Exit fullscreen mode

Now we can view the pods created in the ArgoCD namespace.

Next we can acess the ArgoCD ui from the services deployed

kubectl port-forward svc/argocd-server 8080:443 -n argocd
Enter fullscreen mode Exit fullscreen mode

Argocd Dashboard

The username is admin

The password is autogenerated and stored in the secret called argocd-initial-admin-secret in the argocd installation namespace.

kubectl get secret argocd-initial-admin-secret -n argo
cd -o yaml
Enter fullscreen mode Exit fullscreen mode

Then you can decode the password

echo R215N3hvZ21LSEEwRGlIag== | base64 --decode
Enter fullscreen mode Exit fullscreen mode

The ArgoCD is empty because we have to configure it thats gonna be the next step.

Let's write a configuration file for ArgoCD to connect it to the git repository where the configuration files are hosted

since we have to connect ArgoCD with our cluster we have to get the endpoint for our cluster

aws eks describe-cluster --name <cluster-name> --query "cluster.endpoint"
Enter fullscreen mode Exit fullscreen mode

You can also view the endpoint using the following steps

To find the endpoint using the AWS Management Console:

  1. Open the EKS console.

  2. Select your cluster.

  3. Under the “Configuration” tab, you should see the “Kubernetes endpoint” listed.

Next, we have to configure the CLI to our ArgoCD instance. the easiest way is to use the homebrew command

brew install argocd
Enter fullscreen mode Exit fullscreen mode

After you install you can log in to the CLI using the command

argocd login 127.0.0.1:443
Enter fullscreen mode Exit fullscreen mode

Fill in the Username and Password

Register your Cluster to deploy your application

This step registers a cluster’s credentials to Argo CD, and is only necessary when deploying to an external cluster. When deploying internally (to the same cluster that Argo CD is running in), https://kubernetes.default.svc should be used as the application’s K8s API server address.

First list all clusters contexts in your current kubeconfig:

kubectl config get-contexts -o name
Enter fullscreen mode Exit fullscreen mode

Add your cluster

argocd cluster add arn:aws:eks:us-east-2:758659350150:cluster/Giovanni
Enter fullscreen mode Exit fullscreen mode

The above command installs a ServiceAccount (argocd-manager), into the kube-system namespace of that kubectl context, and binds the service account to an admin-level ClusterRole. Argo CD uses this service account token to perform its management tasks (i.e. deploy/monitoring).

Next, we will configure the git repository https://gitlab.com/onai254/giovanni.git to deploy the application but before that, we need to set the current namespace to ArgoCD by running the following command:

kubectl config set-context --current --namespace=argocd
Enter fullscreen mode Exit fullscreen mode

Next, we will create the application using the following command

argocd app create myapp --repo https://github.com/argoproj/argocd-example-apps.git --path . --revision master --dest-server https://11E5FA4C5A83DEA0033E57F09D23DFC5.gr7.us-east-2.eks.amazonaws.com --dest-namespace default
Enter fullscreen mode Exit fullscreen mode

With this, our application is deployed automatically by ArgoCD and also it watches the repository for any changes.

You can also view more functionality of ArgoCD and view the different parts of the application.

Top comments (0)