-
Notifications
You must be signed in to change notification settings - Fork 9
/
create_kafka_cluster_sample.py
95 lines (88 loc) · 3.58 KB
/
create_kafka_cluster_sample.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
from azure.mgmt.hdinsight import HDInsightManagementClient
from azure.common.credentials import ServicePrincipalCredentials
from sample_settings import *
from azure.mgmt.hdinsight.models import *
def main():
# Authentication
credentials = ServicePrincipalCredentials(
client_id=CLIENT_ID,
secret=CLIENT_SECRET,
tenant=TENANT_ID
)
client = HDInsightManagementClient(credentials, SUBSCRIPTION_ID)
# Prepare cluster create parameters
create_params = ClusterCreateParametersExtended(
location=LOCATION,
tags={},
properties=ClusterCreateProperties(
cluster_version="3.6",
os_type=OSType.linux,
tier=Tier.standard,
cluster_definition=ClusterDefinition(
kind="Kafka",
configurations={
"gateway": {
"restAuthCredential.isEnabled": "true",
"restAuthCredential.username": CLUSTER_LOGIN_USER_NAME,
"restAuthCredential.password": PASSWORD
}
}
),
compute_profile=ComputeProfile(
roles=[
Role(
name="headnode",
target_instance_count=2,
hardware_profile=HardwareProfile(vm_size="Large"),
os_profile=OsProfile(
linux_operating_system_profile=LinuxOperatingSystemProfile(
username=SSH_USER_NAME,
password=PASSWORD
)
)
),
Role(
name="workernode",
target_instance_count=3,
hardware_profile=HardwareProfile(vm_size="Large"),
os_profile=OsProfile(
linux_operating_system_profile=LinuxOperatingSystemProfile(
username=SSH_USER_NAME,
password=PASSWORD
)
),
data_disks_groups = [
DataDisksGroups(
disks_per_node=2
)
]
),
Role(
name="zookeepernode",
target_instance_count=3,
hardware_profile=HardwareProfile(vm_size="Small"),
os_profile=OsProfile(
linux_operating_system_profile=LinuxOperatingSystemProfile(
username=SSH_USER_NAME,
password=PASSWORD
)
)
)
]
),
storage_profile=StorageProfile(
storageaccounts=[
StorageAccount(
name=STORAGE_ACCOUNT_NAME + BLOB_ENDPOINT_SUFFIX,
key=STORAGE_ACCOUNT_KEY,
container=CONTAINER_NAME.lower(),
is_default=True
)
]
)
)
)
print('Starting to create to create HDInsight Kafka cluster {}'.format(CLUSTER_NAME))
client.clusters.create(RESOURCE_GROUP_NAME, CLUSTER_NAME, create_params)
if __name__ == "__main__":
main()