How to Deploy ArgoCD in EKS cluster For Continuous Deployment
Tags: kubernetes, aws, microservices, devops
Published: 2023-03-13 20:32:57

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?

![](https://cdn-images-1.medium.com/max/2000/1*Xj91hAG4RlI_w1HhBIPcAw.png)

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

![](https://cdn-images-1.medium.com/max/2000/1*Rub7ZU_wp5S9mGowvrd25g.png)

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

![](https://cdn-images-1.medium.com/max/2000/1*VgxppR96RFaMcTY_ljoFMw.png)

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

![](https://cdn-images-1.medium.com/max/2000/1*WSKtUR5ey_-iL43IZdtOAg.png)

Next we can acess the ArgoCD ui from the services deployed

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

![Argocd Dashboard](https://cdn-images-1.medium.com/max/2748/1*1smNocskR-AQIGCUEAIAlA.png)

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

![](https://cdn-images-1.medium.com/max/2000/1*bRIk2rE82QKDicPIfrxwiQ.png)

Then you can decode the password

    echo R215N3hvZ21LSEEwRGlIag== | base64 --decode

![](https://cdn-images-1.medium.com/max/2000/1*bhadmXd9E3Bp3PD3cCewvQ.png)

![](https://cdn-images-1.medium.com/max/2724/1*u631A_l4f4aPo-qooOFzYw.png)

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"

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

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

    argocd login 127.0.0.1:443

Fill in the Username and Password

![](https://cdn-images-1.medium.com/max/2000/1*KbkiLnY72h2KiF-D6pbHFA.png)

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](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

![](https://cdn-images-1.medium.com/max/2000/1*J6FD2g2SXerO48NV8C6OMQ.png)

Add your cluster

    argocd cluster add arn:aws:eks:us-east-2:758659350150:cluster/Giovanni

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).

![](https://cdn-images-1.medium.com/max/2000/1*zEFDmogRL72gsRH25EHyYg.png)

Next, we will configure the git repository [https://gitlab.com/onai254/giovanni.git](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

![](https://cdn-images-1.medium.com/max/2000/1*jj5Fj-yAnBf2Vrnr4ZhkKw.png)

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

![](https://cdn-images-1.medium.com/max/2000/1*O7E0YPyREEaA4_MYvoL2YQ.png)

![](https://cdn-images-1.medium.com/max/2722/1*A1doQiNAz5clhrLH2D_ruw.png)

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.