use yamlencode for k3s configs...
...and remove the now, hopefully unneeded workaround for agent.conf, all values are in config.yaml now
This commit is contained in:
parent
e2d1ed3068
commit
960311ebd4
26
agents.tf
26
agents.tf
@ -59,27 +59,15 @@ resource "hcloud_server" "agents" {
|
|||||||
EOT
|
EOT
|
||||||
}
|
}
|
||||||
|
|
||||||
# Generating and uploading the angent.conf file
|
|
||||||
provisioner "file" {
|
|
||||||
content = templatefile("${path.module}/templates/agent.conf.tpl", {
|
|
||||||
server_url = "https://${local.first_control_plane_network_ip}:6443"
|
|
||||||
node_token = random_password.k3s_token.result
|
|
||||||
})
|
|
||||||
destination = "/etc/rancher/k3s/agent.conf"
|
|
||||||
|
|
||||||
connection {
|
|
||||||
user = "root"
|
|
||||||
private_key = local.ssh_private_key
|
|
||||||
agent_identity = local.ssh_identity
|
|
||||||
host = self.ipv4_address
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Generating k3s server config file
|
# Generating k3s server config file
|
||||||
provisioner "file" {
|
provisioner "file" {
|
||||||
content = templatefile("${path.module}/templates/agent_config.yaml.tpl", {
|
content = yamlencode({
|
||||||
node_ip = cidrhost(hcloud_network.k3s.ip_range, 2 + var.servers_num + count.index)
|
node-name = self.name
|
||||||
node_name = self.name
|
server = "https://${local.first_control_plane_network_ip}:6443"
|
||||||
|
kubelet-arg = "cloud-provider=external"
|
||||||
|
flannel-iface = "eth1"
|
||||||
|
node-ip = local.first_control_plane_network_ip
|
||||||
|
token = random_password.k3s_token.result
|
||||||
})
|
})
|
||||||
destination = "/etc/rancher/k3s/config.yaml"
|
destination = "/etc/rancher/k3s/config.yaml"
|
||||||
|
|
||||||
|
15
master.tf
15
master.tf
@ -59,11 +59,16 @@ resource "hcloud_server" "first_control_plane" {
|
|||||||
|
|
||||||
# Generating k3s master config file
|
# Generating k3s master config file
|
||||||
provisioner "file" {
|
provisioner "file" {
|
||||||
content = templatefile("${path.module}/templates/master_config.yaml.tpl", {
|
content = yamlencode({
|
||||||
node_ip = local.first_control_plane_network_ip
|
node-name = self.name
|
||||||
token = random_password.k3s_token.result
|
cluster-init = true
|
||||||
node_name = self.name
|
disable-cloud-controller = true
|
||||||
allow_scheduling_on_control_plane = var.allow_scheduling_on_control_plane
|
disable = "servicelb, local-storage"
|
||||||
|
flannel-iface = "eth1"
|
||||||
|
kubelet-arg = "cloud-provider=external"
|
||||||
|
node-ip = local.first_control_plane_network_ip
|
||||||
|
advertise-address = local.first_control_plane_network_ip
|
||||||
|
token = random_password.k3s_token.result
|
||||||
})
|
})
|
||||||
destination = "/etc/rancher/k3s/config.yaml"
|
destination = "/etc/rancher/k3s/config.yaml"
|
||||||
|
|
||||||
|
18
servers.tf
18
servers.tf
@ -60,12 +60,18 @@ resource "hcloud_server" "control_planes" {
|
|||||||
|
|
||||||
# Generating k3s server config file
|
# Generating k3s server config file
|
||||||
provisioner "file" {
|
provisioner "file" {
|
||||||
content = templatefile("${path.module}/templates/server_config.yaml.tpl", {
|
content = yamlencode({
|
||||||
first_control_plane_url = "https://${local.first_control_plane_network_ip}:6443"
|
node-name = self.name
|
||||||
node_ip = cidrhost(hcloud_network.k3s.ip_range, 3 + count.index)
|
server = "https://${local.first_control_plane_network_ip}:6443"
|
||||||
token = random_password.k3s_token.result
|
cluster-init = true
|
||||||
node_name = self.name
|
disable-cloud-controller = true
|
||||||
allow_scheduling_on_control_plane = var.allow_scheduling_on_control_plane
|
disable = "servicelb, local-storage"
|
||||||
|
flannel-iface = "eth1"
|
||||||
|
kubelet-arg = "cloud-provider=external"
|
||||||
|
node-ip = cidrhost(hcloud_network.k3s.ip_range, 3 + count.index)
|
||||||
|
advertise-address = cidrhost(hcloud_network.k3s.ip_range, 3 + count.index)
|
||||||
|
tls-san = cidrhost(hcloud_network.k3s.ip_range, 3 + count.index)
|
||||||
|
token = random_password.k3s_token.result
|
||||||
})
|
})
|
||||||
destination = "/etc/rancher/k3s/config.yaml"
|
destination = "/etc/rancher/k3s/config.yaml"
|
||||||
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
SERVER_URL="${server_url}"
|
|
||||||
NODE_TOKEN="${node_token}"
|
|
||||||
AGENT_OPTS=
|
|
@ -1,4 +0,0 @@
|
|||||||
node-ip: ${node_ip}
|
|
||||||
kubelet-arg: "cloud-provider=external"
|
|
||||||
flannel-iface: eth1
|
|
||||||
node-name: ${node_name}
|
|
@ -1,16 +0,0 @@
|
|||||||
cluster-init: true
|
|
||||||
disable-cloud-controller: true
|
|
||||||
disable:
|
|
||||||
- servicelb
|
|
||||||
- local-storage
|
|
||||||
flannel-iface: eth1
|
|
||||||
node-ip: ${node_ip}
|
|
||||||
advertise-address: ${node_ip}
|
|
||||||
tls-san: ${node_ip}
|
|
||||||
kubelet-arg: "cloud-provider=external"
|
|
||||||
token: ${token}
|
|
||||||
node-name: ${node_name}
|
|
||||||
%{ if !allow_scheduling_on_control_plane }
|
|
||||||
node-taint:
|
|
||||||
- node-role.kubernetes.io/master:NoSchedule
|
|
||||||
%{ endif }
|
|
@ -1,16 +0,0 @@
|
|||||||
server: ${first_control_plane_url}
|
|
||||||
disable-cloud-controller: true
|
|
||||||
disable:
|
|
||||||
- servicelb
|
|
||||||
- local-storage
|
|
||||||
flannel-iface: eth1
|
|
||||||
node-ip: ${node_ip}
|
|
||||||
advertise-address: ${node_ip}
|
|
||||||
tls-san: ${node_ip}
|
|
||||||
kubelet-arg: "cloud-provider=external"
|
|
||||||
token: ${token}
|
|
||||||
node-name: ${node_name}
|
|
||||||
%{ if !allow_scheduling_on_control_plane }
|
|
||||||
node-taint:
|
|
||||||
- node-role.kubernetes.io/master:NoSchedule
|
|
||||||
%{ endif }
|
|
Loading…
Reference in New Issue
Block a user