Terminal prompt logo for Ali Haidry — alihaidry.dev~/AHAli Haidryalihaidry.dev
Phase 3 of 6Published

GitOps with Argo CD

The cluster state lives in a second repository. Argo CD watches it and reconciles, and nobody applies manifests by hand.

Argo CDHelmEnvoy Gatewaycert-managerKubernetesUpdated Nov 2026

Goal

What this phase delivers

A GitOps loop where a commit is the only way to change the cluster: an Argo CD app-of-apps, a Helm chart with three environments, a Gateway API entry point and trusted HTTPS certificates that renew themselves.

  • App of appsOne root Application points at child Applications for the platform and for each environment.Done
  • Helm chartOne chart, three values files: dev, staging and prod.Done
  • Gateway APIEnvoy Gateway routes /api and /ws to the api and everything else to the web app.Done
  • Automatic TLScert-manager issues and renews Let's Encrypt certificates.Done
  • Self-healManual changes to the cluster are reverted to what Git says.Done

Steps and commands

Run these in dev first. Every step has a check that proves it worked, so you are never guessing.

  1. Build and push the images

    az acr build uploads the source and builds inside Azure, so you do not need Docker on your machine.

    $ az acr build -r paktechacr -t paktech-chat-api:$TAG .
    $ az acr repository show-tags -n paktechacr --repository paktech-chat-api -o tsv
    Check: the tag appears for both the api and web repositories.
  2. Lint and render the chart

    Catch template mistakes before Argo CD finds them in the cluster.

    $ helm lint charts/paktech-chat -f environments/dev/values.yaml
    $ helm template dev charts/paktech-chat -f environments/dev/values.yaml | head -60
    Check: helm lint reports 0 charts failed and the template prints valid YAML.
  3. Install Argo CD and apply the root app

    This is the one thing you apply by hand. After it, Git drives everything.

    $ kubectl -n argocd rollout status deploy/argocd-server --timeout=5m
    $ kubectl apply -f bootstrap/root-app.yaml
    $ kubectl -n argocd get applications -w
    Check: the child applications appear and turn Synced and Healthy.
  4. Check the gateway and the certificates

    The edge resources must be programmed before TLS can be issued.

    $ kubectl get gatewayclass
    $ kubectl get gateway -n edge
    $ kubectl get certificate -A
    Check: the gateway is Programmed and every certificate is Ready.
  5. Prove self-heal

    Change the cluster by hand and watch Argo CD undo it.

    $ kubectl -n paktech-chat-dev patch deployment web -p '{"spec":{"replicas":3}}'
    $ kubectl -n paktech-chat-dev get deploy web -w
    Check: the deployment returns to one replica within seconds, with no Git change.

Workflow

A change reaches the cluster only through Git. Sync waves order the work inside Argo CD.

  1. STEP 1CommitTo the GitOps repo
  2. STEP 2Argo CDDetects the change
  3. STEP 3RenderHelm chart + values
  4. STEP 4SyncIn wave order
  5. STEP 5HealthyPods ready

Rollback: Revert the commit in the GitOps repository. Argo CD reconciles the cluster back to it.

Diagram

The GitOps loop: Git is the source of truth, Argo CD reconciles the cluster
Figure: the GitOps loop.
Request path through the gateway to the app
Figure: the request path through Envoy Gateway. Only /api and /ws reach the api.
Argo CD tiles: platform applications and the dev environment, all healthy
Figure: Argo CD with the platform applications and the dev environment healthy.
Two users chatting in real time through the gateway
Figure: the browser proof. Two users, two windows, a message arriving live over wss.

Issues met

These are real, from the run. The surprises are the useful part.

az acr build sat on "Packing source" for more than ten minutes
Cause
The upload included about 1 GB of node_modules and .next, because the CLI packer ignores trailing-slash folder rules in .dockerignore.
Fix
Removed the trailing slashes and added a frontend .dockerignore. Builds dropped to about two minutes.
The migrate Job crashed with "redis_port Input should be a valid integer"
Cause
Kubernetes injects service-link variables such as REDIS_PORT=tcp://..., and the app reads REDIS_PORT as a number.
Fix
enableServiceLinks: false on every pod.
cert-manager stayed OutOfSync while Healthy
Cause
The AKS admissions enforcer adds namespace selectors to every webhook, so Git never matches the live object.
Fix
Read the exact fields in the Argo CD diff and ignored only those with jqPathExpressions.
Certificates were Ready but browsers rejected them
Cause
The Gateway still used the Let's Encrypt staging issuer.
Fix
Switched to the production issuer, deleted the four TLS secrets and let cert-manager reissue them.

Trade-offs

Ingress controller or Gateway API
I chose: Envoy Gateway with the Gateway API

Why: ingress-nginx is being retired and the Gateway API is the direction Kubernetes is moving. It also makes it easy to expose only /api and /ws.

It costs: Newer API, fewer examples, and a few more resources to understand.

Ignoring drift in Argo CD
I chose: Ignore only the exact field that drifts

Why: A broad ignore rule hides real drift along with the harmless kind.

It costs: You have to read the diff and write a precise jqPathExpression.

Interview questions

What does GitOps change about how you deploy?
The repository is the only way in. Argo CD reconciles the cluster to it, reverts manual changes and gives you history and rollback for free.
What is the app-of-apps pattern for?
One root Application owns the child Applications, so bootstrapping a whole cluster is a single apply, and ordering is handled with sync waves.
An app is OutOfSync but Healthy. What do you do?
Read the diff. If a controller mutates a field you do not own, ignore that exact field. Never ignore more than the field that drifts.