0
0
Kubernetesdevops~10 mins

GitOps with ArgoCD in Kubernetes - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - GitOps with ArgoCD
Developer pushes code to Git repo
ArgoCD monitors Git repo
Detects changes in repo
ArgoCD syncs changes to Kubernetes cluster
Kubernetes applies new config/state
Cluster state matches Git repo state
ArgoCD reports status back
This flow shows how ArgoCD watches a Git repository for changes, then applies those changes automatically to a Kubernetes cluster, keeping cluster state in sync with Git.
Execution Sample
Kubernetes
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
argocd app create guestbook --repo https://github.com/argoproj/argocd-example-apps.git --path guestbook --dest-server https://kubernetes.default.svc --dest-namespace default
argocd app sync guestbook
This sequence installs ArgoCD, creates an application linked to a Git repo, and syncs it to the Kubernetes cluster.
Process Table
StepActionEvaluationResult
1Create namespace 'argocd'Namespace 'argocd' does not existNamespace 'argocd' created
2Apply ArgoCD manifestsManifests validArgoCD components deployed in 'argocd' namespace
3Create ArgoCD app 'guestbook'Repo and path accessibleApp 'guestbook' registered in ArgoCD
4ArgoCD monitors Git repoNo changes yetApp status: Synced
5Push change to Git repo (e.g., update guestbook image)Change detected by ArgoCDApp status: OutOfSync
6Run 'argocd app sync guestbook'Sync command acceptedCluster updated to match Git repo
7Verify app statusCluster matches Git repoApp status: Synced
8ExitNo further changesProcess waits for next Git change
💡 No new changes in Git repo, ArgoCD waits for updates
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 5After Step 6Final
Namespace 'argocd'Not presentCreatedExistsExistsExistsExistsExists
ArgoCD app 'guestbook' statusNot presentNot presentNot presentSyncedOutOfSyncSyncedSynced
Cluster stateOld configOld configOld configOld configOld configUpdated to Git stateUpdated to Git state
Key Moments - 3 Insights
Why does ArgoCD show 'OutOfSync' after I push changes to Git?
Because ArgoCD detects that the cluster state no longer matches the Git repo state (see execution_table step 5). It waits for a sync command or automatic sync to update the cluster.
What happens if I don't run 'argocd app sync' after pushing changes?
The cluster remains out of sync with Git repo (execution_table step 5). ArgoCD will not apply changes until sync is triggered manually or auto-sync is enabled.
Why do we create a separate namespace 'argocd' before installing ArgoCD?
Namespaces isolate resources in Kubernetes. Creating 'argocd' namespace (step 1) keeps ArgoCD components organized and separate from other apps.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 5, what is the ArgoCD app 'guestbook' status?
AOutOfSync
BUnknown
CSynced
DError
💡 Hint
Check the 'Result' column at step 5 in the execution_table.
At which step does the Kubernetes cluster update to match the Git repo?
AStep 5
BStep 6
CStep 3
DStep 7
💡 Hint
Look for the step where 'Cluster updated to match Git repo' appears in the execution_table.
If you skip creating the 'argocd' namespace, what will happen at step 2?
AArgoCD installs in default namespace
BNamespace is created automatically
CInstallation fails due to missing namespace
DArgoCD installs but with errors
💡 Hint
Refer to variable_tracker for 'Namespace argocd' status after step 1 and step 2.
Concept Snapshot
GitOps with ArgoCD:
- ArgoCD watches Git repo for changes
- Changes trigger sync to Kubernetes cluster
- Cluster state matches Git repo state
- Use 'argocd app sync' to apply changes
- Namespace isolates ArgoCD components
- Status shows sync state (Synced/OutOfSync)
Full Transcript
GitOps with ArgoCD means using Git as the single source of truth for Kubernetes configurations. Developers push changes to a Git repository. ArgoCD continuously monitors this repo. When it detects changes, it marks the application as OutOfSync. Running 'argocd app sync' applies those changes to the Kubernetes cluster, updating it to match the Git state. The cluster then reports back as Synced. ArgoCD runs in its own namespace for organization. This process automates deployment and keeps cluster state consistent with Git.