Skip to content

Commit

Permalink
Convert AKS - Multicluster from TypeScript to Go (pulumi#729)
Browse files Browse the repository at this point in the history
* Add azure-go-aks-multicluster

* Update README.md, add test

* Fix typo from index.ts to main.go

Co-authored-by: Justin Van Patten <[email protected]>

Co-authored-by: Justin Van Patten <[email protected]>
  • Loading branch information
albert-zhong and justinvp committed Jun 25, 2020
1 parent f248f87 commit 3ba6c9a
Show file tree
Hide file tree
Showing 7 changed files with 497 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ Example | Description |
Example | Description |
--------- | --------- |
[App Service](azure-go-appservice) | Build a web application hosted in Azure App Service.
[AKS - Multicluster](azure-go-aks-multicluster) | Create multiple Azure Kubernetes Service (AKS) Clusters in different regions and with different node counts.
[Web Server Component](azure-go-webserver-component) | Provision a configurable number of Linux web servers in an Azure Virtual Machine using a reusable component.

### C#
Expand Down
15 changes: 15 additions & 0 deletions azure-go-aks-multicluster/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: azure-go-aks-multicluster
runtime: go
description: Create multiple Azure Kubernetes Service (AKS) clusters in different regions and with different node counts
template:
config:
azure:environment:
description: The Azure environment to use (`public`, `usgovernment`, `german`, `china`)
default: public
password:
description: Your cluster password
secret: true
sshPublicKey:
description: Your SSH public key (generate with `ssh-keygen -t rsa -f key.rsa`)
location:
description: The location to use for the Azure Resource Group
71 changes: 71 additions & 0 deletions azure-go-aks-multicluster/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
[![Deploy](https://get.pulumi.com/new/button.svg)](https://app.pulumi.com/new)

# Multiple Azure Kubernetes Service (AKS) Clusters

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](https://www.pulumi.com/docs/get-started/install/).

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](https://azure.microsoft.com/en-us/free/).
[Follow the instructions here](https://www.pulumi.com/docs/intro/cloud-providers/azure/setup/) to connect Pulumi to your Azure account.

## Running the Example

> **Note**: Due to an issue in the Azure Terraform Provider (https://github.com/terraform-providers/terraform-provider-azurerm/issues/1635) the
> creation of an Azure Service Principal, which is needed to create the Kubernetes cluster (see main.go), 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:

```bash
$ pulumi stack init
```

2. Set the required configuration variables for this program:

```bash
$ pulumi config set azure: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:

```bash
$ 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.

```bash
$ pulumi up
...
Outputs:
+ aksClusterNames: [
+ [0]: "akscluster-east7f398a0b"
+ [1]: "akscluster-west7ee96bf1"
]
...
```

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:

```bash
$ pulumi destroy
$ pulumi stack rm
```
9 changes: 9 additions & 0 deletions azure-go-aks-multicluster/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module github.com/pulumi/examples/azure-go-aks

go 1.13

require (
github.com/pulumi/pulumi-azure/sdk/v3 v3.0.0
github.com/pulumi/pulumi-azuread/sdk/v2 v2.0.1
github.com/pulumi/pulumi/sdk/v2 v2.0.0
)
Loading

0 comments on commit 3ba6c9a

Please sign in to comment.