diff --git a/.github/workflows/integration-per-language.yml b/.github/workflows/integration-per-language.yml index 151de875..b635f6ae 100644 --- a/.github/workflows/integration-per-language.yml +++ b/.github/workflows/integration-per-language.yml @@ -158,6 +158,7 @@ jobs: --variable CONTAINERNAME=someContainer \ --variable CLUSTERRESOURCEGROUP=someClusterResourceGroup \ --variable CLUSTERNAME=someAksCluster \ + --variable CLUSTERRESOURCETYPE=Microsoft.ContainerService/managedClusters \ --variable DOCKERFILE=./Dockerfile \ --variable BUILDCONTEXTPATH=. \ --variable NAMESPACE=default @@ -331,6 +332,7 @@ jobs: --variable CONTAINERNAME=someContainer \ --variable CLUSTERRESOURCEGROUP=someClusterResourceGroup \ --variable CLUSTERNAME=someAksCluster \ + --variable CLUSTERRESOURCETYPE=Microsoft.ContainerService/managedClusters \ --variable DOCKERFILE=./Dockerfile \ --variable BUILDCONTEXTPATH=. \ --variable NAMESPACE=default @@ -484,7 +486,7 @@ jobs: curl -m 3 $SERVICEIP:${{env.serviceport}} sleep 5 kill $tunnelPID - - run: ./draft -v generate-workflow -d ./langtest/ --deploy-type manifests --variable WORKFLOWNAME=someWorkflow --variable BRANCHNAME=main --variable ACRRESOURCEGROUP=someAcrResourceGroup --variable AZURECONTAINERREGISTRY=someRegistry --variable CONTAINERNAME=someContainer --variable CLUSTERRESOURCEGROUP=someClusterResourceGroup --variable CLUSTERNAME=someAksCluster --variable DOCKERFILE=./Dockerfile --variable BUILDCONTEXTPATH=. --variable NAMESPACE=default + - run: ./draft -v generate-workflow -d ./langtest/ --deploy-type manifests --variable WORKFLOWNAME=someWorkflow --variable BRANCHNAME=main --variable ACRRESOURCEGROUP=someAcrResourceGroup --variable AZURECONTAINERREGISTRY=someRegistry --variable CONTAINERNAME=someContainer --variable CLUSTERRESOURCEGROUP=someClusterResourceGroup --variable CLUSTERNAME=someAksCluster --variable CLUSTERRESOURCETYPE=Microsoft.ContainerService/managedClusters --variable DOCKERFILE=./Dockerfile --variable BUILDCONTEXTPATH=. --variable NAMESPACE=default # Validate generated workflow yaml - name: Install action-validator with asdf uses: asdf-vm/actions/install@v1 diff --git a/pkg/fixtures/workflows/github/helm/.github/workflows/azure-kubernetes-service-helm.yml b/pkg/fixtures/workflows/github/helm/.github/workflows/azure-kubernetes-service-helm.yml index c11b857b..ee8eea28 100644 --- a/pkg/fixtures/workflows/github/helm/.github/workflows/azure-kubernetes-service-helm.yml +++ b/pkg/fixtures/workflows/github/helm/.github/workflows/azure-kubernetes-service-helm.yml @@ -20,8 +20,9 @@ # - ACR_RESOURCE_GROUP (resource group of your ACR) # - AZURE_CONTAINER_REGISTRY (name of your container registry / ACR) # - CONTAINER_NAME (name of the container image you would like to push up to your ACR) +# - CLUSTER_NAME (name of the resource to deploy to - fleet name or managed cluster name) # - CLUSTER_RESOURCE_GROUP (where your cluster is deployed) -# - CLUSTER_NAME (name of your AKS cluster) +# - CLUSTER_RESOURCE_TYPE (type of resource to deploy to, either 'Microsoft.ContainerService/fleets' or 'Microsoft.ContainerService/managedClusters') # - DOCKER_FILE (path to your Dockerfile) # - BUILD_CONTEXT_PATH (path to the context of your Dockerfile) # - CHART_PATH (path to your helm chart) @@ -44,8 +45,9 @@ env: ACR_RESOURCE_GROUP: testAcrRG AZURE_CONTAINER_REGISTRY: testAcr CONTAINER_NAME: testContainer - CLUSTER_RESOURCE_GROUP: testClusterRG CLUSTER_NAME: testCluster + CLUSTER_RESOURCE_GROUP: testClusterRG + CLUSTER_RESOURCE_TYPE: Microsoft.ContainerService/managedClusters DOCKER_FILE: ./Dockerfile BUILD_CONTEXT_PATH: test CHART_PATH: testPath @@ -102,16 +104,18 @@ jobs: # Retrieves your Azure Kubernetes Service cluster's kubeconfig file - name: Get K8s context - uses: azure/aks-set-context@v3 + uses: azure/aks-set-context@v4 with: resource-group: ${{ env.CLUSTER_RESOURCE_GROUP }} cluster-name: ${{ env.CLUSTER_NAME }} + resource-type: ${{ env.CLUSTER_RESOURCE_TYPE }} admin: "false" use-kubelogin: "true" # Checks if the AKS cluster is private - name: Is private cluster id: isPrivate + if: ${{ env.CLUSTER_RESOURCE_TYPE != 'Microsoft.ContainerService/fleets' }} run: | result=$(az aks show --resource-group ${{ env.CLUSTER_RESOURCE_GROUP }} --name ${{ env.CLUSTER_NAME }} --query "apiServerAccessProfile.enablePrivateCluster") echo "PRIVATE_CLUSTER=$result" >> "$GITHUB_OUTPUT" @@ -124,11 +128,17 @@ jobs: result=$(az aks command result --resource-group ${{ env.CLUSTER_RESOURCE_GROUP }} --name ${{ env.CLUSTER_NAME }} --command-id $command_id) echo "Helm upgrade result: $result" exitCode=$(az aks command result --resource-group ${{ env.CLUSTER_RESOURCE_GROUP }} --name ${{ env.CLUSTER_NAME }} --command-id $command_id --query exitCode -o tsv) - + if [ $exitCode -ne 0 ]; then exit $exitCode fi - name: Deploy application on public cluster - if: steps.isPrivate.outputs.PRIVATE_CLUSTER != 'true' - run: helm upgrade --wait -i -f ${{ env.CHART_OVERRIDE_PATH }} --set ${{ env.CHART_OVERRIDES }} --set image.tag=${{ github.sha }} automated-deployment ${{ env.CHART_PATH }} --namespace ${{ env.NAMESPACE }} --create-namespace + if: ${{ steps.isPrivate.outputs.PRIVATE_CLUSTER != 'true' && env.CLUSTER_RESOURCE_TYPE != 'Microsoft.ContainerService/fleets' }} + run: | + helm upgrade --wait -i -f ${{ env.CHART_OVERRIDE_PATH }} --set ${{ env.CHART_OVERRIDES }} --set image.tag=${{ github.sha }} automated-deployment ${{ env.CHART_PATH }} --namespace ${{ env.NAMESPACE }} --create-namespace + + - name: Deploy application on fleet hub cluster + if: ${{ env.CLUSTER_RESOURCE_TYPE == 'Microsoft.ContainerService/fleets' }} + run: | + helm upgrade -i -f ${{ env.CHART_OVERRIDE_PATH }} --set ${{ env.CHART_OVERRIDES }} --set image.tag=${{ github.sha }} automated-deployment ${{ env.CHART_PATH }} --namespace ${{ env.NAMESPACE }} diff --git a/pkg/fixtures/workflows/github/kustomize/.github/workflows/azure-kubernetes-service-kustomize.yml b/pkg/fixtures/workflows/github/kustomize/.github/workflows/azure-kubernetes-service-kustomize.yml index ee198518..66799304 100644 --- a/pkg/fixtures/workflows/github/kustomize/.github/workflows/azure-kubernetes-service-kustomize.yml +++ b/pkg/fixtures/workflows/github/kustomize/.github/workflows/azure-kubernetes-service-kustomize.yml @@ -20,8 +20,9 @@ # - ACR_RESOURCE_GROUP (resource group of your ACR) # - AZURE_CONTAINER_REGISTRY (name of your container registry / ACR) # - CONTAINER_NAME (name of the container image you would like to push up to your ACR) +# - CLUSTER_NAME (name of the resource to deploy to - fleet name or managed cluster name) # - CLUSTER_RESOURCE_GROUP (where your cluster is deployed) -# - CLUSTER_NAME (name of your AKS cluster) +# - CLUSTER_RESOURCE_TYPE (type of resource to deploy to, either 'Microsoft.ContainerService/fleets' or 'Microsoft.ContainerService/managedCluster') # - DOCKER_FILE (path to your Dockerfile) # - BUILD_CONTEXT_PATH (path to the context of your Dockerfile) # - NAMESPACE (namespace to deploy your application) @@ -45,8 +46,9 @@ env: ACR_RESOURCE_GROUP: testAcrRG AZURE_CONTAINER_REGISTRY: testAcr CONTAINER_NAME: testContainer - CLUSTER_RESOURCE_GROUP: testClusterRG CLUSTER_NAME: testCluster + CLUSTER_RESOURCE_GROUP: testClusterRG + CLUSTER_RESOURCE_TYPE: Microsoft.ContainerService/managedClusters KUSTOMIZE_PATH: ./overlays/production DOCKER_FILE: ./Dockerfile BUILD_CONTEXT_PATH: test @@ -101,12 +103,13 @@ jobs: # Retrieves your Azure Kubernetes Service cluster's kubeconfig file - name: Get K8s context - uses: azure/aks-set-context@v3 + uses: azure/aks-set-context@v4 with: resource-group: ${{ env.CLUSTER_RESOURCE_GROUP }} cluster-name: ${{ env.CLUSTER_NAME }} admin: 'false' use-kubelogin: 'true' + resource-type: ${{ env.CLUSTER_RESOURCE_TYPE }} # Runs Kustomize to create manifest files - name: Bake deployment @@ -116,9 +119,9 @@ jobs: kustomizationPath: ${{ env.KUSTOMIZE_PATH }} kubectl-version: latest id: bake - # Checks if the AKS cluster is private - name: Is private cluster + if: ${{ env.CLUSTER_RESOURCE_TYPE != 'Microsoft.ContainerService/fleets' }} id: isPrivate run: | result=$(az aks show --resource-group ${{ env.CLUSTER_RESOURCE_GROUP }} --name ${{ env.CLUSTER_NAME }} --query "apiServerAccessProfile.enablePrivateCluster") @@ -126,7 +129,7 @@ jobs: # Deploys application based on manifest files from previous step - name: Deploy application - uses: Azure/k8s-deploy@v4 + uses: Azure/k8s-deploy@v5 with: action: deploy manifests: ${{ steps.bake.outputs.manifestsBundle }} @@ -136,4 +139,5 @@ jobs: name: ${{ env.CLUSTER_NAME }} private-cluster: ${{ steps.isPrivate.outputs.PRIVATE_CLUSTER == 'true' }} namespace: ${{ env.NAMESPACE }} + resource-type: ${{ env.CLUSTER_RESOURCE_TYPE }} diff --git a/pkg/fixtures/workflows/github/manifests/.github/workflows/azure-kubernetes-service.yml b/pkg/fixtures/workflows/github/manifests/.github/workflows/azure-kubernetes-service.yml index 92c2dbff..e5c326d4 100644 --- a/pkg/fixtures/workflows/github/manifests/.github/workflows/azure-kubernetes-service.yml +++ b/pkg/fixtures/workflows/github/manifests/.github/workflows/azure-kubernetes-service.yml @@ -18,14 +18,14 @@ # 2. Set the following environment variables (or replace the values below): # - ACR_RESOURCE_GROUP (resource group of your ACR) # - AZURE_CONTAINER_REGISTRY (name of your container registry / ACR) +# - CLUSTER_NAME (name of the resource to deploy to - fleet name or managed cluster name) # - CLUSTER_RESOURCE_GROUP (where your cluster is deployed) -# - CLUSTER_NAME (name of your AKS cluster) +# - CLUSTER_RESOURCE_TYPE (type of resource to deploy to, either 'Microsoft.ContainerService/fleets' or 'Microsoft.ContainerService/managedClusters') # - CONTAINER_NAME (name of the container image you would like to push up to your ACR) # - DEPLOYMENT_MANIFEST_PATH (path to the manifest yaml for your deployment) # - DOCKER_FILE (path to your Dockerfile) # - BUILD_CONTEXT_PATH (path to the context of your Dockerfile) # - NAMESPACE (namespace to deploy your application) -# # For more information on GitHub Actions for Azure, refer to https://github.com/Azure/Actions # For more samples to get started with GitHub Action workflows to deploy to Azure, refer to https://github.com/Azure/actions-workflow-samples # For more options with the actions used below please refer to https://github.com/Azure/login @@ -41,8 +41,9 @@ env: ACR_RESOURCE_GROUP: testAcrRG AZURE_CONTAINER_REGISTRY: testAcr CONTAINER_NAME: testContainer - CLUSTER_RESOURCE_GROUP: testClusterRG CLUSTER_NAME: testCluster + CLUSTER_RESOURCE_GROUP: testClusterRG + CLUSTER_RESOURCE_TYPE: Microsoft.ContainerService/managedClusters DEPLOYMENT_MANIFEST_PATH: ./manifests DOCKER_FILE: ./Dockerfile BUILD_CONTEXT_PATH: test @@ -97,15 +98,17 @@ jobs: # Retrieves your Azure Kubernetes Service cluster's kubeconfig file - name: Get K8s context - uses: azure/aks-set-context@v3 + uses: azure/aks-set-context@v4 with: resource-group: ${{ env.CLUSTER_RESOURCE_GROUP }} cluster-name: ${{ env.CLUSTER_NAME }} admin: 'false' use-kubelogin: 'true' + resource-type: ${{ env.CLUSTER_RESOURCE_TYPE }} # Checks if the AKS cluster is private - name: Is private cluster + if: ${{ env.CLUSTER_RESOURCE_TYPE != 'Microsoft.ContainerService/fleets' }} id: isPrivate run: | result=$(az aks show --resource-group ${{ env.CLUSTER_RESOURCE_GROUP }} --name ${{ env.CLUSTER_NAME }} --query "apiServerAccessProfile.enablePrivateCluster") @@ -113,7 +116,7 @@ jobs: # Deploys application based on given manifest file - name: Deploys application - uses: Azure/k8s-deploy@v4 + uses: Azure/k8s-deploy@v5 with: action: deploy manifests: ${{ env.DEPLOYMENT_MANIFEST_PATH }} @@ -123,3 +126,4 @@ jobs: name: ${{ env.CLUSTER_NAME }} private-cluster: ${{ steps.isPrivate.outputs.PRIVATE_CLUSTER == 'true' }} namespace: ${{ env.NAMESPACE }} + resource-type: ${{ env.CLUSTER_RESOURCE_TYPE }} diff --git a/pkg/handlers/templatetests/workflows_github_helm_test.go b/pkg/handlers/templatetests/workflows_github_helm_test.go index 179d1f03..cbec3d3f 100644 --- a/pkg/handlers/templatetests/workflows_github_helm_test.go +++ b/pkg/handlers/templatetests/workflows_github_helm_test.go @@ -22,6 +22,7 @@ func TestGitHubWorkflowHelmTemplates(t *testing.T) { "AZURECONTAINERREGISTRY": "testAcr", "CONTAINERNAME": "testContainer", "CLUSTERRESOURCEGROUP": "testClusterRG", + "CLUSTERRESOURCETYPE": "Microsoft.ContainerService/managedClusters", "CLUSTERNAME": "testCluster", "KUSTOMIZEPATH": "./overlays/production", "DEPLOYMENTMANIFESTPATH": "./manifests", diff --git a/pkg/handlers/templatetests/workflows_github_kustomize_test.go b/pkg/handlers/templatetests/workflows_github_kustomize_test.go index 69894be0..efbf7231 100644 --- a/pkg/handlers/templatetests/workflows_github_kustomize_test.go +++ b/pkg/handlers/templatetests/workflows_github_kustomize_test.go @@ -22,6 +22,7 @@ func TestGitHubWorkflowKustomizeTemplates(t *testing.T) { "AZURECONTAINERREGISTRY": "testAcr", "CONTAINERNAME": "testContainer", "CLUSTERRESOURCEGROUP": "testClusterRG", + "CLUSTERRESOURCETYPE": "Microsoft.ContainerService/managedClusters", "CLUSTERNAME": "testCluster", "DEPLOYMENTMANIFESTPATH": "./manifests", "DOCKERFILE": "./Dockerfile", diff --git a/template/workflows/helm/.github/workflows/azure-kubernetes-service-helm.yml b/template/workflows/helm/.github/workflows/azure-kubernetes-service-helm.yml index 0a39ee85..48e9affc 100644 --- a/template/workflows/helm/.github/workflows/azure-kubernetes-service-helm.yml +++ b/template/workflows/helm/.github/workflows/azure-kubernetes-service-helm.yml @@ -20,8 +20,9 @@ # - ACR_RESOURCE_GROUP (resource group of your ACR) # - AZURE_CONTAINER_REGISTRY (name of your container registry / ACR) # - CONTAINER_NAME (name of the container image you would like to push up to your ACR) +# - CLUSTER_NAME (name of the resource to deploy to - fleet name or managed cluster name) # - CLUSTER_RESOURCE_GROUP (where your cluster is deployed) -# - CLUSTER_NAME (name of your AKS cluster) +# - CLUSTER_RESOURCE_TYPE (type of resource to deploy to, either 'Microsoft.ContainerService/fleets' or 'Microsoft.ContainerService/managedClusters') # - DOCKER_FILE (path to your Dockerfile) # - BUILD_CONTEXT_PATH (path to the context of your Dockerfile) # - CHART_PATH (path to your helm chart) @@ -44,8 +45,9 @@ env: ACR_RESOURCE_GROUP: {{ .Config.GetVariableValue "ACRRESOURCEGROUP" }} AZURE_CONTAINER_REGISTRY: {{ .Config.GetVariableValue "AZURECONTAINERREGISTRY" }} CONTAINER_NAME: {{ .Config.GetVariableValue "CONTAINERNAME" }} - CLUSTER_RESOURCE_GROUP: {{ .Config.GetVariableValue "CLUSTERRESOURCEGROUP" }} CLUSTER_NAME: {{ .Config.GetVariableValue "CLUSTERNAME" }} + CLUSTER_RESOURCE_GROUP: {{ .Config.GetVariableValue "CLUSTERRESOURCEGROUP" }} + CLUSTER_RESOURCE_TYPE: {{ .Config.GetVariableValue "CLUSTERRESOURCETYPE" }} DOCKER_FILE: {{ .Config.GetVariableValue "DOCKERFILE" }} BUILD_CONTEXT_PATH: {{ .Config.GetVariableValue "BUILDCONTEXTPATH" }} CHART_PATH: {{ .Config.GetVariableValue "CHARTPATH" }} @@ -102,16 +104,18 @@ jobs: # Retrieves your Azure Kubernetes Service cluster's kubeconfig file - name: Get K8s context - uses: azure/aks-set-context@v3 + uses: azure/aks-set-context@v4 with: resource-group: ${{ env.CLUSTER_RESOURCE_GROUP }} cluster-name: ${{ env.CLUSTER_NAME }} + resource-type: ${{ env.CLUSTER_RESOURCE_TYPE }} admin: "false" use-kubelogin: "true" # Checks if the AKS cluster is private - name: Is private cluster id: isPrivate + if: ${{ env.CLUSTER_RESOURCE_TYPE != 'Microsoft.ContainerService/fleets' }} run: | result=$(az aks show --resource-group ${{ env.CLUSTER_RESOURCE_GROUP }} --name ${{ env.CLUSTER_NAME }} --query "apiServerAccessProfile.enablePrivateCluster") echo "PRIVATE_CLUSTER=$result" >> "$GITHUB_OUTPUT" @@ -130,6 +134,12 @@ jobs: fi - name: Deploy application on public cluster - if: steps.isPrivate.outputs.PRIVATE_CLUSTER != 'true' - run: helm upgrade --wait -i -f ${{ env.CHART_OVERRIDE_PATH }} --set ${{ env.CHART_OVERRIDES }} --set image.tag=${{ github.sha }} automated-deployment ${{ env.CHART_PATH }} --namespace ${{ env.NAMESPACE }} --create-namespace + if: ${{ steps.isPrivate.outputs.PRIVATE_CLUSTER != 'true' && env.CLUSTER_RESOURCE_TYPE != 'Microsoft.ContainerService/fleets' }} + run: | + helm upgrade --wait -i -f ${{ env.CHART_OVERRIDE_PATH }} --set ${{ env.CHART_OVERRIDES }} --set image.tag=${{ github.sha }} automated-deployment ${{ env.CHART_PATH }} --namespace ${{ env.NAMESPACE }} --create-namespace + + - name: Deploy application on fleet hub cluster + if: ${{ env.CLUSTER_RESOURCE_TYPE == 'Microsoft.ContainerService/fleets' }} + run: | + helm upgrade -i -f ${{ env.CHART_OVERRIDE_PATH }} --set ${{ env.CHART_OVERRIDES }} --set image.tag=${{ github.sha }} automated-deployment ${{ env.CHART_PATH }} --namespace ${{ env.NAMESPACE }} `}} diff --git a/template/workflows/kustomize/.github/workflows/azure-kubernetes-service-kustomize.yml b/template/workflows/kustomize/.github/workflows/azure-kubernetes-service-kustomize.yml index 1988e233..3d05ecb7 100644 --- a/template/workflows/kustomize/.github/workflows/azure-kubernetes-service-kustomize.yml +++ b/template/workflows/kustomize/.github/workflows/azure-kubernetes-service-kustomize.yml @@ -20,8 +20,9 @@ # - ACR_RESOURCE_GROUP (resource group of your ACR) # - AZURE_CONTAINER_REGISTRY (name of your container registry / ACR) # - CONTAINER_NAME (name of the container image you would like to push up to your ACR) +# - CLUSTER_NAME (name of the resource to deploy to - fleet name or managed cluster name) # - CLUSTER_RESOURCE_GROUP (where your cluster is deployed) -# - CLUSTER_NAME (name of your AKS cluster) +# - CLUSTER_RESOURCE_TYPE (type of resource to deploy to, either 'Microsoft.ContainerService/fleets' or 'Microsoft.ContainerService/managedCluster') # - DOCKER_FILE (path to your Dockerfile) # - BUILD_CONTEXT_PATH (path to the context of your Dockerfile) # - NAMESPACE (namespace to deploy your application) @@ -45,8 +46,9 @@ env: ACR_RESOURCE_GROUP: {{ .Config.GetVariableValue "ACRRESOURCEGROUP" }} AZURE_CONTAINER_REGISTRY: {{ .Config.GetVariableValue "AZURECONTAINERREGISTRY" }} CONTAINER_NAME: {{ .Config.GetVariableValue "CONTAINERNAME" }} - CLUSTER_RESOURCE_GROUP: {{ .Config.GetVariableValue "CLUSTERRESOURCEGROUP" }} CLUSTER_NAME: {{ .Config.GetVariableValue "CLUSTERNAME" }} + CLUSTER_RESOURCE_GROUP: {{ .Config.GetVariableValue "CLUSTERRESOURCEGROUP" }} + CLUSTER_RESOURCE_TYPE: {{ .Config.GetVariableValue "CLUSTERRESOURCETYPE" }} KUSTOMIZE_PATH: {{ .Config.GetVariableValue "KUSTOMIZEPATH" }} DOCKER_FILE: {{ .Config.GetVariableValue "DOCKERFILE" }} BUILD_CONTEXT_PATH: {{ .Config.GetVariableValue "BUILDCONTEXTPATH" }} @@ -101,12 +103,13 @@ jobs: # Retrieves your Azure Kubernetes Service cluster's kubeconfig file - name: Get K8s context - uses: azure/aks-set-context@v3 + uses: azure/aks-set-context@v4 with: resource-group: ${{ env.CLUSTER_RESOURCE_GROUP }} cluster-name: ${{ env.CLUSTER_NAME }} admin: 'false' use-kubelogin: 'true' + resource-type: ${{ env.CLUSTER_RESOURCE_TYPE }} # Runs Kustomize to create manifest files - name: Bake deployment @@ -116,9 +119,9 @@ jobs: kustomizationPath: ${{ env.KUSTOMIZE_PATH }} kubectl-version: latest id: bake - # Checks if the AKS cluster is private - name: Is private cluster + if: ${{ env.CLUSTER_RESOURCE_TYPE != 'Microsoft.ContainerService/fleets' }} id: isPrivate run: | result=$(az aks show --resource-group ${{ env.CLUSTER_RESOURCE_GROUP }} --name ${{ env.CLUSTER_NAME }} --query "apiServerAccessProfile.enablePrivateCluster") @@ -126,7 +129,7 @@ jobs: # Deploys application based on manifest files from previous step - name: Deploy application - uses: Azure/k8s-deploy@v4 + uses: Azure/k8s-deploy@v5 with: action: deploy manifests: ${{ steps.bake.outputs.manifestsBundle }} @@ -136,4 +139,5 @@ jobs: name: ${{ env.CLUSTER_NAME }} private-cluster: ${{ steps.isPrivate.outputs.PRIVATE_CLUSTER == 'true' }} namespace: ${{ env.NAMESPACE }} + resource-type: ${{ env.CLUSTER_RESOURCE_TYPE }} `}} diff --git a/template/workflows/manifests/.github/workflows/azure-kubernetes-service.yml b/template/workflows/manifests/.github/workflows/azure-kubernetes-service.yml index 7e425e79..662199f8 100644 --- a/template/workflows/manifests/.github/workflows/azure-kubernetes-service.yml +++ b/template/workflows/manifests/.github/workflows/azure-kubernetes-service.yml @@ -18,14 +18,14 @@ # 2. Set the following environment variables (or replace the values below): # - ACR_RESOURCE_GROUP (resource group of your ACR) # - AZURE_CONTAINER_REGISTRY (name of your container registry / ACR) +# - CLUSTER_NAME (name of the resource to deploy to - fleet name or managed cluster name) # - CLUSTER_RESOURCE_GROUP (where your cluster is deployed) -# - CLUSTER_NAME (name of your AKS cluster) +# - CLUSTER_RESOURCE_TYPE (type of resource to deploy to, either 'Microsoft.ContainerService/fleets' or 'Microsoft.ContainerService/managedClusters') # - CONTAINER_NAME (name of the container image you would like to push up to your ACR) # - DEPLOYMENT_MANIFEST_PATH (path to the manifest yaml for your deployment) # - DOCKER_FILE (path to your Dockerfile) # - BUILD_CONTEXT_PATH (path to the context of your Dockerfile) # - NAMESPACE (namespace to deploy your application) -# # For more information on GitHub Actions for Azure, refer to https://github.com/Azure/Actions # For more samples to get started with GitHub Action workflows to deploy to Azure, refer to https://github.com/Azure/actions-workflow-samples # For more options with the actions used below please refer to https://github.com/Azure/login @@ -41,8 +41,9 @@ env: ACR_RESOURCE_GROUP: {{ .Config.GetVariableValue "ACRRESOURCEGROUP" }} AZURE_CONTAINER_REGISTRY: {{ .Config.GetVariableValue "AZURECONTAINERREGISTRY" }} CONTAINER_NAME: {{ .Config.GetVariableValue "CONTAINERNAME" }} - CLUSTER_RESOURCE_GROUP: {{ .Config.GetVariableValue "CLUSTERRESOURCEGROUP" }} CLUSTER_NAME: {{ .Config.GetVariableValue "CLUSTERNAME" }} + CLUSTER_RESOURCE_GROUP: {{ .Config.GetVariableValue "CLUSTERRESOURCEGROUP" }} + CLUSTER_RESOURCE_TYPE: {{ .Config.GetVariableValue "CLUSTERRESOURCETYPE" }} DEPLOYMENT_MANIFEST_PATH: {{ .Config.GetVariableValue "DEPLOYMENTMANIFESTPATH" }} DOCKER_FILE: {{ .Config.GetVariableValue "DOCKERFILE" }} BUILD_CONTEXT_PATH: {{ .Config.GetVariableValue "BUILDCONTEXTPATH" }} @@ -97,15 +98,17 @@ jobs: # Retrieves your Azure Kubernetes Service cluster's kubeconfig file - name: Get K8s context - uses: azure/aks-set-context@v3 + uses: azure/aks-set-context@v4 with: resource-group: ${{ env.CLUSTER_RESOURCE_GROUP }} cluster-name: ${{ env.CLUSTER_NAME }} admin: 'false' use-kubelogin: 'true' + resource-type: ${{ env.CLUSTER_RESOURCE_TYPE }} # Checks if the AKS cluster is private - name: Is private cluster + if: ${{ env.CLUSTER_RESOURCE_TYPE != 'Microsoft.ContainerService/fleets' }} id: isPrivate run: | result=$(az aks show --resource-group ${{ env.CLUSTER_RESOURCE_GROUP }} --name ${{ env.CLUSTER_NAME }} --query "apiServerAccessProfile.enablePrivateCluster") @@ -113,7 +116,7 @@ jobs: # Deploys application based on given manifest file - name: Deploys application - uses: Azure/k8s-deploy@v4 + uses: Azure/k8s-deploy@v5 with: action: deploy manifests: ${{ env.DEPLOYMENT_MANIFEST_PATH }} @@ -123,4 +126,5 @@ jobs: name: ${{ env.CLUSTER_NAME }} private-cluster: ${{ steps.isPrivate.outputs.PRIVATE_CLUSTER == 'true' }} namespace: ${{ env.NAMESPACE }} + resource-type: ${{ env.CLUSTER_RESOURCE_TYPE }} `}} \ No newline at end of file