
Setting Up ArgoCD with AWS EKS for GitOps Implementation
5 September, 2023
0
0
0
Contributors
👋 Introduction:
Enter ArgoCD, the solution to seamless Kubernetes deployment. With GitOps-style continuous deployment at its core, ArgoCD ensures your app in the cluster matches its Git repository definition. This blog explores how to install ArgoCD streamlines deployment, automates sync
🚀 Prerequisites:
- ☁️ Kubernetes Cluster
- 👨🏻💻 Git Repository
- 🧐 Basic familiarity with Kubernetes and Github concept
📚 Step-by-step guide:
✒ Install Argo CD:
Before we install it , we should know that ArgoCD is composed of three mains components:
API Server: Exposes the API for the WebUI / CLI / CICD Systems
Repository Server: Internal service which maintains a local cache of the git repository holding the application manifests
Application Controller: Kubernetes controller which controls and monitors applications continuously and compares that current live state with desired target state (specified in the repository). If a OutOfSync
is detected, it will take corrective actions.
Now let us install it on our EKS cluster
All those components could be installed using a manifest provided by the Argo Project . Run below commands to create a namespace and apply deploy the install file , change the version if you want :
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/v2.4.7/manifests/install.yaml
To interact with the API Server
we need to deploy the argocd CLI , change the version if you want:
sudo curl --silent --location -o /usr/local/bin/argocd https://github.com/argoproj/argo-cd/releases/download/v2.4.7/argocd-linux-amd64
sudo chmod +x /usr/local/bin/argocd
✒ Expose argocd-server
By default argocd-server is not publicaly exposed. For the purpose of this workshop, we will use a Load Balancer to make it usable:
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'
Wait about 2 minutes for the LoadBalancer creation
Run the following command to view the LoadBalancer endpoint URL
kubectl get svc -n argocdubectl get svc -n argocd
Export ARGOCD_SERVER
export ARGOCD_SERVER=`kubectl get svc argocd-server -n argocd -o json | jq --raw-output '.status.loadBalancer.ingress[0].hostname'`
✒ Login to argocd
The initial password is autogenerated with the pod name of the ArgoCD API server:
Be sure to export this password as well
export ARGO_PWD=`kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d`
Run the following login command:
✒ Create the sync file
In order for ArgoCD to track changes in our application repository, we need to create a sync file that deploys our app and synchronizes it with the target repository. Here is what the sync file looks like for our web-app
:
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: web-app
namespace: argocd
spec:
destination:
namespace: default
server: https://kubernetes.default.svc
project: default
source:
repoURL: https://github.com/Hayder-alobaidi/P1-kubernetes_manifest.git
path: mainfest
targetRevision: HEAD
syncPolicy:
automated:
prune: true
selfHeal: true
allowEmpty: false
To apply this sync file and have ArgoCD manage our web-app
, use the following command:
kubectl apply -f web-app-sync.yaml
✒ Verify the Deployment of Our App
Log in to the ArgoCD web interface and confirm that our app is displayed as Synced and Healthy
✒ Conclusion:
Thank you for reading this blog. In our journey, we installed ArgoCD, linked it to monitor changes in our Kubernetes manifest repository, and successfully deployed our app using this powerful tool. By verifying the deployment, we ensured that our app was not only deployed but also functioning as intended. ArgoCD has proven its value in simplifying the deployment process and enhancing our confidence in managing Kubernetes applications.
✒ Next read:
📌 Creating AWS EKS Cluster using Terraform
📌 Setting Up ArgoCD with AWS EKS for GitOps Implementation ( Current Blog )
📌 Setting Up Jenkins CI/CD as part of GitOps Implementation