forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
59 lines (54 loc) · 1.81 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright 2016-2018, Pulumi Corporation. All rights reserved.
import * as azure from "@pulumi/azure";
import * as pulumi from "@pulumi/pulumi";
import * as config from "./config";
// Per-cluster config
const aksClusterConfig = [
{
name: 'east',
location: "East US",
nodeCount: 2,
nodeSize: "Standard_D2_v2",
},
{
name: 'west',
location: "West US",
nodeCount: 5,
nodeSize: "Standard_D2_v2",
},
];
// Create the AD service principal for the K8s cluster.
const adApp = new azure.ad.Application("aks");
const adSp = new azure.ad.ServicePrincipal("aksSp", {applicationId: adApp.applicationId});
const adSpPassword = new azure.ad.ServicePrincipalPassword("aksSpPassword", {
servicePrincipalId: adSp.id,
value: config.password,
endDate: "2099-01-01T00:00:00Z",
});
// Create the individual clusters
const k8sClusters = aksClusterConfig.map((perClusterConfig, index) => {
const cluster = new azure.containerservice.KubernetesCluster(`aksCluster-${perClusterConfig.name}`, {
// Global config arguments
resourceGroupName: config.resourceGroup.name,
linuxProfile: {
adminUsername: "aksuser",
sshKeys: [{
keyData: config.sshPublicKey,
}],
},
servicePrincipal: {
clientId: adApp.applicationId,
clientSecret: adSpPassword.value,
},
// Per-cluster config arguments
location: perClusterConfig.location,
agentPoolProfile: {
name: "aksagentpool",
count: perClusterConfig.nodeCount,
vmSize: perClusterConfig.nodeSize,
},
dnsPrefix: `${pulumi.getStack()}-kube`,
});
return cluster;
});
export const aksClusterNames = k8sClusters.map(cluster => cluster.name);