GitOps for Azure Kubernetes Service
GitOps changes the operational boundary around AKS: the cluster stops being the primary edit surface and becomes the target of a reconciler. That has practical consequences for platform teams: access paths, approval flows, and drift handling need to be designed around the operator, not around direct kubectl edits. In the Flux scenarios, the poll-based model also matters because it removes the need for inbound exposure from build systems to the cluster, which simplifies network trust assumptions and reduces attack surface.
The architecture choice between Flux and Argo CD is less about syntax than control model. Flux fits well when you want native AKS extension management and automated reconciliation from Git or supported artifact sources. Argo CD adds a more visible control plane with UI-driven diffing, history, and manual or automatic sync. That makes it easier to operationalize review and rollback, but it also introduces a management endpoint that should be intentionally isolated behind internal access patterns.
For CI/CD, the real integration point is the manifest update step. GitHub Actions builds and publishes the image, but deployment depends on a separate commit that updates the Kubernetes manifest to the new version. That separation improves auditability, but it also creates a version-coupling requirement: image tags, manifest references, and reconciliation timing must stay aligned or deployments will lag, drift, or roll back unexpectedly.
The policy layer is where GitOps becomes governance rather than just delivery. OPA Gatekeeper and related controls can enforce admission-time rules, while branch protection and signed commits protect the source of truth itself. For multi-cluster operations, this gives teams a repeatable control plane, but it also means repository design, PR workflows, and policy definitions become production-critical assets.
GitOps is a set of principles for operating and managing a software system.ย This article describes techniques for using GitOps principles to operate and manage an Azureย
Architecture
Two GitOps operators that you can use with AKS areย Fluxย andย Argo CD. They’reย Cloud Native Computing Foundation (CNCF)ย projects and are widely used. The following scenarios show ways to use them.Scenario 1: GitOps with Flux and AKS
Download aย Visio fileย of this architecture.
Dataflow for scenario 1
Flux is a nativeย cluster extensionย to AKS. Cluster extensions provide a platform for installing and managing solutions on an AKS cluster. You can use the Azure portal, the Azure CLI, or infrastructure as code (IaC) scripts, such as Terraform or Bicep scripts, to enable Flux as an extension to AKS. You can also use Azure Policy to apply Flux v2 configurations at scale on AKS clusters. For more information, seeย Deploy applications consistently at scale using Flux v2 configurations and Azure Policy. Flux can deploy Kubernetes manifests, Helm charts, and Kustomization files to AKS. Flux is a poll-based process, so it can detect, pull, and reconcile configuration changes without exposing cluster endpoints to your build agents. In this scenario, Kubernetes administrators can change Kubernetes configuration objects, such as secrets and ConfigMaps, and commit the changes directly to a GitHub repository. The data flow for this scenario is:- The developer commits configuration changes to the GitHub repository.
- Flux detects configuration drift in the Git repository, and pulls the configuration changes.
- Flux reconciles the state in the Kubernetes cluster.
Alternatives for scenario 1
- You can use Flux with other Git repositories such as Azure DevOps, GitLab, and BitBucket.
- Instead of Git repositories,ย Flux Bucket APIย defines a source to produce an artifact for objects from storage solutions like Amazon S3 and Google Cloud Storage buckets. You can also use a solution that has an S3-compatible API. Two examples are Minio and Alibaba Cloud OSS, but there are others.
- You can also configure Flux against an Azure Blob Storage container as a source to produce artifacts. For more information, seeย GitOps Flux v2 configurations with AKS and Azure Arc-enabled Kubernetes.
Scenario 2: Use GitOps with Flux, GitHub, and AKS to implement CI/CD
Download aย Visio fileย of this architecture.
Dataflow for scenario 2
This scenario is a pull-based DevOps pipeline for a typical web application. The pipeline uses GitHub Actions for build. For deployment, it uses Flux as the GitOps operator to pull and sync the app. The data flows through the scenario as follows:- The app code is developed by using an IDE such as Visual Studio Code.
- The app code is committed to a GitHub repository.
- GitHub Actions builds a container image from the app code and pushes the container image to Azure Container Registry.
- GitHub Actions updates a Kubernetes manifest deployment file with the current image version that’s based on the version number of the container image in Azure Container Registry.
- The Flux operator detects configuration drift in the Git repository and pulls the configuration changes.
- Flux uses manifest files to deploy the app to the AKS cluster.
Scenario 3: GitOps with Argo CD, GitHub repository and AKS
Download aย Visio fileย of this architecture.
Dataflow for scenario 3
In this scenario, the Kubernetes administrator can change Kubernetes configuration objects, such as secrets and ConfigMaps, and commit the changes directly to the GitHub repository. The data flow for this scenario is:- The Kubernetes administrator makes configuration changes in YAML files and commits the changes to the GitHub repository.
- Argo CD pulls the changes from the Git repository.
- Argo CD reconciles the configuration changes to the AKS cluster.
Alternatives for scenario 3
Any repository that’s compatible with Git, including Azure DevOps, can serve as the configuration source repository.Scenario 4: Use GitOps with Argo CD, GitHub Actions, and AKS to Implement CI/CD
Download aย Visio fileย of this architecture.
Dataflow for scenario 4
This scenario is a pull-based DevOps pipeline for a typical web application. The pipeline uses GitHub Actions for build. For deployment, it uses Argo CD as the GitOps operator to pull and sync the app. The data flows through the scenario as follows:- The app code is developed by using an IDE such as Visual Studio Code.
- The app code is committed to a GitHub repository.
- GitHub Actions builds a container image from the app code and pushes the container image to Azure Container Registry.
- GitHub Actions updates a Kubernetes manifest deployment file with the current image version that’s based on the version number of the container image in Azure Container Registry.
- Argo CD pulls from the Git repository.
- Argo CD deploys the app to the AKS cluster.
Alternatives for scenario 4
Any repository that’s compatible with Git, including Azure DevOps, can serve as the configuration source repository.Scenario 5: Use Syncier Tower and GitOps operator to enforce policies
Download aย Visio fileย of this architecture.
Dataflow for scenario 5
This solution follows a strong GitOps approach.- The single source of truth is the GitHub repository that holds the provisioned AKS cluster configurations. The repository stores all AKS application manifests and all cluster infrastructure desired states. Every change to the cluster happens under version control.
GitHub functionality:
- Ensures review for changes.
- Prevents unintended or unauthorized changes.
- Enforces desired quality checks.
- Flux is the GitOps operator and controller, and is the only component that can make changes to the cluster. Flux pulls cluster desired state changes from GitHub, and syncs them into AKS. Flux:
- Pulls desired changes from GitHub.
- Detects any configuration drift.
- Reconciles the state in the Kubernetes cluster.
- Manages Gatekeeper and the applications.
- Updates itself.
- Open Policy Agent (OPA) Gatekeeper enforces policies with a validating admission webhook. Gatekeeper validates cluster configuration changes against provisioned policies, and applies the changes only if they comply with policies.
- Syncier Security Tower is a GitOps control kit that provides an overview of all AKS clusters and helps manage policies.ย Syncier Security Tower:
- Assembles all cluster images in an overview that shows which versions are deployed and identifies outdated images.
- Provides feedback on policy violations via pull request (PR) feedback before changes are applied.
- Introduces risk acceptance whenever policies aren’t applied for good reasons.
- Provides security policies to OPA Gatekeeper.
Components
The architecture scenarios use one or more of the following components:- AKSย is a highly available, secure, and fully managed Kubernetes service in Azure. In AKS, Azure manages the Kubernetes API server. Cluster owners and operators access and manage the Kubernetes nodes and node pools.
- GitHubย is a code hosting platform for version control and collaboration. GitHub provides Git distributed version control, source code management, and other features.
- Fluxย is a GitOps tool that automates the deployment of applications on Kubernetes. Flux automates configuration updates when there’s new code to deploy. Flux is provided as a native extension to AKS.
- Argo CDย is a declarative GitOps continuous-delivery tool for Kubernetes.
- OPA Gatekeeperย is a project that integrates the open-source OPA admission controller with Kubernetes. Kubernetes admission controllers enforce policies on objects during create, update, and delete operations, and are fundamental to Kubernetes policy enforcement.
- Syncier Security Towerย is a publicly available tool from Syncier that helps overcome GitOps security and compliance challenges. To help ensure that only trusted images run in the cluster, Syncier Security Tower comes with a set of best-practice policies that are grouped according to well-known security standards.
Scenario details
GitOps is a set of principles for operating and managing a software system.- It uses source control as the single source of truth for the system.
- It applies development practices like version control, collaboration, compliance, and continuous integration/continuous deployment (CI/CD) to infrastructure automation.
- You can apply it to any software system.
- Declarative: A system that GitOps manages must have its desired state expressed declaratively. The declaration is typically stored in a Git repository.
- Versioned and immutable: The desired state is stored in a way that enforces immutability and versioning, and retains a complete version history.
- Pulled automatically: Software agents automatically pull the desired state declarations from the source.
- Continuously reconciled: Software agents continuously observe actual system state and attempt to apply the desired state.
GitOps as the single source of truth
GitOps provides consistency and standardization of the cluster state, and can help to enhance security. You can also use GitOps to ensure consistent state across multiple clusters. For example, GitOps can apply the same configuration across primary and disaster recovery (DR) clusters, or across a farm of clusters. If you want to enforce that only GitOps can change the cluster state, you can restrict direct access to the cluster. There are various ways to do this, including Azure role-based access control (RBAC), admissions controllers, and other tools.Use GitOps to bootstrap initial configuration
It’s possible to have a need to deploy AKS clusters as part of the baseline configuration. An example is that you have to deploy a set of shared services or a configuration before you deploy workloads. These shared-services can configure AKS add-ons such as: You can enable Flux as an extension that’s applied when you create an AKS cluster. Flux can then bootstrap the baseline configuration to the cluster. Theย Baseline architecture for an AKS clusterย suggests using GitOps for bootstrapping. If you use the Flux extension, you can bootstrap clusters very soon after you deploy. You can extend the described scenarios to other GitOps tools. Jenkins X is another GitOps tool that provides instructions toย integrate to Azure. You can use progressive delivery tools such asย Flaggerย for gradual shifting of production workloads that are deployed through GitOps.Potential use cases
This solution benefits any organization that wants the advantages of deploying applications and infrastructure as code, with an audit trail of every change. GitOps shields the developer from the complexities of managing a container environment. Developers can continue to work with familiar tools such as Git to manage updates and new features. In this way, GitOps enhances developer productivity.Considerations
These considerations implement the pillars of the Azure Well-Architected Framework, which is a set of guiding tenets that you can use to improve the quality of a workload. For more information, seeReliability
Reliability ensures that your application can meet the commitments that you make to your customers. For more information, seeย Overview of the reliability pillar. One of the key pillars of reliability is resiliency. The goal of resiliency is to return the application to a fully functioning state after a failure occurs. If a cluster becomes unavailable, GitOps can create a new one quickly. It uses the Git repository as the single source of truth for Kubernetes configuration and application logic. It can create and apply the cluster configuration and application deployment as a scale unit and can establish theย deployment stampย pattern.Security
Security provides assurances against deliberate attacks and the abuse of your valuable data and systems. For more information, seeย Overview of the security pillar. With the GitOps approach, individual developers or administrators don’t directly access the Kubernetes clusters to apply changes or updates. Instead, users push changes to a Git repository and the GitOps operator (Flux or Argo CD) reads the changes and applies them to the cluster. This approach follows the security best practice of least privilege by not giving DevOps teams write permissions to the Kubernetes API. In diagnostic or troubleshooting scenarios, you can grant cluster permissions for a limited time on a case-by-case basis. Apart from the task of setting up repository permissions, consider implementing the following security measures in Git repositories that sync to AKS clusters:- Branch protection:ย Protect the branches that represent the state of the Kubernetes clusters from having changes pushed to them directly. Use PRs to make changes, and have at least one other person review every PR. Also, use PRs to do automatic checks.
- PR review:ย Require PRs to have at least one reviewer, to enforce the four-eyes principle. You can also use the GitHub code owners feature to define individuals or teams that are responsible for reviewing specific files in a repository.
- Immutable history:ย Only allow new commits on top of existing changes. Immutable history is especially important for auditing purposes.
- Further security measures:ย Require your GitHub users to activate two-factor authentication. Also, allow only commits that are signed, to prevent changes.
Cost optimization
Cost optimization is about looking at ways to reduce unnecessary expenses and improve operational efficiencies. For more information, seeย Overview of the cost optimization pillar.- On the free tier, AKS offers free cluster management. Costs are limited to the compute, storage, and networking resources that AKS uses to host nodes.
- GitHub offers a free service, but to use advanced security-related features like code owners or required reviewers, you need the Team plan. For more information, see theย GitHub pricingย page.
- Azure DevOps offers a free tier that you can use for some scenarios.
- Use theย Azure pricing calculatorย to estimate costs.
Operational excellence
Operational excellence covers the operations processes that deploy an application and keep it running in production. For more information, seeย Overview of the operational excellence pillar. GitOps can increase DevOps productivity. One of the most useful features is the ability to quickly roll back changes that are behaving unexpectedly, just by performing Git operations. The commit graph still contains all commits, so it can help with the post-mortem analysis. GitOps teams often manage multiple environments for the same application. It’s typical to have several stages of an application that are deployed to different Kubernetes clusters or namespaces. The Git repository, which is the single source of truth, shows which versions of applications are currently deployed to a cluster. You can use Syncier Security Tower to simplify cluster operations. It can extract the application versions that are deployed to multiple clusters from the repository and display the results in a user-friendly way. DevOps teams can use advanced Syncier Security Tower features to get insights into who changed what, and when, in an application. Teams can browse and filter based on factors like change type and resource kind. Syncier Security Tower provides a control center to activate policies and compare compliance state over different clusters.Deploy a scenario
The following list provides references for information about deploying the five scenarios:Contributors
This article is maintained by Microsoft. It was originally written by the following contributors. Principal author: To see non-public LinkedIn profiles, sign in to LinkedIn.Enjoyed this article? Sign up for our newsletter to receive regular insights and stay connected.
