Skip to content

Latest commit

 

History

History

azure-go-aks-helm

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Deploy

Azure Kubernetes Service (AKS) Cluster and Helm Chart

This example demonstrates creating an Azure Kubernetes Service (AKS) cluster and deploying a Helm Chart from Bitnami Helm chart repository into this cluster, all in one Pulumi program.

The example showcases the native Azure provider for Pulumi.

Prerequisites

Running the Example

In this example we will provision a Kubernetes cluster running a public Apache web server, verify we can access it, and clean up when done.

  1. Get the code:

    $ git clone [email protected]:pulumi/examples.git
    $ cd examples/azure-go-aks-helm
  2. Restore dependencies and build:

    $ go build
  3. Create a new stack, which is an isolated deployment target for this example:

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

    $ pulumi config set azure-native:location westus2
  5. Deploy everything with the pulumi up command. This provisions all the Azure resources necessary, including an Active Directory service principal, AKS cluster, and then deploys the Apache Helm Chart, all in a single gesture (takes 5-10 min):

    $ pulumi up
  6. Now your cluster and Apache server are ready. Several output variables will be printed, including your cluster name (clusterName), Kubernetes config (kubeconfig) and server IP address (apacheServiceIP).

    Using these output variables, you may access your Apache server:

    $ curl $(pulumi stack output apacheServiceIP)
    <html><body><h1>It works!</h1></body></html>

    And you may also configure your kubectl client using the kubeConfig configuration:

    $ pulumi stack output kubeconfig --show-secrets > kubeconfig.yaml
    $ KUBECONFIG=./kubeconfig.yaml kubectl get service
    
    NAME           TYPE           CLUSTER-IP     EXTERNAL-IP      PORT(S)                      AGE
    apache-chart   LoadBalancer   10.0.154.121   40.125.100.104   80:30472/TCP,443:30364/TCP   8m
    kubernetes     ClusterIP      10.0.0.1       <none>           443/TCP                      8m
  7. At this point, you have a running cluster. 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. This could be altering the existing chart, adding new Azure or Kubernetes resources, or anything, really.

    TIP: if you make changes to the example code outside of an IDE, run the Go compiler after every change:

    $ go build
  8. Once you are done, you can destroy all of the resources, and the stack:

    $ pulumi destroy
    $ pulumi stack rm
    $ rm kubeconfig.yaml