Multiple Azure Kubernetes Service (AKS) clusters
Create multiple Azure Kubernetes Service (AKS) clusters in different regions and with different node counts
This example lives in the pulumi/examples repository. Check out just this directory to use it:
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examplesgit -C pulumi-examples sparse-checkout set azure-py-aks-multiclustercd pulumi-examples/azure-py-aks-multiclusterThis example demonstrates creating multiple Azure Kubernetes Service (AKS) clusters in different regions and with different node counts. Please see https://docs.microsoft.com/en-us/azure/aks/ for more information about AKS.
Prerequisites#
Deploying the example#
-
Create a new stack, which is an isolated deployment target for this example:
Terminal window pulumi stack init -
Set the required configuration variables for this program:
Terminal window pulumi config set azure-native:environment publicpulumi config set password --secret [your-cluster-password-here]ssh-keygen -t rsa -f key.rsapulumi config set sshPublicKey < key.rsa.pub -
Install dependencies:
Terminal window python3 -m venv venvsource venv/bin/activatepip install -r requirements.txt -
Deploy everything with the
pulumi upcommand. This provisions all the Azure resources necessary, including an Active Directory service principal and AKS clusters:Terminal window pulumi upNote: Due to an issue in the Azure AD Terraform Provider (https://github.com/hashicorp/terraform-provider-azuread/issues/4) the creation of an Azure Service Principal, which is needed to create the Kubernetes cluster (see main.py), is delayed and may not be available when the cluster is created. If you get a Service Principal not found error, as a work around, you should be able to run
pulumi upagain, at which time the Service Principal should have been created. -
After a couple minutes, your AKS clusters will be ready. The AKS cluster names will be printed as output variables once
pulumi upcompletes.Outputs:+ aksClusterNames: [+ [0]: "akscluster-east513be264"+ [1]: "akscluster-westece285c7"] -
At this point, you have multiple AKS clusters running in different regions. Feel free to modify your program, and run
pulumi upto redeploy changes. The Pulumi CLI automatically detects what has changed and makes the minimal edits necessary to accomplish these changes.
Cleaning up#
Once you’re finished experimenting, you can destroy your stack and remove it to avoid incurring any additional cost:
pulumi destroypulumi stack rm