Nextgen Blog
HomeLearnAIQuantumRoboticsSecuritySpaceAbout
Nextgen Blog

By Anubhav โ€” full stack engineer, IIT Mandi CSE. Deep dives into AI, software engineering, and the technologies shaping the next generation of tech.

Navigate

  • Home
  • Learn
  • Blog
  • Archive
  • About

Topics

  • Artificial Intelligence
  • Quantum Computing
  • Robotics
  • Cybersecurity
  • Space Tech

Connect

Built with โค๏ธ & By - Anubhav

ยฉ 2026 Nextgen Blog by Anubhav. All rights reserved.

Privacy PolicyTerms of Service
Phase 05 ยท Production & GitOpsChapter 32 of 33
31.
Phase 05Read time ~17 minDifficulty intermediate

GitOps + Argo CD ๐Ÿ”„

Warrior, this is one of the most important chapters in the entire Kubernetes course.

In this chapter
  • 01What is GitOps?
  • 02Traditional deployment
  • 03GitOps deployment
  • 04Why is this useful?
  • 05The GitOps mental model
  • 06What is Argo CD?
  • 07Argo CD is not CI
  • 08CI
  • 09Argo CD
  • 10Complete GitOps architecture
  • 11Two Git repositories
  • 12Repository 1 โ€” Application
  • 13Repository 2 โ€” Deployment
  • 14Why separate repositories?
  • 15But you don't have to use two repositories
  • 16Git becomes the source of truth
  • 17Desired vs actual state
  • 18Argo CD Application
  • 19Example Argo CD Application
  • 20source
  • 21destination
  • 22syncPolicy
  • 23What is selfHeal?
  • 24What is prune?
  • 25Sync
  • 26Argo CD UI
  • 27Sync status vs health
  • 28Sync status
  • 29Health
  • 30Very important distinction
  • 31GitOps deployment flow
  • 32Where does CI fit?
  • 33Image update automation
  • 34Kustomize + Argo CD
  • 35Helm + Argo CD
  • 36Kustomize vs Helm with Argo
  • 37Helm
  • 38Kustomize
  • 39Multi-environment GitOps
  • 40ApplicationSet
  • 41Argo CD Projects
  • 42RBAC in Argo CD
  • 43GitOps and Kubernetes reconciliation
  • 44Drift example
  • 45What if someone changes Git?
  • 46Git history becomes deployment history
  • 47Rollback with GitOps
  • 48GitOps rollback vs Kubernetes rollback
  • 49Kubernetes rollback
  • 50GitOps rollback
  • 51The "don't fight GitOps" principle
  • 52GitOps repository example for your stack
  • 53Your production architecture with GitOps
  • 54GitOps with your AI application
  • 55GitOps advantages
  • 56Auditability
  • 57Reproducibility
  • 58Drift detection
  • 59Review
  • 60Rollback
  • 61Reduced direct cluster access
  • 62GitOps challenges
  • 63Secrets
  • 64Large repositories
  • 65Database migrations
  • 66GitOps vs CI/CD
  • 67Interview question: What is GitOps?
  • 68Interview question: What is Argo CD?
  • 69Interview question: What is drift?
  • 70Interview question: What does self-healing mean?
  • 71Interview question: Helm + Argo CD?
  • 72Interview question: Kustomize + Argo CD?
  • 73The entire Kubernetes course in one architecture
  • 74The most important mental model:
In this chapter (74 sections)
01What is GitOps?02Traditional deployment03GitOps deployment04Why is this useful?05The GitOps mental model06What is Argo CD?07Argo CD is not CI08CI09Argo CD10Complete GitOps architecture11Two Git repositories12Repository 1 โ€” Application13Repository 2 โ€” Deployment14Why separate repositories?15But you don't have to use two repositories16Git becomes the source of truth17Desired vs actual state18Argo CD Application19Example Argo CD Application20source21destination22syncPolicy23What is selfHeal?24What is prune?25Sync26Argo CD UI27Sync status vs health28Sync status29Health30Very important distinction31GitOps deployment flow32Where does CI fit?33Image update automation34Kustomize + Argo CD35Helm + Argo CD36Kustomize vs Helm with Argo37Helm38Kustomize39Multi-environment GitOps40ApplicationSet41Argo CD Projects42RBAC in Argo CD43GitOps and Kubernetes reconciliation44Drift example45What if someone changes Git?46Git history becomes deployment history47Rollback with GitOps48GitOps rollback vs Kubernetes rollback49Kubernetes rollback50GitOps rollback51The "don't fight GitOps" principle52GitOps repository example for your stack53Your production architecture with GitOps54GitOps with your AI application55GitOps advantages56Auditability57Reproducibility58Drift detection59Review60Rollback61Reduced direct cluster access62GitOps challenges63Secrets64Large repositories65Database migrations66GitOps vs CI/CD67Interview question: What is GitOps?68Interview question: What is Argo CD?69Interview question: What is drift?70Interview question: What does self-healing mean?71Interview question: Helm + Argo CD?72Interview question: Kustomize + Argo CD?73The entire Kubernetes course in one architecture74The most important mental model:

You've already learned:

Git โ†’ CI โ†’ Docker โ†’ Registry โ†’ Kubernetes

Now we're going to change how Kubernetes deployments are controlled.

Instead of CI directly telling Kubernetes:

kubectl apply ...

we'll use:

Git
 โ†“
Argo CD
 โ†“
Kubernetes

This is called GitOps.


1. What is GitOps?#

The simplest definition:

GitOps means using Git as the source of truth for the desired state of your infrastructure and applications, with an automated system continuously reconciling Kubernetes to that state.

Remember Chapter 1?

Kubernetes works using:

Desired State
      โ†“
Controller
      โ†“
Actual State

GitOps takes that idea and makes Git the source of the desired state.


2. Traditional deployment#

Previously we learned:

Developer
    โ†“
Git
    โ†“
GitHub Actions
    โ†“
Docker build
    โ†“
Container Registry
    โ†“
kubectl apply
    โ†“
Kubernetes

For example:

kubectl apply -f deployment.yaml

The CI server directly changes the cluster.


3. GitOps deployment#

With GitOps:

Developer
    โ†“
Git
    โ†“
CI
    โ†“
Docker Image
    โ†“
Registry
 
Git
    โ†“
Kubernetes manifests
    โ†“
Argo CD
    โ†“
Kubernetes

Notice something important:

CI doesn't necessarily need to directly deploy to Kubernetes.

Argo CD does.


4. Why is this useful?#

Imagine someone manually changes production:

kubectl scale deployment node-api --replicas=10

But Git says:

replicas: 3

Now:

Git = 3
Kubernetes = 10

The cluster has drifted from the desired configuration.

A GitOps controller can detect this difference.

Desired
3 replicas
 
Actual
10 replicas
 
        โ†“
 
Drift detected

Depending on your Argo CD configuration, it can synchronize the cluster back to the Git-defined state.


5. The GitOps mental model#

This is extremely important:

                 Git
                  โ”‚
          Desired State
                  โ”‚
                  โ†“
               Argo CD
                  โ”‚
          Reconciliation
                  โ”‚
                  โ†“
             Kubernetes
                  โ”‚
            Actual State
                  โ”‚
                  โ†“
             Pods/Services

Argo CD continuously compares:

Desired state
      VS
Actual state

6. What is Argo CD?#

Argo CD is a GitOps continuous delivery tool for Kubernetes.

Its primary job is:

Git repository
      โ†“
Read Kubernetes configuration
      โ†“
Compare with cluster
      โ†“
Synchronize
      โ†“
Kubernetes

It supports configurations such as:

  • plain Kubernetes YAML
  • Kustomize
  • Helm
  • Jsonnet
  • other supported configuration sources

7. Argo CD is not CI#

This distinction is critical.

CI#

Usually handles:

Build
Test
Lint
Security
Docker image

Argo CD#

Handles:

Deployment
Synchronization
Drift detection
Reconciliation

So:

CI
 โ†“
Build artifact
 
Argo CD
 โ†“
Deploy artifact/configuration

8. Complete GitOps architecture#

A modern pipeline can look like:

                    Developer
                        โ”‚
                        โ†“
                       Git
                        โ”‚
             โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
             โ†“                     โ†“
        Application repo       Deployment repo
             โ”‚                     โ”‚
             โ†“                     โ†“
            CI                  Argo CD
             โ”‚                     โ”‚
             โ†“                     โ†“
       Docker Image           Kubernetes
             โ”‚                     โ”‚
             โ†“                     โ†“
          Registry              Pods

There are different repository structures, but the separation is useful to understand.


9. Two Git repositories#

A common pattern:

Repository 1 โ€” Application#

node-api/
โ”œโ”€โ”€ src/
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ Dockerfile
โ””โ”€โ”€ tests/

Repository 2 โ€” Deployment#

k8s-config/
โ”œโ”€โ”€ base/
โ””โ”€โ”€ overlays/
    โ”œโ”€โ”€ dev/
    โ”œโ”€โ”€ staging/
    โ””โ”€โ”€ production/

Then:

Application repo
       โ†“
CI
       โ†“
Docker image
       โ†“
Registry
 
Deployment repo
       โ†“
Argo CD
       โ†“
Kubernetes

10. Why separate repositories?#

Because application code and infrastructure configuration have different purposes.

Application repo:

"How does my application work?"

Deployment repo:

"How should this application run?"

For example:

replicas: 5

is deployment configuration.

While:

app.get("/users")

is application code.


11. But you don't have to use two repositories#

GitOps can also use a single repository.

For example:

my-project/
โ”‚
โ”œโ”€โ”€ src/
โ”œโ”€โ”€ Dockerfile
โ”‚
โ””โ”€โ”€ k8s/
    โ”œโ”€โ”€ base/
    โ””โ”€โ”€ overlays/

Argo CD watches:

/k8s

This is perfectly valid.

The right structure depends on team size, release model, ownership, and organizational needs.


12. Git becomes the source of truth#

Suppose Git contains:

replicas: 3

Argo CD sees:

Git = 3
Cluster = 3

Everything is synchronized.

Now someone changes the cluster manually:

kubectl scale deployment node-api --replicas=7

Now:

Git = 3
Cluster = 7

Argo CD sees:

DRIFT

If automated sync/self-healing is configured, Argo CD can reconcile the cluster back toward Git's desired state.


13. Desired vs actual state#

This is the heart of GitOps.

              Git
               โ”‚
               โ†“
        Desired State
          replicas=3
               โ”‚
               โ†“
            Argo CD
               โ”‚
               โ†“
       Kubernetes Cluster
               โ”‚
               โ†“
         Actual State
          replicas=3

When they differ:

Desired = 3
Actual  = 7
 
      โ†“
 
     DRIFT

Argo CD can synchronize.


14. Argo CD Application#

Argo CD introduces an important object:

Application

An Argo CD Application tells Argo:

"This Git repository/path represents the desired state for this Kubernetes application."

Conceptually:

Argo CD Application
 
Repository:
github.com/company/platform
 
Path:
k8s/overlays/production
 
Destination:
production-cluster

15. Example Argo CD Application#

A simplified Application:

apiVersion: argoproj.io/v1alpha1
kind: Application
 
metadata:
  name: node-api
 
spec:
  project: default
 
  source:
    repoURL: https://github.com/example/k8s-config.git
    targetRevision: main
    path: overlays/production
 
  destination:
    server: https://kubernetes.default.svc
    namespace: production
 
  syncPolicy:
    automated:
      prune: true
      selfHeal: true

Let's understand this piece by piece.


16. source#

source:
  repoURL: https://github.com/example/k8s-config.git
  targetRevision: main
  path: overlays/production

This says:

Git repository
     โ†“
main branch
     โ†“
overlays/production

That's where Argo CD gets the desired Kubernetes configuration.


17. destination#

destination:
  server: https://kubernetes.default.svc
  namespace: production

This specifies where the application should be deployed.

In a multi-cluster environment, the destination can identify a particular Kubernetes cluster.


18. syncPolicy#

This controls synchronization behavior.

For example:

syncPolicy:
  automated:
    prune: true
    selfHeal: true

This enables automated reconciliation behavior.


19. What is selfHeal?#

Imagine Git says:

replicas: 3

Someone manually changes:

replicas = 10

Argo CD detects:

Git      = 3
Cluster  = 10

With self-healing enabled, Argo CD can restore the Git-defined state.

Conceptually:

Manual change
     โ†“
Drift
     โ†“
Argo CD detects
     โ†“
Reconcile
     โ†“
Back toward desired state

20. What is prune?#

Suppose Git originally contains:

deployment.yaml
service.yaml
configmap.yaml

Then someone removes:

configmap.yaml

from Git.

Without appropriate pruning behavior, the old ConfigMap may remain in the cluster.

With pruning enabled:

Git
 โ†“
ConfigMap removed
 โ†“
Argo CD detects resource no longer desired
 โ†“
Prune
 โ†“
ConfigMap removed from cluster

Be careful with pruning in production.

You want Git to be authoritative, but accidental Git changes can have real consequences.


21. Sync#

Argo CD uses the concept of sync.

If:

Git desired state
        โ‰ 
Cluster actual state

the application is out of sync.

Sync means:

Bring cluster toward Git-defined desired state.

22. Argo CD UI#

Argo CD provides a web UI where you can see:

Applications
Clusters
Resources
Sync status
Health
History
Events

You might see:

node-api
 
SYNC: Synced
HEALTH: Healthy

Or:

SYNC: OutOfSync
HEALTH: Degraded

This is extremely useful operationally.


23. Sync status vs health#

These are different.

Sync status#

Answers:

Does the cluster match the Git configuration?

Possible conceptual state:

Synced
OutOfSync

Health#

Answers:

Is the application/resource functioning according to Argo CD's health assessment?

Conceptually:

Healthy
Progressing
Degraded
Missing
Unknown

You can have:

Synced + Degraded

For example:

Git configuration = correctly applied
but
Pods = crashing

24. Very important distinction#

Synced

does not necessarily mean:

Application is healthy.

It means the cluster matches the desired configuration.

Example:

Deployment says:
 
image: broken-image:v5

Argo CD successfully applies it.

So:

SYNC = Synced
HEALTH = Degraded

because the Pods may fail to start.


25. GitOps deployment flow#

Let's say you release:

node-api v2

Developer changes:

image:
  tag: "v2"

Then:

git commit
      โ†“
git push
      โ†“
Argo CD detects change
      โ†“
OutOfSync
      โ†“
Sync
      โ†“
Kubernetes Deployment
      โ†“
Rolling Update
      โ†“
New Pods
      โ†“
Readiness
      โ†“
Healthy

26. Where does CI fit?#

CI still builds the image.

For example:

Developer
   โ†“
Git
   โ†“
GitHub Actions
   โ†“
Tests
   โ†“
Docker Build
   โ†“
Registry

Then CI needs to update the deployment configuration.

For example:

image:
  tag: "a8f72c1"

A commit is pushed to the deployment repository.

Then:

Deployment Git
     โ†“
Argo CD
     โ†“
Kubernetes

This creates a clean separation.


27. Image update automation#

Imagine CI builds:

node-api:a8f72c1

Then it updates:

images:
  - name: node-api
    newTag: a8f72c1

and commits that change.

Now:

Git
 โ†“
new image reference
 โ†“
Argo CD
 โ†“
Kubernetes

The deployment itself becomes Git-driven.


28. Kustomize + Argo CD#

This is particularly relevant because Chapter 26 covered Kustomize.

Repository:

k8s/
โ”‚
โ”œโ”€โ”€ base/
โ”‚   โ”œโ”€โ”€ deployment.yaml
โ”‚   โ”œโ”€โ”€ service.yaml
โ”‚   โ””โ”€โ”€ kustomization.yaml
โ”‚
โ””โ”€โ”€ overlays/
    โ”œโ”€โ”€ dev/
    โ”‚   โ””โ”€โ”€ kustomization.yaml
    โ”‚
    โ”œโ”€โ”€ staging/
    โ”‚   โ””โ”€โ”€ kustomization.yaml
    โ”‚
    โ””โ”€โ”€ production/
        โ””โ”€โ”€ kustomization.yaml

Argo CD can point to:

overlays/production

Argo understands the Kustomize configuration and generates the desired manifests.


29. Helm + Argo CD#

Argo CD can also deploy Helm charts.

Repository:

helm/
โ””โ”€โ”€ node-api/
    โ”œโ”€โ”€ Chart.yaml
    โ”œโ”€โ”€ values.yaml
    โ””โ”€โ”€ templates/

Argo CD points to:

helm/node-api

and can supply appropriate Helm values.

So:

Helm
   โ†“
Kubernetes manifests
   โ†“
Argo CD
   โ†“
Kubernetes

30. Kustomize vs Helm with Argo#

Both work.

Helm#

Chart
 +
Values
 โ†“
Rendered resources
 โ†“
Argo CD

Kustomize#

Base
 +
Overlay
 โ†“
Rendered resources
 โ†“
Argo CD

Argo CD becomes the GitOps controller responsible for synchronizing the resulting desired state.


31. Multi-environment GitOps#

Suppose:

Development
Staging
Production

Repository:

k8s/
โ”‚
โ”œโ”€โ”€ base/
โ”‚
โ””โ”€โ”€ overlays/
    โ”œโ”€โ”€ dev/
    โ”œโ”€โ”€ staging/
    โ””โ”€โ”€ production/

Then create Argo Applications:

node-api-dev
node-api-staging
node-api-production

Each points to:

different path

For example:

node-api-dev
    โ†“
overlays/dev
 
node-api-staging
    โ†“
overlays/staging
 
node-api-production
    โ†“
overlays/production

32. ApplicationSet#

Imagine you have:

20 applications
3 environments

Creating every Argo Application manually can become repetitive.

Argo CD provides ApplicationSet for generating Applications from templates.

Conceptually:

ApplicationSet
      โ”‚
      โ”œโ”€โ”€ app1-dev
      โ”œโ”€โ”€ app1-prod
      โ”œโ”€โ”€ app2-dev
      โ”œโ”€โ”€ app2-prod
      โ”œโ”€โ”€ app3-dev
      โ””โ”€โ”€ app3-prod

This becomes extremely useful at platform scale.


33. Argo CD Projects#

Argo CD also has:

AppProject

Projects help define boundaries such as:

Which repositories can be used?
Which clusters?
Which namespaces?
Which resource types?

For example:

team-a project
   โ†“
team-a Git repositories
   โ†“
team-a namespaces

This provides an additional governance layer.


34. RBAC in Argo CD#

You now have another authorization layer.

Remember:

AWS IAM
Kubernetes RBAC
Argo CD RBAC

These are different systems.

Argo CD RBAC can control:

Who can view applications?
Who can sync?
Who can modify applications?
Who can access projects?

35. GitOps and Kubernetes reconciliation#

This is one of the deepest concepts in the course.

Kubernetes already does:

Desired State
      โ†“
Controllers
      โ†“
Actual State

GitOps adds:

Git
 โ†“
Desired State
 โ†“
Argo CD
 โ†“
Kubernetes API
 โ†“
Controllers
 โ†“
Actual State

So:

GitOps

is very naturally aligned with Kubernetes' controller-based architecture.


36. Drift example#

Suppose Git:

replicas: 3

Cluster:

3

Everything is fine.

Someone executes:

kubectl scale deployment node-api --replicas=8

Now:

Git      = 3
Cluster  = 8

Argo:

OutOfSync

If self-healing is enabled:

8
 โ†“
Argo reconciliation
 โ†“
3

This is GitOps in action.


37. What if someone changes Git?#

Suppose:

Git
replicas: 3

Developer changes:

replicas: 5

and creates a pull request.

After approval:

Git
replicas: 5

Argo sees:

Desired = 5
Actual = 3

Then syncs:

3 โ†’ 5

This is a much more auditable deployment model.


38. Git history becomes deployment history#

Suppose:

Commit A
replicas: 3
 
Commit B
replicas: 5
 
Commit C
image: v2

You can trace:

Git commit
    โ†“
Configuration change
    โ†“
Argo synchronization
    โ†“
Kubernetes deployment

This improves:

  • auditing
  • traceability
  • review
  • rollback
  • collaboration

39. Rollback with GitOps#

Suppose production is running:

v2

and it is broken.

Git history:

Commit A โ†’ v1
Commit B โ†’ v2

You can revert the deployment configuration:

Commit B
    โ†“
revert
    โ†“
Commit A state
    โ†“
Argo CD
    โ†“
Kubernetes
    โ†“
v1

This makes Git itself part of the rollback mechanism.


40. GitOps rollback vs Kubernetes rollback#

You now have two mechanisms.

Kubernetes rollback#

kubectl rollout undo deployment/node-api

GitOps rollback#

Revert Git commit
        โ†“
Argo CD
        โ†“
Kubernetes

With GitOps, the Git-defined state should generally remain authoritative.

Otherwise you can create a mismatch:

Git = v2
Cluster = v1

and Argo may reconcile back to v2.


41. The "don't fight GitOps" principle#

Imagine:

Git says:
replicas = 3

You manually execute:

kubectl scale deployment node-api --replicas=10

Argo:

"Git says 3."

You:

"Make it 10."

Argo:

"Git says 3."

This creates a fight.

The correct approach is usually:

Need 10 replicas?
      โ†“
Change Git
      โ†“
Review
      โ†“
Merge
      โ†“
Argo
      โ†“
10 replicas

42. GitOps repository example for your stack#

For your typical architecture:

platform-config/
โ”‚
โ”œโ”€โ”€ apps/
โ”‚   โ”œโ”€โ”€ frontend/
โ”‚   โ””โ”€โ”€ backend/
โ”‚
โ”œโ”€โ”€ infrastructure/
โ”‚   โ”œโ”€โ”€ redis/
โ”‚   โ””โ”€โ”€ ingress/
โ”‚
โ””โ”€โ”€ environments/
    โ”‚
    โ”œโ”€โ”€ dev/
    โ”‚
    โ”œโ”€โ”€ staging/
    โ”‚
    โ””โ”€โ”€ production/

Or Kustomize:

platform-config/
โ”‚
โ”œโ”€โ”€ base/
โ”‚   โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ redis/
โ”‚   โ””โ”€โ”€ ingress/
โ”‚
โ””โ”€โ”€ overlays/
    โ”œโ”€โ”€ dev/
    โ”œโ”€โ”€ staging/
    โ””โ”€โ”€ production/

43. Your production architecture with GitOps#

Now combine almost everything we've learned:

                         Git
                          โ”‚
                โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                โ†“                   โ†“
          Application Repo     Deployment Repo
                โ”‚                   โ”‚
                โ†“                   โ†“
               CI                 Argo CD
                โ”‚                   โ”‚
                โ†“                   โ†“
           Docker Image          Sync
                โ”‚                   โ”‚
                โ†“                   โ†“
             Registry           Kubernetes
                                    โ”‚
                       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                       โ†“            โ†“            โ†“
                    Frontend     Backend       Redis
                       โ”‚            โ”‚
                       โ†“            โ†“
                    Next.js      Node.js
                                    โ”‚
                             โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”
                             โ†“             โ†“
                          PostgreSQL      RAG

And monitoring:

Kubernetes
    โ†“
Prometheus
    โ†“
Grafana

Logging:

Pods
 โ†“
Log collector
 โ†“
Centralized logging

44. GitOps with your AI application#

Imagine your AI support system:

Next.js
   โ†“
Node.js API
   โ†“
Agent Orchestrator
   โ†“
Retriever
   โ†“
Vector DB
   โ†“
LLM

You might have:

frontend Deployment
backend Deployment
retriever Deployment
worker Deployment
redis
vector DB
ingress
HPA
network policies

GitOps manages the Kubernetes configuration for all of these.

Example:

Git
โ”‚
โ”œโ”€โ”€ frontend
โ”œโ”€โ”€ backend
โ”œโ”€โ”€ retriever
โ”œโ”€โ”€ worker
โ”œโ”€โ”€ redis
โ”œโ”€โ”€ ingress
โ”œโ”€โ”€ HPA
โ””โ”€โ”€ network policies
        โ”‚
        โ†“
      Argo CD
        โ”‚
        โ†“
    Kubernetes

45. GitOps advantages#

1. Auditability#

Git records:

Who
What
When

2. Reproducibility#

You can reconstruct environments from Git.

3. Drift detection#

Cluster configuration can be compared against Git.

4. Review#

Infrastructure changes can go through Pull Requests.

5. Rollback#

Git history provides a natural rollback mechanism.

6. Reduced direct cluster access#

Developers don't necessarily need unrestricted production kubectl access.


46. GitOps challenges#

GitOps isn't magic.

Potential challenges include:

Secrets#

Don't blindly commit:

password=secret123

to Git.

Use:

External Secrets
Secret Manager
Sealed Secrets
SOPS

or another appropriate secret-management strategy.


Large repositories#

Very large organizations need careful repository structure.


Database migrations#

This is especially important.

Suppose Git changes:

application v1 โ†’ v2

but database schema isn't compatible.

GitOps doesn't automatically solve migration compatibility.

You still need:

expand
 โ†“
migrate
 โ†“
application transition
 โ†“
contract

strategies where appropriate.


47. GitOps vs CI/CD#

Don't say:

"GitOps replaces CI."

That's incorrect.

A better model:

CI
 โ†“
Build/Test/Package

while:

GitOps
 โ†“
Deploy/Reconcile

Together:

CI + GitOps

can form a complete delivery system.


48. Interview question: What is GitOps?#

Strong answer:

"GitOps is an operational model where Git stores the desired state of applications and infrastructure, and an automated controller continuously reconciles the Kubernetes cluster with that state. Argo CD is a popular GitOps controller for Kubernetes."


49. Interview question: What is Argo CD?#

"Argo CD is a Kubernetes continuous delivery and GitOps tool. It monitors Git repositories containing desired Kubernetes configuration, compares that configuration with the cluster, detects drift, and synchronizes the cluster according to the configured policies."


50. Interview question: What is drift?#

"Drift occurs when the actual state of the Kubernetes cluster differs from the desired state defined in Git."

Example:

Git:
replicas=3
 
Cluster:
replicas=5

That's drift.


51. Interview question: What does self-healing mean?#

"With automated reconciliation and self-healing enabled, Argo CD can detect certain out-of-band changes and synchronize the cluster back toward the Git-defined desired state."


52. Interview question: Helm + Argo CD?#

Answer:

"Helm packages and templates Kubernetes resources, while Argo CD acts as the GitOps controller that tracks the desired configuration and synchronizes the resulting resources to Kubernetes."


53. Interview question: Kustomize + Argo CD?#

Answer:

"Kustomize manages environment-specific Kubernetes customization using bases and overlays, while Argo CD monitors the Git repository and synchronizes the rendered desired state to the cluster."


54. The entire Kubernetes course in one architecture#

Warrior, you've now reached the point where the pieces connect:

                           GIT
                            โ”‚
                            โ†“
                           CI
                            โ”‚
                  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                  โ†“                   โ†“
                Tests             Docker Build
                                      โ”‚
                                      โ†“
                                  Registry
                                      โ”‚
                                      โ†“
                              Deployment Config
                                      โ”‚
                                      โ†“
                                  Argo CD
                                      โ”‚
                              Reconciliation
                                      โ”‚
                                      โ†“
                                Kubernetes
                                      โ”‚
             โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
             โ†“                        โ†“                     โ†“
        Deployment                 Service               Config
             โ”‚                        โ”‚                     โ”‚
             โ†“                        โ†“             ConfigMap/Secret
           Pods                    Networking
             โ”‚                        โ”‚
       โ”Œโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”             Ingress
       โ†“     โ†“     โ†“                โ”‚
      Pod   Pod   Pod               โ†“
                                  Users
       โ”‚
       โ”œโ”€โ”€ HPA
       โ”œโ”€โ”€ Probes
       โ”œโ”€โ”€ RBAC
       โ”œโ”€โ”€ NetworkPolicy
       โ”œโ”€โ”€ Logging
       โ””โ”€โ”€ Monitoring
             โ”‚
             โ†“
       Prometheus/Grafana

And the infrastructure:

Cloud
 โ”‚
 โ”œโ”€โ”€ Compute
 โ”œโ”€โ”€ Networking
 โ”œโ”€โ”€ Load Balancer
 โ”œโ”€โ”€ Registry
 โ”œโ”€โ”€ Storage
 โ”œโ”€โ”€ Database
 โ””โ”€โ”€ Identity

๐Ÿง  Chapter 31 Cheat Sheet#

GitOps
  โ†“
Git = desired state
 
Argo CD
  โ†“
GitOps controller
 
Sync
  โ†“
Bring cluster toward Git state
 
Drift
  โ†“
Git state โ‰  cluster state
 
Self-heal
  โ†“
Reconcile certain manual changes
 
Prune
  โ†“
Remove resources no longer desired
 
Application
  โ†“
Argo CD definition of a deployed application
 
ApplicationSet
  โ†“
Generate many Applications
 
AppProject
  โ†“
Govern Applications
 
Helm
  โ†“
Package/template Kubernetes resources
 
Kustomize
  โ†“
Customize Kubernetes YAML
 
Argo CD
  โ†“
Deploy/reconcile Helm or Kustomize output

The most important mental model:#

                GIT
                 โ”‚
          Desired State
                 โ”‚
                 โ†“
              ARGO CD
                 โ”‚
            Compare State
                 โ”‚
          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”
          โ”‚             โ”‚
       Same          Different
          โ”‚             โ”‚
       Synced          Drift
                        โ”‚
                        โ†“
                    Reconcile
                        โ”‚
                        โ†“
                   Kubernetes

๐ŸŽฏ You have completed Chapter 31#

Only Chapter 32 โ€” Final Production Project remains.

In the final chapter, we'll combine almost everything you've learned into one realistic system:

                    INTERNET
                       โ”‚
                       โ†“
                    Ingress
                       โ”‚
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ†“                 โ†“
         Next.js Frontend    Node.js API
              โ”‚                 โ”‚
              โ”‚          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ”‚          โ†“      โ†“      โ†“
              โ”‚        Redis PostgreSQL Workers
              โ”‚
              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                         โ†“
                    AI Services
                         โ”‚
                 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                 โ†“               โ†“
              Retriever         LLM
                 โ”‚
                 โ†“
              Vector DB

And around it:

Docker
Kubernetes
Helm
Kustomize
HPA
Node Autoscaling
RBAC
NetworkPolicy
Secrets
Persistent Storage
Ingress
Prometheus
Grafana
Centralized Logging
GitHub Actions
Argo CD
AWS/GCP/Azure

Next โ†’ Chapter 32: Build a Production-Style Kubernetes Application ๐Ÿš€

Finished this chapter?

Mark it as complete to track your mastery.

Previous ChapterChapter 30 โ€” Kubernetes + CI/CD ๐Ÿš€Next ChapterChapter 32 โ€” Final Production-Style Kubernetes Project
PrevNext