📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

📚 Interview question

What is GitOps, and how do Flux or Argo CD deploy a .NET service to Kubernetes? Explain pull-based versus push-based deployment, how drift is detected and corrected, how a new image version gets promoted between environments, and when GitOps is not worth it.

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.

Mid-Level Theory Intermediate argo-cd devops flux gitops infrastructure-as-code kubernetes

🎯 Key points

  • GitOps: desired state declared in Git, versioned, pulled and continuously reconciled by an agent
  • Pull-based: an in-cluster controller (Flux or Argo CD) pulls from Git; CI never holds cluster credentials
  • Drift: controller compares live objects with Git; Argo CD selfHeal / Flux reconciliation reverts manual kubectl edits
  • prune deletes anything removed from Git, including PVCs and namespaces: disable pruning on stateful objects and review deletes
  • Promotion = a PR that bumps an immutable image tag or digest in the env overlay; rollback = git revert
  • Migrations are not ordered by reconciliation: migration Job via PreSync hook or Flux dependsOn, backward-compatible schema
  • Secrets never in plain Git: External Secrets Operator with Key Vault, Sealed Secrets or SOPS; controller scoped with Kubernetes RBAC and Argo CD projects per team/namespace
  • AKS offers a managed Flux v2 extension; GitOps fits many services on Kubernetes, not one App Service app

⏱ 30-second answer

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).

  • Drift is detected because the controller compares live state with Git every few minutes, and self-heal reverts manual kubectl edits.
  • Rollback is a git revert.
  • CI never holds cluster credentials, which shrinks the attack surface.

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.

🗣 Full answer (senior)

How I would answer this in an interview

"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 apply or helm upgrade once. In GitOps, the controller inside the cluster has the rights, and CI has none. And because it reconciles every few minutes, if someone kubectl edits a deployment in production, Argo CD shows the app as OutOfSync and, with selfHeal on, puts it back. Promotion is a pull request against the prod overlay, so the audit trail is the Git history, and rollback is git 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 vs pull

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 vs Argo CD

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

Production example

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.

🔍 What the interviewer is checking

Checks that the candidate understands pull-based reconciliation, how drift and rollback work, and the practical issues of secrets and promotion.

Green flags

  • Explains pull versus push and why CI no longer needs cluster credentials
  • Describes drift detection, self-heal and prune, including the HPA replicas conflict
  • Promotion and rollback via Git commits; immutable image tags
  • Has a real answer for secrets (External Secrets with Key Vault, SOPS)

Red flags

  • Thinks GitOps just means 'the YAML is in Git'
  • Plain secrets in the config repo
  • Uses latest tags or keeps kubectl apply in CI alongside the controller

📚 Learn in depth

1. The four GitOps principles (OpenGitOps)

  1. Declarative: the desired state is expressed as data (YAML, Helm values, Kustomize overlays).
  2. Versioned and immutable: stored in Git, with history.
  3. Pulled automatically: agents fetch the desired state.
  4. Continuously reconciled: agents observe actual state and correct it.

2. The flow

 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

3. Reconciliation and drift

The controller periodically renders the manifests from Git and compares them with live objects using server-side apply field ownership. Differences mean drift:

  • Argo CD marks the app OutOfSync; automated.selfHeal: true resyncs it, automated.prune: true deletes objects removed from Git.
  • Flux Kustomizations reapply on every 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.

4. Promotion between environments

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.

5. Secrets

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.

6. Ordering and migrations

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).

7. When not to use it

  • No Kubernetes (App Service, Functions, Container Apps without a cluster you control).
  • One or two services with a simple pipeline.
  • Teams without capacity to run the controller, secret tooling and config repo hygiene.

Try it yourself

  1. Create a kind or AKS cluster, install Flux with flux bootstrap github, and deploy a sample .NET API from a config repo.
  2. kubectl edit the deployment's image and watch Flux (or Argo CD with selfHeal) revert it; time how long it takes.
  3. Remove the Service from Git with prune: true and confirm it is deleted.
  4. Add an ExternalSecret that reads a Key Vault secret with workload identity.
  5. Roll back a release with git revert and observe the reconciliation events (flux get kustomizations, kubectl events).

💻 Code

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

⚠ Common mistakes

  • Mistake: Committing plain Kubernetes Secrets to the config repo. Why it is wrong: Base64 is not encryption; the secret is in Git history forever. Instead: External Secrets Operator with Key Vault, Sealed Secrets or SOPS, and managed identity where possible.
  • Mistake: Keeping 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.
  • Mistake: Using the 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.
  • Mistake: Letting Git manage 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.
  • Mistake: Turning on 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.
  • Mistake: Giving the GitOps controller cluster-admin for every team. Why it is wrong: One team's config repo can then change another team's namespace or cluster-wide objects. Instead: Argo CD projects or Flux tenant service accounts limited to their namespaces with Kubernetes RBAC.
  • Mistake: Auto-promoting to production with image automation. Why it is wrong: No human or test gate before customers see it. Instead: Automate dev; promote to prod by reviewed PR.
  • Mistake: Treating GitOps as a migration tool. Why it is wrong: Reconciliation does not order database changes. Instead: A migration Job with a PreSync hook or dependsOn, using backward-compatible migrations.

🏛 Senior insight: trade-offs

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.

🔗 Follow-ups the interviewer may ask

  1. When: Candidate mentions Helm releases or Kustomize overlays. Why: Checks how Helm charts or Kustomize overlays fit into the config repo that GitOps reconciles.
    How to answer

    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.

  2. When: Candidate mentions deployments, services or ConfigMaps being reconciled. Why: Checks the Kubernetes object basics that Flux or Argo CD apply.
    How to answer

    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.

  3. When: Candidate mentions rollback or progressive delivery. Why: Checks how canary or blue-green releases are layered on top of GitOps.
    How to answer

    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.

🛠 Real-world problems: how you handle them

Manual hot-fixes vanishing on every deploy
Situation
[Company] ran [around 20] .NET services on AKS in Australia East, deployed by `helm upgrade` from GitHub Actions. On-call engineers sometimes patched production with `kubectl` during incidents.
Signals
A memory limit raised during an incident reverted on the next release and the pod was OOMKilled again; Helm release history did not match what was running; security review flagged a long-lived kubeconfig secret in GitHub.
Investigation
Compared `helm get values` and `kubectl get deploy -o yaml` against the chart; reviewed the AKS audit logs in Log Analytics (KQL on `AKSAudit`) to find who changed what; listed which pipelines held cluster-admin credentials.
Resolution
Immediate: committed the raised limit to the chart and rotated the kubeconfig. Long term: installed the AKS Flux extension, moved manifests to a config repo with per-environment overlays, removed cluster credentials from CI, moved secrets to External Secrets Operator with Key Vault and workload identity, and gave humans read-only access in prod with a break-glass group.
Prevention
Branch protection and CODEOWNERS on the prod overlays; alerts when a Kustomization is not Ready; weekly report of drift corrections; runbook saying incident fixes are made by PR (fast-tracked), not `kubectl edit`.

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.

More in Infrastructure as Code

Last updated 23 Nov 2026.

🌐 Sangam's Webring

⏪ Previous 🏠 Main Next ⏩
💬 Chat with me