Skip to main content

Azure Kubernetes Service (AKS) cluster using the native Azure provider

A C# Pulumi program to provision an Azure Kubernetes Service (AKS) cluster

This example lives in the pulumi/examples repository. Check out just this directory to use it:

Get started with this example
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examples
git -C pulumi-examples sparse-checkout set azure-cs-aks
cd pulumi-examples/azure-cs-aks

This example deploys an AKS cluster, creates an Azure Active AD application, creates a Service Principal and sets credentials to manage access to the cluster.

Prerequisites#

  1. Install Pulumi
  2. Configure Azure credentials
  3. Install .NET

Deploying the example#

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

    Terminal window
    pulumi stack init dev
  2. Login to the Azure CLI (you will be prompted to do this during deployment if you forget this step):

    Terminal window
    az login
  3. Set the Azure location in which to deploy:

    Terminal window
    pulumi config set azure-native:location westus2
  4. Stand up the cluster by running pulumi up:

    Terminal window
    pulumi up
  5. After 3-4 minutes, your cluster will be ready, and the kubeconfig YAML you’ll use to connect to the cluster will be available as an output. You can save this kubeconfig to a file like so:

    Terminal window
    pulumi stack output kubeconfig --show-secrets > kubeconfig.yaml

    Once you have this file in hand, you can interact with your new cluster as usual via kubectl:

    Terminal window
    KUBECONFIG=./kubeconfig.yaml kubectl get nodes
  6. From there, feel free to experiment. Simply making edits and running pulumi up will incrementally update your stack.

Cleaning up#

Once you’ve finished experimenting, destroy your stack and remove it:

Terminal window
pulumi destroy --yes
pulumi stack rm --yes

Related

The infrastructure as code platform for any cloud.