Deploy from Git with Flux

DevOps, Hands On30 minutesCosts moneySteps checked 14 November 2026By Cloud Hands On

In this task you'll make the cluster deploy what's in a Git repository.

With GitOps the cluster pulls its desired state from Git and keeps applying it. Nobody runs kubectl against production: changes are pull requests, and a rollback is a revert.

On AKS, Flux is an extension Azure installs and updates. A Flux configuration names the repository, branch and path; prune removes things deleted from Git.

Example. Fernhill Cloud's platform team merges a change to the cluster repository; within a few minutes every cluster that follows it has the change, and the commit is the audit trail.

Costs money. This task creates resources that are charged while they exist. Delete them as soon as you finish.

Before you start

You need: An AKS cluster. Time: 30 minutes.

Where to look

  1. Home
  2. Kubernetes services
  3. (cluster)
  4. Settings
  5. GitOps

Steps

  1. Register the provider and add the CLI extensions: Microsoft.KubernetesConfiguration, k8s-extension and k8s-configuration.
  2. Install Flux: az k8s-extension create --extension-type microsoft.flux --name flux --cluster-type managedClusters -g <group> -c <cluster>.It can take 10 minutes.
  3. Create a configuration pointing at a repository, branch and path, with prune=true. Use --scope cluster if the path creates namespaces or cluster-wide objects; a namespace-scoped configuration may only touch its own namespace.
  4. az k8s-configuration flux show ... --query complianceState until Compliant.

Commands

az k8s-extension create --extension-type microsoft.flux --name flux --cluster-type managedClusters -g <group> -c <cluster>
az k8s-configuration flux create -g <group> -c <cluster> -t managedClusters -n podinfo --namespace cluster-config --scope cluster -u https://github.com/stefanprodan/podinfo --branch master --kustomization name=app path=./deploy/webapp prune=true

Watch out for

Cost
The extension is free; you pay for the cluster.
Security
Protect the repository's main branch: whoever can push to it can change production.
Common mistakes
Changing things with kubectl on a GitOps cluster (Flux puts them back), and forgetting prune.

Clean up

az k8s-configuration flux delete and az k8s-extension delete, or delete the cluster.

Words to know

GitOps
Git as the single source of truth, applied by an agent in the cluster.
Kustomization
Flux's object that applies a path from the repository.
Prune
Delete cluster objects that were removed from Git.

Tick off each step and track your progress in the guide.

Open this task in DevOps, Hands On

Keep going