Git is where my team keeps the truth about what should run in Kubernetes. Not in a wiki. Not in a chat thread. In Git.

That is GitOps. The state you want lives in a repo. A tool watches that repo and makes the cluster match it. When you want a change, you open a pull request. When it merges, the cluster follows.

What GitOps really means

GitOps has two parts. Git is the source of truth for the desired state. A controller in the cluster pulls that state and applies it.

The pull model matters. In a push model, a CI job runs kubectl apply from outside the cluster, then stops watching. If someone changes a resource by hand, nothing notices until the next deploy.

In a pull model, Argo CD runs inside the cluster, reads the repo on a schedule, and syncs the cluster when Git differs.

One repo holds app code, another holds deployment config: Helm charts, Kustomize overlays, and Argo CD Application files.

Nothing deploys without a commit. That gives you a full history of every change. You can see who changed what, when, and why. You can review a deploy the same way you review code.

Helm: packaging the app

Raw Kubernetes YAML gets long fast. Multiply one service by ten services and three environments and you have a mess.

Helm packages those files into a chart. A chart is a set of templates plus a values file. The templates have placeholders. The values file fills them in.

# values.yaml replicaCount: 2 image: repository: my-registry/orders-api tag: "1.4.2" resources: requests: cpu: 200m memory: 256Mi 

The Deployment template uses those values for the replica count, the image, and the resources. One chart can serve many environments. You keep a base values file, then add one values file per environment. Dev gets one replica and small limits. Prod gets three replicas and higher limits. The chart stays the same. Only the values change.

helm upgrade --install orders-api ./charts/orders-api \ --namespace orders \ --values charts/orders-api/values.yaml \ --values charts/orders-api/values-prod.yaml 

Helm alone still uses a push model. That is where Argo CD comes in.

Keep charts simple. If a value is only used once, hardcode it in the template. If it changes per environment, put it in values.

Kustomize: overlays without templates

Helm fits when you need templating and packaging. Kustomize fits when you already have plain YAML and you want small changes per environment.

Kustomize works with a base and overlays. The base holds the common files. Each overlay patches the base. You do not copy the whole Deployment three times. You write the base once, then each overlay changes only what is different.

A prod overlay patches the replica count and the image tag:

# overlays/prod/kustomization.yaml resources: - ../../base images: - name: my-registry/orders-api newTag: "1.4.2" patches: - target: {kind: Deployment, name: orders-api} patch: |- - op: replace path: /spec/replicas value: 3 

Build it with kubectl kustomize overlays/prod. Kustomize is built into kubectl. It is plain YAML, easy to review.

Helm and Kustomize are not rivals. I have used Helm for packaged apps with lots of options, and Kustomize for plain manifests that need small patches. Argo CD supports both. Pick the one that keeps the diff small and the review clear.

Argo CD: the pull loop

Argo CD is a controller that lives in the cluster. You tell it which repo and path to watch, and which namespace to sync into. It pulls on a schedule and compares Git with the live cluster.

An Application manifest is the unit of work in Argo CD:

# argocd/orders-api-prod.yaml apiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: orders-api-prod namespace: argocd spec: source: repoURL: https://github.com/example-org/gitops-config.git targetRevision: main path: apps/orders-api/overlays/prod destination: server: https://kubernetes.default.svc namespace: orders syncPolicy: automated: {prune: true, selfHeal: true} 

The source points at a repo, a branch, and a path. The destination points at a cluster and a namespace. The sync policy says what to do when Git and the cluster differ.

Automated sync means Argo CD applies changes without a human clicking a button. Prune means it deletes resources removed from Git. Self-heal means it fixes resources changed by hand in the cluster. Those three settings give you the pull loop.

The UI shows each Application as Synced or OutOfSync, with the diff and sync history.

Argo CD also supports Helm directly. Point the source at a chart path and pass values files in the Application spec. That keeps one pattern for both Helm and Kustomize apps.

Promoting the same image across environments

A common mistake is to rebuild the image for each environment. Do not do that. Build once. Promote the same image.

CI builds the image from a commit and tags it with the commit SHA or a version number. That image goes to dev first. If dev looks good, the same tag moves to staging. If staging looks good, the same tag moves to prod.

Only the tag in the config repo changes between environments. The code, the layers, and the tests are the same. That removes a whole class of "it worked in staging" surprises.

Dev syncs fast. Prod syncs only after review.

Use fixed tags, not latest. A tag like latest moves under you. You cannot tell which build is running. A commit SHA or a version like 1.4.2 is fixed. You can trace it back to the code that built it.

Secrets do not belong in Git

Git is the source of truth for config. It is not the place for plain secrets. A repo with a database password in a YAML file is a breach waiting to happen.

Two patterns work well. Pick one and use it everywhere.

Sealed Secrets encrypts a secret into a SealedSecret object. You commit the encrypted object. Only the controller in the cluster can decrypt it. The encrypted value is safe to store in Git.

External Secrets takes the other path. You store the secret in a vault or a cloud secret manager. You commit an ExternalSecret object that names the secret. The controller fetches the value at runtime. Git holds a pointer, not the value.

apiVersion: external-secrets.io/v1beta1 kind: ExternalSecret metadata: name: orders-api-secrets spec: secretStoreRef: {name: vault-store, kind: SecretStore} target: {name: orders-api-secrets} data: - secretKey: db-password remoteRef: {key: orders-api/db-password} 

Either pattern works. What does not work is a plain Secret in Git, or a secret pasted into a values file. Keep the rule simple: if it is a password, a token, or a key, it never goes into a commit in plain text. Rotate them on a schedule.

Drift, self-heal, and rollback

Drift happens. Someone runs kubectl edit during an incident and forgets to revert it. Someone changes a replica count by hand to handle a spike.

Without GitOps, that drift stays, and the next deploy may wipe out the hand fix.

With self-heal on, Argo CD notices the drift and puts the resource back to the Git state. If a hand change was right, it should go into Git as a pull request. If it was a quick fix, it should be reverted once the incident is over.

You can still edit by hand in an incident, then make the Git change right after. Turn on drift alerts too.

Rollbacks are where GitOps pays for itself. In a push model, a rollback is a special action. In GitOps, a rollback is a Git revert. Find the commit that caused the problem. Revert it. Merge the revert. Argo CD syncs the old state back.

git log --oneline -10 -- apps/orders-api/overlays/prod git revert <bad-commit-sha> git push origin main 

The revert is reviewed like any other change. It only helps if the change was in Git.

Putting it together

Here is a layout that has worked for me across AKS and GKE, and across Azure, AWS, and GCP:

gitops-config/ apps/orders-api/base/deployment.yaml apps/orders-api/overlays/prod/kustomization.yaml argocd/orders-api-prod.yaml 

Each app has its own folder. Each environment has its own overlay or values file, and its own Argo CD Application. Start with one app and one environment. Get the loop working: commit, sync, verify. Then add staging, then prod. Then add the second app. Do not try to convert everything at once.

For Spring microservices on Google Cloud, running on Cloud Run and GKE, this same pattern holds. The image build happens in CI. The config repo holds the Helm chart or the Kustomize overlay. Argo CD syncs it into GKE. Terraform fits the same idea: it keeps cloud resources in code, GitOps keeps cluster workloads in Git.

Checklist

  • Git holds the desired state, and nothing deploys without a commit.
  • Argo CD watches the config repo, one Application per app per environment.
  • Automated sync, prune, and self-heal are on.
  • Helm or Kustomize keeps per-environment diffs small and reviewable.
  • The same image tag is promoted dev to staging to prod, with no rebuilds.
  • Image tags are fixed versions or commit SHAs, never latest.
  • Secrets live in a vault or as sealed values, never plain text in Git.
  • A rollback is a Git revert, tried once in a safe environment.
  • Drift alerts go to the team, and hand edits are followed by a Git change.
  • The repo layout is simple enough to find a service in a minute.

If you cannot check all ten, fix the missing one first.

Next in this series: "Scaling and Staying Up: HPA, Probes, and Safe Rollouts". I will cover how the HorizontalPodAutoscaler reacts to load, how readiness and liveness probes keep bad pods out of traffic, and how to roll out a new version without dropping requests.