Skip to content
Latchkey

How to Deploy to AKS in Azure Pipelines

The KubernetesManifest task applies your manifests to AKS and substitutes the freshly built image tag.

Create a Kubernetes service connection to your AKS cluster, then use the KubernetesManifest deploy action with containers to set the image.

Deploy manifests with image substitution

The task applies the manifests and replaces the image reference with the tag you built.

azure-pipelines.yml
- task: KubernetesManifest@1
  inputs:
    action: deploy
    connectionType: kubernetesServiceConnection
    kubernetesServiceConnection: aks-prod
    namespace: web
    manifests: |
      manifests/deployment.yml
      manifests/service.yml
    containers: myregistry.azurecr.io/web:$(Build.BuildId)

Notes

  • The Kubernetes service connection holds cluster credentials so the task does not need a raw kubeconfig.
  • containers overrides the image in the manifest with the tag from this build.
  • Use a deployment job with an environment to get AKS resource visibility and approvals.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →