I have recently worked and tried out a wonderful continuous delivery (CD) tool ArgoCD. It’s a declarative GitOps continuous delivery tool for Kubernetes which is totally dedicated to Kubernetes deployment. It’s has awesome UI dashboard to monitor and mange deployment. It can be directly linked to source code repo like GitHub.
- Why ArgoCD?
- How to install ArgoCD on Kubernetes cluster
- How to use ArgoCD using UI and CLI headless modes
- Create a deployment app in ArgoCD with a sample GitHub Repo and sync
- Other Kubernetes Operations from UI:
It works on pull mechanism.Application definitions, configurations, and environments should be declarative and version controlled. Application deployment and lifecycle management should be automated, auditable, and easy to understand.
I like the this awesome feature of auto-syncing and deployment on K8s cluster for making any small change in K8s deployment manifest source code.
Kubernetes cluster should be installed and logged in. You can use KIND (Kubernetes Inside Docker) or MiniKube for local testing. I have used TKG Kubernetes cluster.
Kubectl CLI should be installed.
How to install ArgoCD on Kubernetes cluster
a. Install ArgoCD
Refer these easy official docs to install:
How to use ArgoCD
Start ArgoCD Server
$ kubectl port-forward svc/argocd-server -n argocd 9080:443 Forwarding from 127.0.0.1:9080 -> 8080 Forwarding from [::1]:9080 -> 8080
Create a deployment app in ArgoCD with a sample GitHub Repo and sync
You are now almost ready to deploy your application.However, first you need to tell ArgoCD about your deployment target. By default, if you do not add an additional Kubernetes cluster target, ArgoCD will deploy applications to the cluster on which it is installed. To add your target Kubernetes cluster to ArgoCD, use the following:
$ argocd cluster add target-k8s
This will add an ArgoCD service account onto the cluster, which will allow ArgoCD to deploy applications to it
Create an App in ArgoCD with a sample GitHub Repo
There are two ways to create app in ArgoCD:
There are two ways to use ArgoCD:
- UI mode
- CLI mode (headless)
1. UI mode
Login to ArgoCD:
https://localhost:9080/ # User Id - admin, # Password - Can be retrieved from this command: $ kubectl get pods -n argocd -l app.kubernetes.io/name=argocd-server -o name | cut -d'/' -f 2
Create APP – using ArgoCD UI
- Give a project name
- Select default cluster
- Select your Kubernetes cluster namespace
- You need url of source code repo. I am using Github repo.
- Select “Target Revision” of source code. I have used “HEAD”
- Add “Path” from Kubernetes deployment manifest files location
Note: You can also click on “Sync” button on ArgoCD UI.
Now, simply forward the port as you did for the ArgoCD UI.
$ kubectl port-forward svc/online-store-k8s-demo -n default 1090:8080
Once completed, “online-store-k8s-demo” app will be available at http://localhost:9090. You can open this URL on browser now.
Other Kubernetes Operations from UI:
- Logging- POD/deployment/services and other K8s objects logs also on ArgoCD UI dashboard
- Delete K8s objects
- Sync any specific object like re-deploy/sync selected deployment
- Rollback and re-deploy from UI
- Track all event on K8s objects
- Compare source code changes from the previous revision
2. CLI mode (headless)
Login thru CLI: (Optional)
$ argocd login localhost:8080
Manually using CLI
$ argocd app create online-store-k8s-demo --repo https://github.com/rajivmca2004/online-store-k8s-demo --path . --dest-server https://kubernetes.default.svc --dest-namespace default
Once this completes, you can see the status and configuration of your app by running the following:
$ argocd app list
For a more detailed view of your application configuration, run:
$ argocd app get online-store-k8s-demo
Initially your app will be Out of Sync and no health status. Now you are ready to sync your application to your target cluster. To do this, simply use the sync command for your application:
$ argocd app sync online-store-k8s-demo