Covers GitOps principles, pull-based reconciliation with Flux and Argo CD, drift detection and self-heal, image promotion through a config repo, secrets in GitOps, AKS's Flux extension, and when push-based pipelines are the better choice.
GitOps means the desired state of the cluster is declared in Git, and an agent running inside the cluster (Flux or Argo CD) pulls it and continuously reconciles live objects to match. CI builds and pushes the image; deployment happens when someone merges a change to the config repo (for example bumping the image tag in the prod overlay).
kubectl edits.git revert.The trade-off: GitOps adds a controller, a config repo and secret tooling, which pays off for many services on Kubernetes but is overkill for one App Service app.
"GitOps is a set of principles: the system is described declaratively, that description is versioned in Git, an agent pulls it automatically, and it continuously reconciles the live system to match. On Kubernetes the agent is usually Flux or Argo CD, both CNCF graduated projects. The pipeline builds and tests the .NET service and pushes an image to Azure Container Registry, and that is where CI stops. Deploying is a commit to the configuration repo that changes the image tag for an environment. Flux or Argo CD sees the new commit, applies the manifests, and keeps checking.
The difference from a push pipeline is who holds the keys and what happens after the deploy. In a push model, GitHub Actions has credentials to the cluster and runs
kubectl applyorhelm upgradeonce. In GitOps, the controller inside the cluster has the rights, and CI has none. And because it reconciles every few minutes, if someonekubectl edits a deployment in production, Argo CD shows the app as OutOfSync and, withselfHealon, puts it back. Promotion is a pull request against the prod overlay, so the audit trail is the Git history, and rollback isgit revert.The parts people get wrong are secrets and ordering. You never commit plain Kubernetes secrets; I use the External Secrets Operator reading from Key Vault with workload identity, or Sealed Secrets or SOPS. And database migrations still need a plan, like a pre-sync hook or a migration job. GitOps isn't worth it if you run one service on App Service; there is no cluster to reconcile and a normal pipeline with slots is simpler."
| Push (pipeline deploys) | Pull (GitOps) | |
|---|---|---|
| Who applies | CI runner with cluster credentials | Controller inside the cluster |
| Drift handling | None until the next deploy | Detected every interval; optional self-heal |
| Audit trail | Pipeline logs | Git history of the config repo |
| Rollback | Re-run an old pipeline | git revert |
| Works for App Service / Functions | Yes | Not really (Kubernetes-centric) |
| Flux v2 | Argo CD | |
|---|---|---|
| Model | Set of controllers and CRDs (GitRepository, Kustomization, HelmRelease) | Application CRD plus API server and UI |
| UI | None built in (third-party UIs exist) | Rich web UI, diff view, sync history |
| Azure integration | Managed AKS GitOps extension (az k8s-configuration flux) |
Self-installed (Helm), or vendor offerings |
| Image automation | Built-in image reflector/automation controllers | Argo CD Image Updater (separate) |
| Multi-cluster | One Flux per cluster, typical | One Argo CD can manage many clusters |
With [around 20] services on AKS, moving from helm upgrade in pipelines to Flux removed cluster credentials from CI entirely and caught [several] manual hot-fixes a month that previously disappeared on the next deploy. A bad release was rolled back by reverting one commit; Flux reconciled in under two minutes.
Checks that the candidate understands pull-based reconciliation, how drift and rollback work, and the practical issues of secrets and promotion.
Green flags
Red flags
latest tags or keeps kubectl apply in CI alongside the controller app repo ─► CI: dotnet test, docker build ─► push orders-api:1.8.0 to ACR
│
└─► PR to config repo: apps/orders-api/overlays/test image tag = 1.8.0
config repo (main) ◄── poll / webhook ── Flux source-controller (in cluster)
│
kustomize-controller: build + server-side apply
│
live Deployment, Service, ...
│
every interval: diff live vs desired ─► correct drift
The controller periodically renders the manifests from Git and compares them with live objects using server-side apply field ownership. Differences mean drift:
automated.selfHeal: true resyncs it, automated.prune: true deletes objects removed from Git.interval, and prune: true removes objects no longer in the source.Fields legitimately changed by other controllers (for example replicas managed by an HPA) must be ignored (ignoreDifferences in Argo CD, or leaving replicas out of the manifest) or the two will fight.
Common layouts:
config-repo/
apps/orders-api/base/ (Deployment, Service, probes, resources)
apps/orders-api/overlays/dev/ (image tag, replicas, ConfigMap values)
apps/orders-api/overlays/test/
apps/orders-api/overlays/prod/
clusters/aks-prod-aue/ (which apps this cluster runs)
Promotion is a PR changing the tag in the next overlay, with approval rules on the prod path (CODEOWNERS, branch protection). Flux image automation can write tag bumps for dev automatically; keep prod manual.
Git must never hold plain secrets. Options:
| Tool | How |
|---|---|
| External Secrets Operator | ExternalSecret points at Azure Key Vault; operator uses workload identity and creates the Kubernetes Secret |
| Secrets Store CSI driver | Mounts Key Vault secrets as files (AKS add-on) |
| Sealed Secrets / SOPS | Encrypted in Git, decrypted in cluster |
Better still, the .NET app uses workload identity and DefaultAzureCredential to reach Azure services directly, so fewer secrets exist at all.
GitOps applies manifests; it does not know your database. Options: an EF Core migration bundle run as a Kubernetes Job with an Argo CD PreSync hook (or Flux dependsOn between Kustomizations), always backward-compatible (expand, then contract).
flux bootstrap github, and deploy a sample .NET API from a config repo.kubectl edit the deployment's image and watch Flux (or Argo CD with selfHeal) revert it; time how long it takes.prune: true and confirm it is deleted.ExternalSecret that reads a Key Vault secret with workload identity.git revert and observe the reconciliation events (flux get kustomizations, kubectl events).Flux and Argo CD definitions for the same service, plus the CI step that promotes an image.
# Flux v2: where to pull from, and what to apply
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
name: platform-config
namespace: flux-system
spec:
interval: 1m
url: https://github.com/contoso/platform-config
ref:
branch: main
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: orders-api-prod
namespace: flux-system
spec:
interval: 10m # re-check for drift even without new commits
path: ./apps/orders-api/overlays/prod
prune: true # delete objects removed from Git
wait: true # healthy only when the rollout finishes
timeout: 5m
sourceRef:
kind: GitRepository
name: platform-config
# Argo CD: the equivalent Application
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: orders-api-prod
namespace: argocd
spec:
project: orders
source:
repoURL: https://github.com/contoso/platform-config
targetRevision: main
path: apps/orders-api/overlays/prod
destination:
server: https://kubernetes.default.svc
namespace: orders
syncPolicy:
automated:
prune: true
selfHeal: true # revert manual kubectl edits
syncOptions:
- CreateNamespace=true
ignoreDifferences:
- group: apps
kind: Deployment
jsonPointers: [ /spec/replicas ] # owned by the HPA, not Git
# GitHub Actions job in the app repo: CI stops at a PR to the config repo
promote-test:
needs: build-and-push
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: contoso/platform-config
token: ${{ secrets.CONFIG_REPO_TOKEN }} # fine-grained token, contents + PRs only
- name: Bump image tag in the test overlay
run: |
cd apps/orders-api/overlays/test
kustomize edit set image orders-api=myacr.azurecr.io/orders-api:${{ github.sha }}
- uses: peter-evans/create-pull-request@v7
with:
title: "orders-api ${{ github.sha }} to test"
branch: promote/orders-api-test-${{ github.sha }}
# AKS managed Flux extension: install and point it at the config repo
az k8s-configuration flux create \
--resource-group rg-aks-prod --cluster-name aks-prod-aue --cluster-type managedClusters \
--name platform-config --namespace flux-system \
--url https://github.com/contoso/platform-config --branch main \
--kustomization name=orders-prod path=./apps/orders-api/overlays/prod prune=true
kubectl apply in CI as well as running Flux or Argo CD. Why it is wrong: Two writers fight, and CI still holds cluster credentials. Instead: CI builds and opens a PR; only the controller applies.latest tag in manifests. Why it is wrong: Git does not change when the image does, so the controller has nothing to reconcile, nodes may run different images depending on when they pulled, and Git history no longer tells you what was running. Rollback is still possible by other means (re-tagging, pinning a digest by hand), but it is no longer a simple git revert. Instead: Immutable tags or digests, bumped by commits.replicas while an HPA scales the deployment. Why it is wrong: Self-heal keeps resetting the replica count. Instead: Omit replicas or ignore the field.prune without protecting stateful objects. Why it is wrong: Prune deletes whatever is no longer in the rendered manifests, so moving a PersistentVolumeClaim, StatefulSet or namespace to another path, or a broken Kustomize overlay that renders nothing, can delete data. Instead: Disable pruning on stateful resources (kustomize.toolkit.fluxcd.io/prune: disabled, Argo CD Prune=false sync option), set the PV reclaim policy to Retain, and require review on PRs that remove resources.dependsOn, using backward-compatible migrations.GitOps is really about where the authority to change production lives. Moving it from CI runners to an in-cluster controller and a reviewed Git repo reduces credential exposure, gives a complete audit trail and makes drift visible, which auditors and Essential Eight-minded security teams like. The price is more moving parts: a controller to upgrade, a config repo to keep tidy, and secret tooling.
It also does not remove the need for progressive delivery: combine it with Argo Rollouts or Flagger for canaries, and keep deploy and release separate with feature flags.
| Option | When it fits | Cost | When not to |
|---|---|---|---|
Push pipeline (helm upgrade) |
Few services, small team | CI holds cluster credentials, no drift correction | Many clusters or strict audit |
| Flux | AKS with the managed extension, platform teams happy with CLI | No built-in UI | Teams who need a visual diff and sync UI |
| Argo CD | Many clusters, developers want a UI | Another server to secure and upgrade | One small cluster |
Measure it with deployment frequency, lead time from merge to running, number of drift corrections per week, and time to roll back.
Helm is the package manager for Kubernetes. A chart is a set of manifest templates (Go templating) plus a values.yaml of defaults. You install it as a release, overriding values per environment with files like values-prod.yaml. Helm stores each revision in the cluster, so helm upgrade --install --atomic deploys and helm rollback returns to an earlier revision. Charts are versioned and pushed to OCI registries such as Azure Container Registry.
Kustomize takes the opposite approach: plain YAML bases with environment overlays and patches, no templating, built into kubectl apply -k.
I use Helm when a chart is shared across many services or for third-party software, and Kustomize for simple in-house overlays. The trade-off: Helm's power versus template complexity.
Kubernetes runs containers from declarative desired state. A pod is the smallest unit: one or more containers sharing an IP and volumes, and it is disposable. A deployment says "run 3 replicas of this image" and manages ReplicaSets to do rolling updates and rollbacks. A service gives those changing pods a stable DNS name and virtual IP and load-balances across them. Ingress (or the newer Gateway API) routes external HTTP traffic and terminates TLS.
Configuration comes from ConfigMaps and secrets, injected as environment variables or files, which ASP.NET Core reads through IConfiguration. Probes call your health endpoints.
The trade-off: huge flexibility and portability, at the cost of a lot of moving parts to run.
Rolling replaces instances in batches: no extra capacity, but old and new versions serve traffic together and rolling back means another rollout. Blue-green runs a full second environment and switches all traffic at once; rollback is switching back. Canary sends a small share of traffic (say 5%) to the new version, compares error rate and latency, then widens or aborts. App Service deployment slots are blue-green in a box: deploy to staging, warm it up, swap, and swap back to roll back.
The catch is the same for all of them: for a while two versions run against one database, so schema changes must be expand/contract and backward compatible. The trade-off is cost and complexity (blue-green and canary) against blast radius and rollback speed.
How to tell it (STAR)
**S:** At [company] we deployed [around 20] services to AKS with `helm upgrade` from CI, and incident fixes made with `kubectl` kept disappearing on the next release. **T:** I [proposed / led] moving to GitOps so production matched Git and CI no longer needed cluster credentials. **A:** I set up the AKS Flux extension with a config repo and overlays per environment, moved secrets to External Secrets with Key Vault, removed the kubeconfig from GitHub, and changed the incident runbook so hot-fixes were fast-tracked PRs. **R:** Repeat incidents from reverted fixes dropped to [zero] over [period], CI held no cluster credentials, and rollback went from [N minutes] to a revert reconciled in about [2] minutes.
Last updated 23 Nov 2026.