What is Argo CD?
Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes.
Argo CD is implemented as a kubernetes controller which continuously monitors running applications and compares the current, live state against the desired target state (as specified in the Git repo). Argo CD reports & visualizes the differences, while providing facilities to automatically or manually sync the live state back to the desired target state. Any modifications made to the desired target state in the Git repo can be automatically applied and reflected in the specified target environments.
For more details refer — https://argoproj.github.io/argo-cd/
In this article, we will see how we can setup and manage ELK on Kubernetes cluster using Argo CD. We will be using elastic helm charts for setting up cluster with git repo as the single source for Argo CD.
Note: The helm charts used in this article are for development purposes and should not be used in production environment. For production setup, helm charts should be enhanced for example, use persistence volumes for elasticsearch, security creds for Kibana etc.
Setup Argo CD on Kubernetes Cluster
- Running Kubernetes Cluster
- Kubectl command line installed
- Create namespace for Argo CD and Elastic
kubectl create namespace argocd
kubectl create namespace elastic-system
- Install Argo CD
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
This will deploy Argo CD components as pods and expose it as service.
Once pods are running, we need to change argocd-server service type to NodePort so we can access the UI using server IP. (In actual production environment, services should be accessed using ingress, load balancer etc)
- Login to ArgoCD
Lets try to access ArgoCD via browser using NodePort (NodePort will be different in your case so use the port assigned)
https://<server ip>:<node port>
Note: For first time login use the below command to get the admin password.
username : admin
password: <use below command>
kubectl get pods -n argocd -l app.kubernetes.io/name=argocd-server -o name | cut -d'/' -f 2
- Configure ArgoCD
To get started with automating deployments using ArgoCD, it needs to be configured with source GIT repo, project, access etc. So let’s get started:
We are going to use below Elastic Helm Repo as the source. This is a custom repo forked from elastic helm charts and has some changes done to work well with our setup. (like number of replicas, elastic endpoint, role access permissions etc)
Settings > Repositories
Enter details as show below and click on Connect.
Settings > Projects
Enter details as shown below. This will give repository access to deploy resources to the elastic-system namespace in k8s cluster.
Project Name: elastic-system
Sources: Enter the previously added repo.
Destinations: The namespace to which we want to deploy resources.
- Create Applications for ELK
Go to Applications tab and click on + New App.
Enter details as shown below:
Application Name: elasticsearch (can be anything but should be all small letters)
Project: elastic-system (created while config)
Sync Policy: Manual/Automatic
Repository URL: <repo added while config>
Path: elasticsearch (this is the elasticsearch folder in our git helm repo)
Destination: Default cluster
Namespace: elastic-system (as created in first step)
values.yml will get loaded automatically from source repo.
Click on CREATE. It gets saved and shows OutfSync.
Open the newly created application and click on SYNC to deploy elasticsearch to the k8s cluster. Resources will get created inside elastic-system namespace.
(As we have 2 replicas mentioned in our source repo, it will create 2 pods for elasticsearch)
Similar to the process followed for elasticsearch, create a new application for Kibana. Enter details as shown below. Details are same as elasticsearch except the repo path which needs to be kibana in this case.
SYNC the application once created. One kibana pod and service will get created in elastic-system namespace. Kibana helm chart is already updated to use NodePort as type so Kibana can be accessed using NodePort.
Similar to the process followed for elasticsearch, create a new application for Logstash. Enter details as shown below. Details are same as elasticsearch except the repo path which needs to be logstash in this case.
SYNC the application once created.
So now ELK stack is up and running on k8s cluster using ArgoCD. We can install other beats agents also using same repo and process. All the helm charts are there in git repo like metricbeat, heartbeat etc.
Let’s look at heartbeat –
Similar to the process followed for elasticsearch, create a new application for Heartbeat. Enter details as shown below. Details are same as elasticsearch except the repo path which needs to be heartbeat in this case.
SYNC it once created. Heartbeat agents will be deployed as daemonset in all the nodes.
Go to Kibana and create index pattern for heartbeat and see the data flowing for sample monitor.
Now with ArgoCD configured, for any changes to the Elastic Stack all you need to do is update the values/configs in git repo and then SYNC the application in ArgoCD or if Automatic SYNC is configured then changes get auto SYNCED to the cluster.
Important features include:
- Automated deployment of applications to specified target environments
- Ability to manage and deploy to multiple clusters
- Rollback/Roll-anywhere to any application configuration committed in Git repository
- Health status analysis of application resources
- Automated or manual syncing of applications to its desired state
- Web UI which provides real-time view of application activity
Do let us know in comments for any issues or feedback.
- Monitor Kubernetes Control Plane Services Availability with Heartbeat [ELK] - December 14, 2020
- Setup and operate ELK Stack on Kubernetes cluster using Argo CD - October 26, 2020
- Auto clear notification using Watcher - June 10, 2020