Skip to content

Deploy Kubernetes Cluster #20

Deploy Kubernetes Cluster

Deploy Kubernetes Cluster #20

Workflow file for this run

name: Deploy Kubernetes Cluster
on: workflow_dispatch
permissions:
id-token: write
contents: read
# https://docs.github.com/en/actions/deployment/deploying-to-your-cloud-provider/deploying-to-azure/deploying-to-azure-kubernetes-service
# https://docs.github.com/en/actions/publishing-packages/about-packaging-with-github-actions
jobs:
deploy-bicep:
runs-on: ubuntu-latest
name: Deploy Bicep
steps:
- uses: actions/checkout@v3
- uses: azure/login@v1
name: Login to Azure
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
enable-AzPSSession: true
# Why on earth can't I just deploy the bicep file?
- uses: azure/bicep-build-action@v1.0.0
name: Bicep Build
with:
bicepFilePath: infrastructure/Cluster.bicep
outputFilePath: infrastructure/Cluster.json
- id: name
shell: pwsh
run: '"name=aks-$(Get-Date -f yyyyMMddThhmmss)" >> $Env:GITHUB_OUTPUT'
- uses: azure/arm-deploy@v1
name: deploy
timeout-minutes: 240
with:
template: infrastructure/Cluster.json
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION }}
resourceGroupName: ${{ secrets.AZURE_RG }}
parameters: adminId=${{ secrets.ADMIN_GROUP_ID }}
deploymentName: ${{ steps.name.outputs.name }}
- id: deploy-flux
shell: pwsh
run: |
#! Get the cluster credentials
Get-AzAksCluster -ResourceGroupName $Env:RESOURCE_GROUP |
Import-AzAksCredential -Force
#! Update the client ID from the deployment output
$kustomize = Get-Content "clusters/poschode/flux/kustomization.ps1"
$kustomize = $kustomize -replace "azure.workload.identity/client-id: .*$", "azure.workload.identity/client-id: ${{ steps.deploy.outputs.fluxIdClientId }}"
# TODO: commit this file to the repo _before_ running flux
$kustomize | Set-Content "clusters/poschode/flux/kustomization.ps1"
#! Bootstrap Flux
./infrastructure/Install-Flux.ps1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RESOURCE_GROUP: ${{ secrets.AZURE_RG }}