-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinodes.tf
More file actions
125 lines (105 loc) · 5.07 KB
/
linodes.tf
File metadata and controls
125 lines (105 loc) · 5.07 KB
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
data "template_file" "control-plane-init" {
depends_on = [cockroach_cluster.rancherdb] # linode_database_postgresql.rancherdb
template = file("${path.module}/templates/control-plane-init.tpl")
vars = {
####
# https://www.linode.com/community/questions/24834/postgresql-managed-database-404
# Linode has PAUSED managed database provisioning.
####
# RANCHER_DATA_SOURCE = format("postgresql://%s:%s@%s:5432/console", linode_database_postgresql.rancherdb.root_username, linode_database_postgresql.rancherdb.root_password, linode_database_postgresql.rancherdb.host_primary)
RANCHER_DATA_SOURCE = "postgres://${cockroach_sql_user.rancherdb.name}:${random_string.rancherdb_password.result}@${cockroach_cluster.rancherdb.regions.0.sql_dns}:26257/rancherdb?sslmode=require"
GENERATED_K3S_TOKEN = random_string.k3s_token.result
LOAD_BALANCER_VIP = linode_nodebalancer.kubernetes_lb.ipv4
}
}
resource "linode_stackscript" "control-plane-init" {
label = "Initialize Rancher k3s Control Plane"
description = "Initialization script for Rancher k3s control plane."
script = data.template_file.control-plane-init.rendered
images = ["linode/opensuse15.6"]
is_public = false
}
resource "linode_instance" "control-plane-init" {
depends_on = [cockroach_cluster.rancherdb, linode_nodebalancer.kubernetes_lb] # linode_database_postgresql.rancherdb
label = "${var.cluster_name}-control-plane-00"
image = "linode/opensuse15.6"
region = var.cluster_region
type = var.control_plane_size
authorized_keys = [local_file.cluster_public_key.content]
interface {
purpose = "public"
}
stackscript_id = linode_stackscript.control-plane-init.id
tags = ["${var.cluster_name}-control-plane"]
swap_size = 256
private_ip = false
}
data "template_file" "control-plane-replica" {
depends_on = [cockroach_cluster.rancherdb, linode_instance.control-plane-init] # linode_database_postgresql.rancherdb
template = file("${path.module}/templates/control-plane-replica.tpl")
vars = {
####
# https://www.linode.com/community/questions/24834/postgresql-managed-database-404
# Linode has PAUSED managed database provisioning.
####
# RANCHER_DATA_SOURCE = format("postgresql://%s:%s@%s:5432/console", linode_database_postgresql.rancherdb.root_username, linode_database_postgresql.rancherdb.root_password, linode_database_postgresql.rancherdb.host_primary)
RANCHER_DATA_SOURCE = "postgres://${cockroach_sql_user.rancherdb.name}:${random_string.rancherdb_password.result}@${cockroach_cluster.rancherdb.regions.0.sql_dns}:26257/rancherdb?sslmode=require"
GENERATED_K3S_TOKEN = random_string.k3s_token.result
LOAD_BALANCER_VIP = linode_nodebalancer.kubernetes_lb.ipv4
CONTROL_PLANE_INIT_IP = linode_instance.control-plane-init.ip_address
}
}
resource "linode_stackscript" "control-plane-replica" {
label = "Initialize Rancher k3s Control Plane"
description = "Initialization script for Rancher k3s control plane."
script = data.template_file.control-plane-replica.rendered
images = ["linode/opensuse15.6"]
is_public = false
}
resource "linode_instance" "control-plane-replica" {
depends_on = [cockroach_cluster.rancherdb, linode_nodebalancer.kubernetes_lb] # linode_database_postgresql.rancherdb
label = format("${var.cluster_name}-control-plane-%02d", count.index + 1)
image = "linode/opensuse15.6"
region = var.cluster_region
type = var.control_plane_size
count = var.controller_peer_count
authorized_keys = [local_file.cluster_public_key.content]
interface {
purpose = "public"
}
stackscript_id = linode_stackscript.control-plane-replica.id
tags = ["${var.cluster_name}-control-plane"]
swap_size = 256
private_ip = false
}
data "template_file" "node" {
depends_on = [cockroach_cluster.rancherdb, linode_instance.control-plane-init, linode_nodebalancer.kubernetes_lb] # linode_database_postgresql.rancherdb
template = file("${path.module}/templates/node.tpl")
vars = {
K3S_CONTROLLER_IP = linode_nodebalancer.kubernetes_lb.ipv4
GENERATED_K3S_TOKEN = random_string.k3s_token.result
}
}
resource "linode_stackscript" "node" {
label = "Initialize Rancher k3s worker node"
description = "Initialization script for Rancher k3s worker nodes."
script = data.template_file.node.rendered
images = ["linode/opensuse15.6"]
is_public = false
}
resource "linode_instance" "node" {
depends_on = [cockroach_cluster.rancherdb, linode_nodebalancer.kubernetes_lb] # linode_database_postgresql.rancherdb
label = format("${var.cluster_name}-worker-%02d", count.index)
image = "linode/opensuse15.6"
region = var.cluster_region
type = var.node_size
count = var.worker_node_count
authorized_keys = [local_file.cluster_public_key.content]
interface {
purpose = "public"
}
stackscript_id = linode_stackscript.node.id
tags = ["${var.cluster_name}-worker"]
swap_size = 256
private_ip = false
}