Skip to content

Commit

Permalink
Template Support for Private Clusters (#334)
Browse files Browse the repository at this point in the history
Co-authored-by: David Gamero <[email protected]>
  • Loading branch information
meecethereese and davidgamero authored Jul 22, 2024
1 parent 685966f commit 457eb25
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 62 deletions.
72 changes: 36 additions & 36 deletions .github/workflows/integration-linux.yml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ env:
CHART_OVERRIDE_PATH: {{CHARTOVERRIDEPATH}}
CHART_OVERRIDES: {{CHARTOVERRIDES}}
NAMESPACE: {{NAMESPACE}}
PRIVATE_CLUSTER: {{PRIVATECLUSTER}}

jobs:
buildImage:
Expand Down Expand Up @@ -120,6 +119,13 @@ jobs:
helm-version: "latest"
id: bake

# Checks if the AKS cluster is private
- name: Is private cluster
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
Expand All @@ -129,4 +135,4 @@ jobs:
images: |
${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }}
namespace: ${{ env.NAMESPACE }}
private-cluster: ${{ env.PRIVATE_CLUSTER }}
private-cluster: ${{ steps.isPrivate.outputs.PRIVATE_CLUSTER }}
8 changes: 1 addition & 7 deletions template/workflows/helm/draft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,4 @@ variables:
- name: "NAMESPACE"
default:
value: "default"
description: "the Kubernetes namespace"
- name: "PRIVATECLUSTER"
default:
value: false
description: "true if the AKS cluster is private"
type: "bool"

description: "the Kubernetes namespace"
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ env:
DOCKER_FILE: {{DOCKERFILE}}
BUILD_CONTEXT_PATH: {{BUILDCONTEXTPATH}}
NAMESPACE: {{NAMESPACE}}
PRIVATE_CLUSTER: {{PRIVATECLUSTER}}

jobs:
buildImage:
Expand Down Expand Up @@ -114,6 +113,13 @@ jobs:
kustomizationPath: ${{ env.KUSTOMIZE_PATH }}
kubectl-version: latest
id: bake

# Checks if the AKS cluster is private
- name: Is private cluster
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
Expand All @@ -124,4 +130,4 @@ jobs:
images: |
${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }}
namespace: ${{ env.NAMESPACE }}
private-cluster: ${{ env.PRIVATE_CLUSTER }}
private-cluster: ${{ steps.isPrivate.outputs.PRIVATE_CLUSTER }}
5 changes: 0 additions & 5 deletions template/workflows/kustomize/draft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,3 @@ variables:
default:
value: "default"
description: "the Kubernetes namespace"
- name: "PRIVATECLUSTER"
default:
value: "false"
description: "true if the AKS cluster is private"
type: "bool"
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ env:
DOCKER_FILE: {{DOCKERFILE}}
BUILD_CONTEXT_PATH: {{BUILDCONTEXTPATH}}
NAMESPACE: {{NAMESPACE}}
PRIVATE_CLUSTER: {{PRIVATECLUSTER}}

jobs:
buildImage:
Expand Down Expand Up @@ -102,6 +101,13 @@ jobs:
admin: 'false'
use-kubelogin: 'true'

# Checks if the AKS cluster is private
- name: Is private cluster
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
Expand All @@ -111,5 +117,5 @@ jobs:
images: |
${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }}
namespace: ${{ env.NAMESPACE }}
private-cluster: ${{ env.PRIVATE_CLUSTER }}
private-cluster: ${{ steps.isPrivate.outputs.PRIVATE_CLUSTER }}

5 changes: 0 additions & 5 deletions template/workflows/manifests/draft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,3 @@ variables:
default:
value: "default"
description: "the Kubernetes namespace"
- name: "PRIVATECLUSTER"
default:
value: "false"
description: "true if the AKS cluster is private"
type: "bool"
6 changes: 3 additions & 3 deletions test/gen_integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ languageVariables:
curl -m 3 \$SERVICEIP:$serviceport
kill \$tunnelPID
- run: |
./draft -v generate-workflow -d ./langtest/ --deploy-type helm --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 --variable PRIVATECLUSTER=false
./draft -v generate-workflow -d ./langtest/ --deploy-type helm --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
pwd
# Validate generated workflow yaml
- name: Install action-validator with asdf
Expand Down Expand Up @@ -455,7 +455,7 @@ languageVariables:
echo 'Curling service IP'
curl -m 3 \$SERVICEIP:$serviceport
kill \$tunnelPID
- run: ./draft -v generate-workflow -d ./langtest/ --deploy-type kustomize --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 --variable PRIVATECLUSTER=false
- run: ./draft -v generate-workflow -d ./langtest/ --deploy-type kustomize --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
# Validate generated workflow yaml
- name: Install action-validator with asdf
uses: asdf-vm/actions/install@v1
Expand Down Expand Up @@ -596,7 +596,7 @@ languageVariables:
echo 'Curling service IP'
curl -m 3 \$SERVICEIP:$serviceport
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 --variable PRIVATECLUSTER=false
- 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
# Validate generated workflow yaml
- name: Install action-validator with asdf
uses: asdf-vm/actions/install@v1
Expand Down

0 comments on commit 457eb25

Please sign in to comment.