This repository provides the source code for setting up Cluster API on Microsoft Azure using Terraform and Flux: You can use this repository to create a fully automated and scalable workflow for deploying and managing Kubernetes clusters on Azure.
The purpose of the repository is to:
- Deploy the management cluster with Terraform
- Bootstrap it with Flux to pull in the Kubernetes manifests and apply them
- Install Cluster API on top of the management cluster
- Start deploying additional AKS clusters using Cluster API
Through the use of Flux, we’re able to deploy workload clusters quickly after pull requests are merged. You can use this repository as a template or a reference for your own Cluster API projects on Azure.
Please note this repository is under development and subject to change.
clusters
- Kustomize manifests for cluster componentsmanagement
- Platform management clusterworkloads
- Distributed workload clusters
manifests
- Re-usable Kubernetes manifests for all clustersresources
- Terraform files for deploying the management cluster
- Create
.ssh/
directory - Invoke
ssh-keygen -t ed25519 -C "[email protected]"
- Invoke
ssh-keygen -t rsa -b 4096 -C "[email protected]"
- Add the
id_ed25519.pub
file to your repository as "Deploy keys"
- Navigate to the
resources
directory - Update the
resource_name
andlocation
properties inlocals.tf
file - Update the
url
property in theproviders.tf
file - Authenticate Azure session
az login
- Select desired Azure Subscription
az account set -s '{SubscriptionName}'
- Initialize Terraform
terraform init
- Deploy Terraform resources
terraform deploy
- Authenticate Kubernetes context
az aks get-credentials -g '{ResourceGroup}' -n {Name}
Configuring Terraform State Storage has been omitted for brevity
- Browse to the Entra admin center
- Create App registration
- Navigate to "Certificates & Secrets"
- Add Federated credential “Kubernetes accessing Azure resources”
- Update cluster details:
- Cluster issuer URL
az aks show -g '{ResourceGroup}' -n '{Name}' --query 'oidcIssuerProfile.issuerUrl'
- Namespace "capi-azure-system"
- Service account name "capz-manager"
- Cluster issuer URL
- Browse to the Azure portal
- Navigate to the desired Subscription
- Select 'Access control (IAM)' and 'Add role assignment'
- Select Role - Owner and select 'Members'
- Provide the 'Name' of the application from the previous steps
- Navigate to the
manifest/config
directory - Update the
data
properties with desired valuesglobal_public_key
needs to be base64 encoded version ofid_rsa.pub
- Deploy Kubernetes manifest
kubectl apply -f workloads.yaml
Configuration of Workloads settings can also be deployed by Flux