Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/integration-per-language.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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 }}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -116,17 +119,17 @@ 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")
echo "PRIVATE_CLUSTER=$result" >> "$GITHUB_OUTPUT"

# 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 }}
Expand All @@ -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 }}

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -97,23 +98,25 @@ 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")
echo "PRIVATE_CLUSTER=$result" >> "$GITHUB_OUTPUT"

# 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 }}
Expand All @@ -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 }}
1 change: 1 addition & 0 deletions pkg/handlers/templatetests/workflows_github_helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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" }}
Expand Down Expand Up @@ -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"
Expand All @@ -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 }}
`}}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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" }}
Expand Down Expand Up @@ -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
Expand All @@ -116,17 +119,17 @@ 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")
echo "PRIVATE_CLUSTER=$result" >> "$GITHUB_OUTPUT"

# 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 }}
Expand All @@ -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 }}
`}}
Loading
Loading