Skip to content

Latest commit

 

History

History
 
 

azure-cs-aks-private-container-registry

Deploy

Azure Kubernetes Service (AKS) Cluster + Build & Deploy from Private Container Registry

This sample setup demonstrates the following:

  • Stands up an Azure Kubernetes Service (AKS) cluster.
  • Creates an Azure Container Registry.
  • Builds & pushes a sample application as a Docker image to the registry.
  • Deploys the sample application from the registry onto the cluster.
  • Exports a container registry secret for use by other stacks. For example, "service" projects that create kubernetes deployments that need to be able to pull images from the registry.

Deploying the App

To deploy your infrastructure, follow the below steps.

Prerequisites

  1. Install Pulumi
  2. Install .NET Core 3.1+

Steps

  1. Create a new stack:

    $ pulumi stack init
    Enter a stack name: dev
  2. Set the required configuration variable for this program:

    $ pulumi config set azure:location westus
    $ az login
  3. Stand up the AKS cluster:

    Note: Due to an issue in Azure Terraform Provider, the creation of an Azure Service Principal, which is needed to create the Kubernetes cluster, 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 replication should have been completed. See this issue and this doc for further details.

    $ pulumi up
  4. After 10-15 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:

    $ pulumi stack output KubeConfig > kubeconfig.yaml

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

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

  6. Once you've finished experimenting, tear down your stack's resources by destroying and removing it:

    $ pulumi destroy --yes
    $ pulumi stack rm --yes