ArgoCD

Updated 29 October 2024

ArgoCD creates the relationship in between the Git Repo and K8 Cluster

Continuous Delivery Tool

Competitor to Jenkins and GitLab CI/CD

ArgoCD Documentation:

yaml
https://argo-cd.readthedocs.io/en/stable/getting_started/

Why we need it

  • Any change in the configurations or deployment versions.
  • If we have a cluster with a large number of deployments, then it is impractical to manage all of them manually.
  • We don’t need to access the K8 Cluster for using the ArgoCD.
  • No need to access the AWS EKS Cluster.
  • Version Controlled way to manage the K8 Cluster.
Image from notes

How to Configure the ArgoCD:

  1. Deploy ArgoCD into K8 cluster.
  2. Purpose built for K8
  3. Supports multiple clusters.

Deployment on K8 Cluster

ArgoCD gets deployed in the K8 cluster as part of the cluster in which it acts as an agent in the K8 cluster.

Use the following method:

javascript
## Deploy ArgoCD
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/v2.6.7/manifests/install.yaml

Now we will check the default password set after the installation:

javascript
## Get Default Password
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d

Now in order to access the GUI of ArgoCD outside cluster, we have the two ways:

  1. Port Forwarding
  2. Use the NodePort

Using the Port Forwarding:

javascript
## Expose ArgoCD GUI
kubectl port-forward svc/argocd-server -n argocd 8090:443 --address=0.0.0.0

Using the NodePort:

We will modify the service of ArgoCD as following command:

javascript
k edit svc/argocd-server -n argocd

Then the new addition will be as follows:

yaml
- name: http
    nodePort: 30276
    port: 80
    protocol: TCP
    targetPort: 8080
  - name: https
    nodePort: 32311
    port: 443
    protocol: TCP
    targetPort: 8080
  selector:
    app.kubernetes.io/name: argocd-server
  sessionAffinity: None
  type: NodePort

The complete service becomes:

yaml
apiVersion: v1
kind: Service
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app.kubernetes.io/component":"server","app.kubernetes.io/name":"argocd-server","app.kubernetes.io/part-of":"argocd"},"name":"argocd-server","namespace":"argocd"},"spec":{"ports":[{"name":"http","port":80,"protocol":"TCP","targetPort":8080},{"name":"https","port":443,"protocol":"TCP","targetPort":8080}],"selector":{"app.kubernetes.io/name":"argocd-server"}}}
  creationTimestamp: "2023-05-04T07:00:01Z"
  labels:
    app.kubernetes.io/component: server
    app.kubernetes.io/name: argocd-server
    app.kubernetes.io/part-of: argocd
  name: argocd-server
  namespace: argocd
  resourceVersion: "17495421"
  uid: e6dc2e8f-ae7f-4ee9-b559-81b4c2df7c3c
spec:
  clusterIP: 10.102.52.112
  clusterIPs:
  - 10.102.52.112
  externalTrafficPolicy: Cluster
  internalTrafficPolicy: Cluster
  ipFamilies:
  - IPv4
  ipFamilyPolicy: SingleStack
  ports:
  - name: http
    nodePort: 30276
    port: 80
    protocol: TCP
    targetPort: 8080
  - name: https
    nodePort: 32311
    port: 443
    protocol: TCP
    targetPort: 8080
  selector:
    app.kubernetes.io/name: argocd-server
  sessionAffinity: None
  type: NodePort
status:
  loadBalancer: {}

Example of NGINX

Go to the following Github Repo:

yaml
https://Zaeem2022:[email protected]/Zaeem2022/ArgoCD-Test.git

Questions

  • What happens if someone makes a change directly in the cluster by using “kubectl apply”.

ArgoCD checks for the Actual state as well as the Desired State. The desired state is as per defined in the Git Repository. So, it will make the change as per in the Git Repo.

So, it will overwrite the manual change.

Only source of Truth !

In a Nutshell

We can say that in order to manage our K8 cluster with the help of ArgoCD, following steps are involved:

  1. Deploy ArgoCD in the K8 Cluster
  2. Configure ArgoCD to track Git Repo.
  3. ArgoCd monitors for the changes and can apply automatically.
Spotted a mistake or want something added? Send me a note.