1. Packages
  2. Azure Native
  3. How-to Guides
  4. Multiple Azure Kubernetes Service (AKS) Clusters
This is the latest version of Azure Native. Use the Azure Native v1 docs if using the v1 version of this package.
Azure Native v2.73.0 published on Wednesday, Nov 20, 2024 by Pulumi

Multiple Azure Kubernetes Service (AKS) Clusters

azure-native logo
This is the latest version of Azure Native. Use the Azure Native v1 docs if using the v1 version of this package.
Azure Native v2.73.0 published on Wednesday, Nov 20, 2024 by Pulumi

    View Code Deploy this example with Pulumi

    This 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

    Ensure you have downloaded and installed the Pulumi CLI.

    We will be deploying to Azure, so you will need an Azure account. If you don’t have an account, sign up for free here. Follow the instructions here to connect Pulumi to your Azure account.

    Running the Example

    Note: 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 up again, at which time the Service Principal should have been created.

    After cloning this repo, cd into it and run these commands.

    1. Create a new stack, which is an isolated deployment target for this example:

      $ pulumi stack init
      
    2. Set the required configuration variables for this program:

      $ pulumi config set azure-native:environment public
      $ pulumi config set password --secret [your-cluster-password-here]
      $ ssh-keygen -t rsa -f key.rsa
      $ pulumi config set sshPublicKey < key.rsa.pub
      
    3. Deploy everything with the pulumi up command. This provisions all the Azure resources necessary, including an Active Directory service principal and AKS clusters:

      $ pulumi up
      
    4. After a couple minutes, your AKS clusters will be ready. The AKS cluster names will be printed as output variables once pulumi up completes.

      $ pulumi up
      ...
      
      Outputs:
        + aksClusterNames: [
        +     [0]: "akscluster-east513be264"
        +     [1]: "akscluster-westece285c7"
          ]
      ...
      
    5. At this point, you have multiple AKS clusters running in different regions. Feel free to modify your program, and run pulumi up to redeploy changes. The Pulumi CLI automatically detects what has changed and makes the minimal edits necessary to accomplish these changes.

    6. Once you are done, you can destroy all of the resources, and the stack:

      $ pulumi destroy
      $ pulumi stack rm
      
    azure-native logo
    This is the latest version of Azure Native. Use the Azure Native v1 docs if using the v1 version of this package.
    Azure Native v2.73.0 published on Wednesday, Nov 20, 2024 by Pulumi