2121# - AZURE_CONTAINER_REGISTRY (name of your container registry / ACR)
2222# - CONTAINER_NAME (name of the container image you would like to push up to your ACR)
2323# - CLUSTER_RESOURCE_GROUP (where your cluster is deployed)
24- # - CLUSTER_NAME (name of your AKS cluster )
24+ # - CLUSTER_RESOURCE_TYPE (type of resource to deploy to, either 'Microsoft.ContainerService/fleets' or 'Microsoft.ContainerService/managedCluster' )
2525# - DOCKER_FILE (path to your Dockerfile)
2626# - BUILD_CONTEXT_PATH (path to the context of your Dockerfile)
2727# - NAMESPACE (namespace to deploy your application)
28+ # - RESOURCE_NAME (name of your AKS resource)
2829#
2930# 3. Choose the appropriate render engine for the bake step https://github.com/Azure/k8s-bake. The config below assumes Kustomize.
3031# Set your kustomizationPath and kubectl-version to suit your configuration.
4647 AZURE_CONTAINER_REGISTRY : {{ .Config.GetVariableValue "AZURECONTAINERREGISTRY" }}
4748 CONTAINER_NAME : {{ .Config.GetVariableValue "CONTAINERNAME" }}
4849 CLUSTER_RESOURCE_GROUP : {{ .Config.GetVariableValue "CLUSTERRESOURCEGROUP" }}
49- CLUSTER_NAME : {{ .Config.GetVariableValue "CLUSTERNAME " }}
50+ CLUSTER_RESOURCE_TYPE : Microsoft.ContainerService/ {{ .Config.GetVariableValue "RESOURCETYPE " }}
5051 KUSTOMIZE_PATH : {{ .Config.GetVariableValue "KUSTOMIZEPATH" }}
5152 DOCKER_FILE : {{ .Config.GetVariableValue "DOCKERFILE" }}
5253 BUILD_CONTEXT_PATH : {{ .Config.GetVariableValue "BUILDCONTEXTPATH" }}
5354 NAMESPACE : {{ .Config.GetVariableValue "NAMESPACE" }}
55+ RESOURCE_NAME : {{ .Config.GetVariableValue "CLUSTERNAME" }}
5456{{`
5557jobs :
5658 buildImage :
@@ -101,12 +103,13 @@ jobs:
101103
102104 # Retrieves your Azure Kubernetes Service cluster's kubeconfig file
103105 - name : Get K8s context
104- uses : azure/aks-set-context@v3
106+ uses : azure/aks-set-context@v4.0.2
105107 with :
106108 resource-group : ${{ env.CLUSTER_RESOURCE_GROUP }}
107- cluster-name : ${{ env.CLUSTER_NAME }}
109+ cluster-name : ${{ env.RESOURCE_NAME }}
108110 admin : ' false'
109111 use-kubelogin : ' true'
112+ resource-type : ${{ env.CLUSTER_RESOURCE_TYPE }}
110113
111114 # Runs Kustomize to create manifest files
112115 - name : Bake deployment
@@ -116,24 +119,26 @@ jobs:
116119 kustomizationPath : ${{ env.KUSTOMIZE_PATH }}
117120 kubectl-version : latest
118121 id : bake
119-
122+
120123 # Checks if the AKS cluster is private
121124 - name : Is private cluster
125+ if : ${{ env.CLUSTER_RESOURCE_TYPE != 'Microsoft.ContainerService/fleets' }}
122126 id : isPrivate
123127 run : |
124- result=$(az aks show --resource-group ${{ env.CLUSTER_RESOURCE_GROUP }} --name ${{ env.CLUSTER_NAME }} --query "apiServerAccessProfile.enablePrivateCluster")
128+ result=$(az aks show --resource-group ${{ env.CLUSTER_RESOURCE_GROUP }} --name ${{ env.RESOURCE_NAME }} --query "apiServerAccessProfile.enablePrivateCluster")
125129 echo "PRIVATE_CLUSTER=$result" >> "$GITHUB_OUTPUT"
126130
127131 # Deploys application based on manifest files from previous step
128132 - name : Deploy application
129- uses : Azure/k8s-deploy@v4
133+ uses : Azure/k8s-deploy@v5.0.1
130134 with :
131135 action : deploy
132136 manifests : ${{ steps.bake.outputs.manifestsBundle }}
133137 images : |
134138 ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }}
135139 resource-group : ${{ env.CLUSTER_RESOURCE_GROUP }}
136- name : ${{ env.CLUSTER_NAME }}
140+ name : ${{ env.RESOURCE_NAME }}
137141 private-cluster : ${{ steps.isPrivate.outputs.PRIVATE_CLUSTER == 'true' }}
138142 namespace : ${{ env.NAMESPACE }}
143+ resource-type : ${{ env.CLUSTER_RESOURCE_TYPE }}
139144` }}
0 commit comments