forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert AKS - Multicluster from TypeScript to Go (pulumi#729)
* 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
1 parent
f248f87
commit 3ba6c9a
Showing
7 changed files
with
497 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
Oops, something went wrong.