1+ # Azure Kubernetes Service (AKS) pipeline with Kustomize
2+ # Build and push image to Azure Container Registry; Deploy to Azure Kubernetes Service cluster
3+
4+ variables :
5+ armServiceConnection : {{ARMSERVICECONNECTION}}
6+ azureContainerRegistry : {{AZURECONTAINERREGISTRY}}
7+ containerName : {{CONTAINERNAME}}
8+ acrRg : {{CLUSTERRESOURCEGROUP}}
9+ clusterRg : {{ACRRESOURCEGROUP}}
10+ clusterName : {{CLUSTERNAME}}
11+ kustomizePath : {{KUSTOMIZEPATH}}
12+ namespace : {{NAMESPACE}}
13+ tag : " $(Build.BuildId)"
14+ vmImageName : " ubuntu-latest"
15+
16+ trigger :
17+ - {{BRANCHNAME}}
18+
19+ name : {{PIPELINENAME}}
20+
21+ stages :
22+ - stage : BuildAndPush
23+ displayName : Build stage
24+ jobs :
25+ - job : BuildAndPush
26+ displayName : Build and push image
27+ pool :
28+ vmImage : $(vmImageName)
29+ steps :
30+ - task : AzureCLI@2
31+ displayName : Build and push image to Azure Container Registry
32+ inputs :
33+ azureSubscription : $(armServiceConnection)
34+ scriptType : " bash"
35+ scriptLocation : " inlineScript"
36+ inlineScript : |
37+ az acr build --image $1.azurecr.io/$2:$3 --registry $1 -g $4 .
38+ arguments : " $(azureContainerRegistry) $(containerName) $(tag) $(acrRg)"
39+
40+ - stage : Deploy
41+ displayName : Deploy stage
42+ dependsOn : BuildAndPush
43+ jobs :
44+ - job : Deploy
45+ displayName : Deploy to AKS using Kustomize
46+ pool :
47+ vmImage : $(vmImageName)
48+ steps :
49+ - task : KubernetesManifest@1
50+ displayName : Bake Kustomize manifests
51+ inputs :
52+ action : ' bake'
53+ kustomizationPath : $(kustomizePath)
54+ renderType : ' kustomize'
55+ name : ' bake'
56+
57+ - task : KubernetesManifest@1
58+ displayName : Deploy baked manifests to Kubernetes cluster
59+ inputs :
60+ action : ' deploy'
61+ connectionType : ' azureResourceManager'
62+ azureSubscriptionConnection : $(armServiceConnection)
63+ azureResourceGroup : $(clusterRg)
64+ kubernetesCluster : $(clusterName)
65+ namespace : $(namespace)
66+ manifests : $(bake.manifestsBundle)
67+ containers : |
68+ $(azureContainerRegistry).azurecr.io/$(containerName):$(tag)
0 commit comments