forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
__main__.py
56 lines (48 loc) · 1.73 KB
/
__main__.py
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
from pulumi import Config, get_stack, export, Output
import pulumi_azuread as ad
import pulumi_random as random
from pulumi_azure import core, containerservice
config = Config()
password = config.get_secret("password") or random.RandomPassword(
"pwd",
length=20,
special="true").result
ssh_public_key = config.require("sshPublicKey")
resource_group=core.ResourceGroup("aksresourcegroup")
ad_app = ad.Application("aks")
ad_sp = ad.ServicePrincipal(
"aksSp",
application_id=ad_app.application_id)
ad_sp_password = ad.ServicePrincipalPassword(
"aksSpPassword",
service_principal_id=ad_sp.id,
value=password,
end_date="2099-01-01T00:00:00Z")
aks_cluster_config = []
aks_cluster_config.append({"name": "east", "location": "eastus", "node_count": "2", "node_size": "Standard_D2_v2"})
aks_cluster_config.append({"name": "west", "location": "westus", "node_count": "2", "node_size": "Standard_D2_v2"})
cluster_names = []
for config in aks_cluster_config:
cluster = containerservice.KubernetesCluster(
"aksCluster-%s" % config["name"],
resource_group_name=resource_group.name,
linux_profile={
"admin_username": "aksuser",
"ssh_key": {
"key_data": ssh_public_key,
},
},
service_principal={
"client_id": ad_app.application_id,
"client_secret": ad_sp_password.value
},
location=config["location"],
default_node_pool={
"name": "aksagentpool",
"node_count": config["node_count"],
"vm_size": config["node_size"],
},
dns_prefix="sample-kube",
)
cluster_names.append(cluster.name)
export("aks_cluster_names", Output.all(cluster_names))