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:
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.
How to Configure the ArgoCD:
- Deploy ArgoCD into K8 cluster.
- Purpose built for K8
- 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:
## Deploy ArgoCD
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/v2.6.7/manifests/install.yamlNow we will check the default password set after the installation:
## Get Default Password
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -dNow in order to access the GUI of ArgoCD outside cluster, we have the two ways:
- Port Forwarding
- Use the NodePort
Using the Port Forwarding:
## Expose ArgoCD GUI
kubectl port-forward svc/argocd-server -n argocd 8090:443 --address=0.0.0.0Using the NodePort:
We will modify the service of ArgoCD as following command:
k edit svc/argocd-server -n argocdThen the new addition will be as follows:
- 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: NodePortThe complete service becomes:
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:
https://Zaeem2022:[email protected]/Zaeem2022/ArgoCD-Test.gitQuestions
- 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:
- Deploy ArgoCD in the K8 Cluster
- Configure ArgoCD to track Git Repo.
- ArgoCd monitors for the changes and can apply automatically.