-
Notifications
You must be signed in to change notification settings - Fork 0
/
34-anthos-deploy-clusters.tf
178 lines (159 loc) · 6.79 KB
/
34-anthos-deploy-clusters.tf
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
data "template_file" "anthos_deploy_cluster_script" {
template = file("anthos/deploy_clusters.py")
vars = {
private_subnets = jsonencode(var.private_subnets)
vsphere_network = var.anthos_deploy_network
create_anthos_cluster = var.anthos_deploy_clusters
}
}
data "template_file" "anthos_tf_deploy_cluster" {
template = file("anthos/cluster_tf.sh")
vars = {
anthos_deploy_clusters = var.anthos_deploy_clusters
}
}
data "template_file" "anthos_finish_cluster" {
template = file("anthos/cluster/finish_cluster.sh")
vars = {
anthos_user_cluster_name = var.anthos_user_cluster_name
ksa_token_path = "/home/ubuntu/cluster/ksa_token.txt"
}
}
data "template_file" "anthos_cluster_config" {
template = file("anthos/cluster/bundled-lb-admin-uc1-config.yaml")
vars = {
vcenter_user = "[email protected]"
vcenter_pass = random_string.sso_password.result
vcenter_fqdn = format("vcva.%s", var.domain_name)
vcenter_datastore = var.anthos_datastore
vcenter_datacenter = var.vcenter_datacenter_name
vcenter_cluster = var.vcenter_cluster_name
resource_pool = var.anthos_resource_pool_name
deploy_network = var.anthos_deploy_network
anthos_version = var.anthos_version
admin_service_cidr = var.anthos_admin_service_cidr
admin_pod_cidr = var.anthos_admin_pod_cidr
user_cluster_name = var.anthos_user_cluster_name
user_service_cidr = var.anthos_user_service_cidr
user_pod_cidr = var.anthos_user_pod_cidr
gcp_project_id = var.anthos_gcp_project_id
gcp_region = var.anthos_gcp_region
anthos_user_master_replicas = var.anthos_user_master_replicas
anthos_user_worker_replicas = var.anthos_user_worker_replicas
anthos_user_vcpu = var.anthos_user_vcpu
anthos_user_memory_mb = var.anthos_user_memory_mb
whitelisted_key_name = var.whitelisted_key_name
connect_key_name = var.connect_key_name
register_key_name = var.register_key_name
stackdriver_key_name = var.stackdriver_key_name
}
}
data "template_file" "anthos_admin_cluster_config" {
template = file("anthos/cluster/admin-cluster-config.yaml")
vars = {
vcenter_user = "[email protected]"
vcenter_pass = random_string.sso_password.result
vcenter_fqdn = format("vcva.%s", var.domain_name)
vcenter_datastore = var.anthos_datastore
vcenter_datacenter = var.vcenter_datacenter_name
vcenter_cluster = var.vcenter_cluster_name
resource_pool = var.anthos_resource_pool_name
deploy_network = var.anthos_deploy_network
anthos_version = var.anthos_version
admin_service_cidr = var.anthos_admin_service_cidr
admin_pod_cidr = var.anthos_admin_pod_cidr
gcp_project_id = var.anthos_gcp_project_id
gcp_region = var.anthos_gcp_region
whitelisted_key_name = var.whitelisted_key_name
stackdriver_key_name = var.stackdriver_key_name
}
}
data "template_file" "anthos_user_cluster_config" {
template = file("anthos/cluster/user-cluster1-config.yaml")
vars = {
anthos_version = var.anthos_version
user_cluster_name = var.anthos_user_cluster_name
user_service_cidr = var.anthos_user_service_cidr
user_pod_cidr = var.anthos_user_pod_cidr
gcp_project_id = var.anthos_gcp_project_id
gcp_region = var.anthos_gcp_region
anthos_user_master_replicas = var.anthos_user_master_replicas
anthos_user_worker_replicas = var.anthos_user_worker_replicas
anthos_user_vcpu = var.anthos_user_vcpu
anthos_user_memory_mb = var.anthos_user_memory_mb
whitelisted_key_name = var.whitelisted_key_name
connect_key_name = var.connect_key_name
register_key_name = var.register_key_name
stackdriver_key_name = var.stackdriver_key_name
}
}
data "template_file" "anthos_cluster_creation_script" {
template = file("anthos/cluster/bundled-lb-install-script.sh")
vars = {
vcenter_user = "[email protected]"
vcenter_pass = random_string.sso_password.result
vcenter_fqdn = format("vcva.%s", var.domain_name)
vcenter_datastore = var.anthos_datastore
vcenter_datacenter = var.vcenter_datacenter_name
whitelisted_key_name = var.whitelisted_key_name
anthos_user_cluster_name = var.anthos_user_cluster_name
esxi_host_count = var.esxi_host_count
}
}
resource "null_resource" "anthos_deploy_cluster" {
count = var.anthos_deploy_workstation_prereqs ? 1 : 0
depends_on = [null_resource.anthos_deploy_workstation]
connection {
type = "ssh"
user = "root"
private_key = file("~/.ssh/${local.ssh_key_name}")
host = packet_device.router.access_public_ipv4
}
provisioner "file" {
content = data.template_file.anthos_deploy_cluster_script.rendered
destination = "/root/anthos/deploy_clusters.py"
}
provisioner "file" {
content = data.template_file.anthos_tf_deploy_cluster.rendered
destination = "/root/anthos/cluster_tf.sh"
}
provisioner "file" {
content = data.template_file.anthos_cluster_config.rendered
destination = "/root/anthos/cluster/bundled-lb-admin-uc1-config.yaml"
}
provisioner "file" {
content = data.template_file.anthos_admin_cluster_config.rendered
destination = "/root/anthos/cluster/admin-cluster-config.yaml"
}
provisioner "file" {
content = data.template_file.anthos_user_cluster_config.rendered
destination = "/root/anthos/cluster/user-cluster1-config.yaml"
}
provisioner "file" {
content = data.template_file.anthos_cluster_creation_script.rendered
destination = "/root/anthos/cluster/bundled-lb-install-script.sh"
}
provisioner "file" {
source = "anthos/cluster/admin-lb-ipblock.yaml"
destination = "/root/anthos/cluster/admin-lb-ipblock.yaml"
}
provisioner "file" {
source = "anthos/cluster/usercluster-1-lb-ipblock.yaml"
destination = "/root/anthos/cluster/usercluster-1-lb-ipblock.yaml"
}
provisioner "file" {
source = "anthos/cluster/deploy_cluster.tf.tpl"
destination = "/root/anthos/cluster/deploy_cluster.tf"
}
provisioner "file" {
content = data.template_file.anthos_finish_cluster.rendered
destination = "/root/anthos/cluster/finish_cluster.sh"
}
provisioner "remote-exec" {
inline = [
"cp /root/anthos/gcp_keys/* /root/anthos/cluster/",
"python3 /root/anthos/deploy_clusters.py",
"bash /root/anthos/cluster_tf.sh"
]
}
}