Skip to content

Commit 4e5e61e

Browse files
committed
draft changes for helm and kustomize
1 parent 3810774 commit 4e5e61e

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

template/workflows/helm/.github/workflows/azure-kubernetes-service-helm.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
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
# - CHART_PATH (path to your helm chart)
2828
# - CHART_OVERRIDE_PATH (path to your helm chart with override values)
2929
# - CHART_OVERRIDES (override values for your helm chart)
3030
# - NAMESPACE (namespace to deploy your application)
31+
# - RESOURCE_NAME (name of your AKS resource)
3132
#
3233
# For more information on GitHub Actions for Azure, refer to https://github.com/Azure/Actions
3334
# For more samples to get started with GitHub Action workflows to deploy to Azure, refer to https://github.com/Azure/actions-workflow-samples
@@ -45,13 +46,15 @@ env:
4546
AZURE_CONTAINER_REGISTRY: {{ .Config.GetVariableValue "AZURECONTAINERREGISTRY" }}
4647
CONTAINER_NAME: {{ .Config.GetVariableValue "CONTAINERNAME" }}
4748
CLUSTER_RESOURCE_GROUP: {{ .Config.GetVariableValue "CLUSTERRESOURCEGROUP" }}
48-
CLUSTER_NAME: {{ .Config.GetVariableValue "CLUSTERNAME" }}
49+
CLUSTER_RESOURCE_TYPE: Microsoft.ContainerService/{{ .Config.GetVariableValue "RESOURCETYPE" }}
4950
DOCKER_FILE: {{ .Config.GetVariableValue "DOCKERFILE" }}
5051
BUILD_CONTEXT_PATH: {{ .Config.GetVariableValue "BUILDCONTEXTPATH" }}
5152
CHART_PATH: {{ .Config.GetVariableValue "CHARTPATH" }}
5253
CHART_OVERRIDE_PATH: {{ .Config.GetVariableValue "CHARTOVERRIDEPATH" }}
5354
CHART_OVERRIDES: {{ .Config.GetVariableValue "CHARTOVERRIDES" }}
5455
NAMESPACE: {{ .Config.GetVariableValue "NAMESPACE" }}
56+
RESOURCE_NAME: {{ .Config.GetVariableValue "CLUSTERNAME" }}
57+
5558
{{`
5659
jobs:
5760
buildImage:
@@ -102,16 +105,18 @@ jobs:
102105

103106
# Retrieves your Azure Kubernetes Service cluster's kubeconfig file
104107
- name: Get K8s context
105-
uses: azure/aks-set-context@v3
108+
uses: azure/aks-set-context@v4.0.2
106109
with:
107110
resource-group: ${{ env.CLUSTER_RESOURCE_GROUP }}
108-
cluster-name: ${{ env.CLUSTER_NAME }}
111+
cluster-name: ${{ env.RESOURCE_NAME }}
112+
resource-type: ${{ env.CLUSTER_RESOURCE_TYPE }}
109113
admin: "false"
110114
use-kubelogin: "true"
111115

112116
# Checks if the AKS cluster is private
113117
- name: Is private cluster
114118
id: isPrivate
119+
if: ${{ env.CLUSTER_RESOURCE_TYPE != 'Microsoft.ContainerService/fleets' }}
115120
run: |
116121
result=$(az aks show --resource-group ${{ env.CLUSTER_RESOURCE_GROUP }} --name ${{ env.CLUSTER_NAME }} --query "apiServerAccessProfile.enablePrivateCluster")
117122
echo "PRIVATE_CLUSTER=$result" >> "$GITHUB_OUTPUT"
@@ -131,5 +136,10 @@ jobs:
131136
132137
- name: Deploy application on public cluster
133138
if: steps.isPrivate.outputs.PRIVATE_CLUSTER != 'true'
134-
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
139+
run: |
140+
if [ "${{ env.CLUSTER_RESOURCE_TYPE }}" == "Microsoft.ContainerService/fleets" ]; then
141+
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 }}
142+
else
143+
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
144+
fi
135145
`}}

template/workflows/kustomize/.github/workflows/azure-kubernetes-service-kustomize.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
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.
@@ -46,11 +47,12 @@ env:
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
{{`
5557
jobs:
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

Comments
 (0)