-
Notifications
You must be signed in to change notification settings - Fork 0
/
cluster.tf
58 lines (46 loc) · 1.25 KB
/
cluster.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
variable "nb_controllers" {
type = number
default = 2
}
variable "nb_workers" {
type = number
default = 3
}
data "digitalocean_ssh_key" "default" {
name = "default"
}
data "digitalocean_domain" "k8s" {
name = "k8s.hackervaillant.eu"
}
resource "digitalocean_droplet" "controllers" {
count = var.nb_controllers
name = "controller-${count.index}.k8s.hackervaillant.eu"
image = "debian-10-x64"
region = "ams3"
size = "s-1vcpu-3gb"
ssh_keys = [data.digitalocean_ssh_key.default.fingerprint]
}
resource "digitalocean_droplet" "workers" {
count = var.nb_workers
name = "worker-${count.index}.k8s.hackervaillant.eu"
image = "debian-10-x64"
region = "ams3"
size = "s-1vcpu-3gb"
ssh_keys = [data.digitalocean_ssh_key.default.fingerprint]
}
resource "digitalocean_record" "controllers" {
count = var.nb_controllers
domain = data.digitalocean_domain.k8s.name
type = "A"
ttl = 30
name = "controller-${count.index}"
value = digitalocean_droplet.controllers[count.index].ipv4_address
}
resource "digitalocean_record" "workers" {
count = var.nb_workers
domain = data.digitalocean_domain.k8s.name
type = "A"
ttl = 30
name = "worker-${count.index}"
value = digitalocean_droplet.workers[count.index].ipv4_address
}