-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathkubernetes.tf
68 lines (59 loc) · 1.92 KB
/
kubernetes.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
provider "scaleway" {
organization = "${var.organization_key}"
token = "${var.secret_key}"
region = "${var.region}"
}
resource "scaleway_server" "kubernetes_master" {
name = "${format("${var.kubernetes_cluster_name}-master-%02d", count.index)}"
image = "${var.base_image_id}"
dynamic_ip_required = "${var.dynamic_ip}"
type = "${var.scaleway_master_type}"
connection {
user = "${var.user}"
private_key = "${file(var.kubernetes_ssh_key_path)}"
}
provisioner "local-exec" {
command = "rm -rf ./scw-install.sh ./scw-install-master.sh"
}
provisioner "local-exec" {
command = "echo ${format("MASTER_%02d", count.index)}=\"${self.public_ip}\" >> ips.txt"
}
provisioner "local-exec" {
command = "echo CLUSTER_NAME=\"${var.kubernetes_cluster_name}\" >> ips.txt"
}
provisioner "local-exec" {
command = "./make-files.sh"
}
provisioner "local-exec" {
command = "while [ ! -f ./scw-install.sh ]; do sleep 1; done"
}
provisioner "file" {
source = "./scw-install.sh"
destination = "/tmp/scw-install.sh"
}
provisioner "remote-exec" {
inline = "KUBERNETES_TOKEN=\"${var.kubernetes_token}\" bash /tmp/scw-install.sh master"
}
}
resource "scaleway_server" "kubernetes_slave" {
name = "${format("${var.kubernetes_cluster_name}-slave-%02d", count.index)}"
depends_on = ["scaleway_server.kubernetes_master"]
image = "${var.base_image_id}"
dynamic_ip_required = "${var.dynamic_ip}"
type = "${var.scaleway_slave_type}"
count = "${var.kubernetes_slave_count}"
connection {
user = "${var.user}"
private_key = "${file(var.kubernetes_ssh_key_path)}"
}
provisioner "local-exec" {
command = "while [ ! -f ./scw-install.sh ]; do sleep 1; done"
}
provisioner "file" {
source = "scw-install.sh"
destination = "/tmp/scw-install.sh"
}
provisioner "remote-exec" {
inline = "KUBERNETES_TOKEN=\"${var.kubernetes_token}\" bash /tmp/scw-install.sh slave"
}
}