In this blog, we will be able to deploy ArgoCd in an EKS cluster and use it for Continuous Deployment process
Prerequisites
Have an EKS cluster running
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
Install ArgoCD in K8s cluster
Configure ArgoCD with “Applicatin” CRD
Install the ArgoCD CLI.
Test our setup by updating Deployment.yaml files
Let's get started by first installing ArgoCd
First, create a namespace
kubectl create namespace argocd
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
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
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
Then you can decode the password
echo R215N3hvZ21LSEEwRGlIag== | base64 --decode
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:
Open the EKS console.
Select your cluster.
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
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
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).
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
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
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)