2018-05-17 07:37:37 +02:00
|
|
|
locals {
|
2020-10-21 09:02:29 +02:00
|
|
|
# flatcar-stable -> stable channel
|
2019-10-06 21:57:15 +02:00
|
|
|
channel = split("-", var.os_channel)[1]
|
2018-05-17 07:37:37 +02:00
|
|
|
}
|
|
|
|
|
2020-10-21 09:02:29 +02:00
|
|
|
// Flatcar Linux install profile (from release.flatcar-linux.net)
|
|
|
|
resource "matchbox_profile" "flatcar-install" {
|
2019-10-06 21:57:15 +02:00
|
|
|
count = length(var.controllers) + length(var.workers)
|
2020-10-21 09:02:29 +02:00
|
|
|
name = format("%s-flatcar-install-%s", var.cluster_name, concat(var.controllers.*.name, var.workers.*.name)[count.index])
|
2018-01-14 21:36:40 +01:00
|
|
|
|
2020-10-21 09:02:29 +02:00
|
|
|
kernel = "${var.download_protocol}://${local.channel}.release.flatcar-linux.net/amd64-usr/${var.os_version}/flatcar_production_pxe.vmlinuz"
|
2017-07-25 08:16:34 +02:00
|
|
|
|
|
|
|
initrd = [
|
2020-10-21 09:02:29 +02:00
|
|
|
"${var.download_protocol}://${local.channel}.release.flatcar-linux.net/amd64-usr/${var.os_version}/flatcar_production_pxe_image.cpio.gz",
|
2017-07-25 08:16:34 +02:00
|
|
|
]
|
|
|
|
|
2019-05-29 04:19:23 +02:00
|
|
|
args = flatten([
|
2020-10-21 09:02:29 +02:00
|
|
|
"initrd=flatcar_production_pxe_image.cpio.gz",
|
|
|
|
"flatcar.config.url=${var.matchbox_http_endpoint}/ignition?uuid=$${uuid}&mac=$${mac:hexhyp}",
|
|
|
|
"flatcar.first_boot=yes",
|
2019-05-29 04:19:23 +02:00
|
|
|
var.kernel_args,
|
|
|
|
])
|
2017-07-25 08:16:34 +02:00
|
|
|
|
2020-10-21 09:02:29 +02:00
|
|
|
container_linux_config = data.template_file.install-configs.*.rendered[count.index]
|
2017-07-25 08:16:34 +02:00
|
|
|
}
|
|
|
|
|
2020-10-21 09:02:29 +02:00
|
|
|
// Flatcar Linux Install profile (from matchbox /assets cache)
|
|
|
|
// Note: Admin must have downloaded os_version into matchbox assets/flatcar.
|
|
|
|
resource "matchbox_profile" "cached-flatcar-install" {
|
2019-10-06 21:57:15 +02:00
|
|
|
count = length(var.controllers) + length(var.workers)
|
2020-10-21 09:02:29 +02:00
|
|
|
name = format("%s-cached-flatcar-linux-install-%s", var.cluster_name, concat(var.controllers.*.name, var.workers.*.name)[count.index])
|
2018-01-14 21:36:40 +01:00
|
|
|
|
2020-10-21 09:02:29 +02:00
|
|
|
kernel = "/assets/flatcar/${var.os_version}/flatcar_production_pxe.vmlinuz"
|
2017-07-25 08:16:34 +02:00
|
|
|
|
|
|
|
initrd = [
|
2020-10-21 09:02:29 +02:00
|
|
|
"/assets/flatcar/${var.os_version}/flatcar_production_pxe_image.cpio.gz",
|
2017-07-25 08:16:34 +02:00
|
|
|
]
|
|
|
|
|
2019-05-29 04:19:23 +02:00
|
|
|
args = flatten([
|
2020-10-21 09:02:29 +02:00
|
|
|
"initrd=flatcar_production_pxe_image.cpio.gz",
|
|
|
|
"flatcar.config.url=${var.matchbox_http_endpoint}/ignition?uuid=$${uuid}&mac=$${mac:hexhyp}",
|
|
|
|
"flatcar.first_boot=yes",
|
2019-05-29 04:19:23 +02:00
|
|
|
var.kernel_args,
|
|
|
|
])
|
2017-07-25 08:16:34 +02:00
|
|
|
|
2020-10-21 09:02:29 +02:00
|
|
|
container_linux_config = data.template_file.cached-install-configs.*.rendered[count.index]
|
2017-07-25 08:16:34 +02:00
|
|
|
}
|
|
|
|
|
2020-10-21 09:02:29 +02:00
|
|
|
data "template_file" "install-configs" {
|
2019-10-06 21:57:15 +02:00
|
|
|
count = length(var.controllers) + length(var.workers)
|
2018-01-14 21:36:40 +01:00
|
|
|
|
2019-12-28 21:07:10 +01:00
|
|
|
template = file("${path.module}/cl/install.yaml")
|
2017-07-25 08:16:34 +02:00
|
|
|
|
2019-03-12 09:19:54 +01:00
|
|
|
vars = {
|
2019-11-14 08:44:02 +01:00
|
|
|
os_channel = local.channel
|
|
|
|
os_version = var.os_version
|
|
|
|
ignition_endpoint = format("%s/ignition", var.matchbox_http_endpoint)
|
|
|
|
install_disk = var.install_disk
|
|
|
|
ssh_authorized_key = var.ssh_authorized_key
|
2020-10-21 09:02:29 +02:00
|
|
|
# only cached profile adds -b baseurl
|
|
|
|
baseurl_flag = ""
|
2017-07-25 08:16:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-21 09:02:29 +02:00
|
|
|
data "template_file" "cached-install-configs" {
|
2019-10-06 21:57:15 +02:00
|
|
|
count = length(var.controllers) + length(var.workers)
|
2018-05-17 08:30:48 +02:00
|
|
|
|
2020-10-21 09:02:29 +02:00
|
|
|
template = file("${path.module}/cl/install.yaml")
|
2018-05-17 08:30:48 +02:00
|
|
|
|
2020-10-21 09:02:29 +02:00
|
|
|
vars = {
|
|
|
|
os_channel = local.channel
|
|
|
|
os_version = var.os_version
|
|
|
|
ignition_endpoint = format("%s/ignition", var.matchbox_http_endpoint)
|
|
|
|
install_disk = var.install_disk
|
|
|
|
ssh_authorized_key = var.ssh_authorized_key
|
|
|
|
# profile uses -b baseurl to install from matchbox cache
|
|
|
|
baseurl_flag = "-b ${var.matchbox_http_endpoint}/assets/flatcar"
|
|
|
|
}
|
2018-05-17 08:30:48 +02:00
|
|
|
}
|
|
|
|
|
2018-10-15 11:27:32 +02:00
|
|
|
|
2017-09-23 20:49:12 +02:00
|
|
|
// Kubernetes Controller profiles
|
|
|
|
resource "matchbox_profile" "controllers" {
|
2019-10-06 21:57:15 +02:00
|
|
|
count = length(var.controllers)
|
|
|
|
name = format("%s-controller-%s", var.cluster_name, var.controllers.*.name[count.index])
|
2022-08-03 03:15:03 +02:00
|
|
|
raw_ignition = data.ct_config.controllers.*.rendered[count.index]
|
2017-07-25 08:16:34 +02:00
|
|
|
}
|
|
|
|
|
2022-08-03 03:15:03 +02:00
|
|
|
# Flatcar Linux controllers
|
|
|
|
data "ct_config" "controllers" {
|
|
|
|
count = var.controller_count
|
|
|
|
content = templatefile("${path.module}/cl/controller.yaml", {
|
2019-10-06 21:57:15 +02:00
|
|
|
domain_name = var.controllers.*.domain[count.index]
|
|
|
|
etcd_name = var.controllers.*.name[count.index]
|
|
|
|
etcd_initial_cluster = join(",", formatlist("%s=https://%s:2380", var.controllers.*.name, var.controllers.*.domain))
|
2019-09-15 01:24:32 +02:00
|
|
|
cluster_dns_service_ip = module.bootstrap.cluster_dns_service_ip
|
2019-05-29 04:19:23 +02:00
|
|
|
cluster_domain_suffix = var.cluster_domain_suffix
|
|
|
|
ssh_authorized_key = var.ssh_authorized_key
|
2022-08-03 03:15:03 +02:00
|
|
|
})
|
|
|
|
strict = true
|
|
|
|
snippets = lookup(var.snippets, var.controllers.*.name[count.index], [])
|
2017-09-23 20:49:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Kubernetes Worker profiles
|
|
|
|
resource "matchbox_profile" "workers" {
|
2019-10-06 21:57:15 +02:00
|
|
|
count = length(var.workers)
|
|
|
|
name = format("%s-worker-%s", var.cluster_name, var.workers.*.name[count.index])
|
2022-08-03 03:15:03 +02:00
|
|
|
raw_ignition = data.ct_config.workers.*.rendered[count.index]
|
2018-07-26 07:44:07 +02:00
|
|
|
}
|
|
|
|
|
2022-08-03 03:15:03 +02:00
|
|
|
# Flatcar Linux workers
|
|
|
|
data "ct_config" "workers" {
|
2019-10-06 21:57:15 +02:00
|
|
|
count = length(var.workers)
|
2022-08-03 03:15:03 +02:00
|
|
|
content = templatefile("${path.module}/cl/worker.yaml", {
|
2019-10-06 21:57:15 +02:00
|
|
|
domain_name = var.workers.*.domain[count.index]
|
2019-09-15 01:24:32 +02:00
|
|
|
cluster_dns_service_ip = module.bootstrap.cluster_dns_service_ip
|
2019-05-29 04:19:23 +02:00
|
|
|
cluster_domain_suffix = var.cluster_domain_suffix
|
|
|
|
ssh_authorized_key = var.ssh_authorized_key
|
2020-03-09 04:39:18 +01:00
|
|
|
node_labels = join(",", lookup(var.worker_node_labels, var.workers.*.name[count.index], []))
|
|
|
|
node_taints = join(",", lookup(var.worker_node_taints, var.workers.*.name[count.index], []))
|
2022-08-03 03:15:03 +02:00
|
|
|
})
|
|
|
|
strict = true
|
|
|
|
snippets = lookup(var.snippets, var.workers.*.name[count.index], [])
|
2017-07-25 08:16:34 +02:00
|
|
|
}
|