An example workflow, using the GitHub Action for Azure to build, tag, and deploy a container image to a running Kubernetes cluster on AKS.
The example workflow will trigger on every push to this repo.
For pushes to a feature branch, the workflow will:
- Build the Docker image from the included
Dockerfile
- Tag and push the image to Azure Container Registry (ACR)
For pushes to the default branch (master
), in addition to the above Actions, the workflow will:
- Update the deployment resource on the running AKS Kubernetes with the latest container image
The following setup steps must be complete before running the example workflow.
- Create an Azure resource group, a logical container into which Azure resources are deployed and managed, in a location of your choice:
az group create --name $RESOURCE_GROUP --location $LOCATION
(more info)
- Create an Azure Container Registry (ACR) instance in your resource group:
az acr create --name $REGISTRY --resource-group $RESOURCE_GROUP --sku Basic
(more info)
- Configure ACR authentication, grant the AKS service principal the correct rights to pull images from ACR:
az role assignment create --assignee $AZURE_SERVICE_APP_ID --scope $ACR_ID --role Reader
(more info)
- Build, tag, and push the included Docker image to ACR
- Create an AKS Kubernetes cluster:
az aks create --resource-group $RESOURCE_GROUP --name $CLUSTER --node-count 1 --service-principal $AZURE_SERVICE_APP_ID --client-secret $AZURE_SERVICE_PASSWORD --generate-ssh-keys
(more info)
- Connect to your cluster using
kubectl
:az aks get-credentials --resource-group $RESOURCE_GROUP --name $CLUSTER
(more info)
- Apply the included Kubernetes configuration to your cluster:
kubectl apply -f ./kconfig.yml
This repository is licensed under CC0-1.0, which waives all copyright restrictions.