2018-05-17 07:37:37 +02:00
|
|
|
locals {
|
|
|
|
# coreos-stable -> coreos flavor, stable channel
|
2018-05-17 08:30:48 +02:00
|
|
|
# flatcar-stable -> flatcar flavor, stable channel
|
2019-11-14 08:44:02 +01:00
|
|
|
flavor = split("-", var.os_channel)[0]
|
2019-10-06 21:57:15 +02:00
|
|
|
channel = split("-", var.os_channel)[1]
|
2018-05-17 07:37:37 +02:00
|
|
|
}
|
|
|
|
|
2017-07-25 08:16:34 +02:00
|
|
|
// Container Linux Install profile (from release.core-os.net)
|
|
|
|
resource "matchbox_profile" "container-linux-install" {
|
2019-10-06 21:57:15 +02:00
|
|
|
count = length(var.controllers) + length(var.workers)
|
|
|
|
name = format("%s-container-linux-install-%s", var.cluster_name, concat(var.controllers.*.name, var.workers.*.name)[count.index])
|
2018-01-14 21:36:40 +01:00
|
|
|
|
2019-03-10 04:34:15 +01:00
|
|
|
kernel = "${var.download_protocol}://${local.channel}.release.core-os.net/amd64-usr/${var.os_version}/coreos_production_pxe.vmlinuz"
|
2017-07-25 08:16:34 +02:00
|
|
|
|
|
|
|
initrd = [
|
2019-03-10 04:34:15 +01:00
|
|
|
"${var.download_protocol}://${local.channel}.release.core-os.net/amd64-usr/${var.os_version}/coreos_production_pxe_image.cpio.gz",
|
2017-07-25 08:16:34 +02:00
|
|
|
]
|
|
|
|
|
2019-05-29 04:19:23 +02:00
|
|
|
args = flatten([
|
2017-11-17 08:19:51 +01:00
|
|
|
"initrd=coreos_production_pxe_image.cpio.gz",
|
2017-07-25 08:16:34 +02:00
|
|
|
"coreos.config.url=${var.matchbox_http_endpoint}/ignition?uuid=$${uuid}&mac=$${mac:hexhyp}",
|
|
|
|
"coreos.first_boot=yes",
|
|
|
|
"console=tty0",
|
|
|
|
"console=ttyS0",
|
2019-05-29 04:19:23 +02:00
|
|
|
var.kernel_args,
|
|
|
|
])
|
2017-07-25 08:16:34 +02:00
|
|
|
|
2019-10-06 21:57:15 +02:00
|
|
|
container_linux_config = data.template_file.container-linux-install-configs.*.rendered[count.index]
|
2017-07-25 08:16:34 +02:00
|
|
|
}
|
|
|
|
|
2018-01-14 21:36:40 +01:00
|
|
|
data "template_file" "container-linux-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_flavor = local.flavor
|
|
|
|
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
|
2017-07-25 08:16:34 +02:00
|
|
|
# only cached-container-linux profile adds -b baseurl
|
|
|
|
baseurl_flag = ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Container Linux Install profile (from matchbox /assets cache)
|
2018-10-15 11:27:32 +02:00
|
|
|
// Note: Admin must have downloaded os_version into matchbox assets/coreos.
|
2017-07-25 08:16:34 +02:00
|
|
|
resource "matchbox_profile" "cached-container-linux-install" {
|
2019-10-06 21:57:15 +02:00
|
|
|
count = length(var.controllers) + length(var.workers)
|
|
|
|
name = format("%s-cached-container-linux-install-%s", var.cluster_name, concat(var.controllers.*.name, var.workers.*.name)[count.index])
|
2018-01-14 21:36:40 +01:00
|
|
|
|
2018-05-17 07:37:37 +02:00
|
|
|
kernel = "/assets/coreos/${var.os_version}/coreos_production_pxe.vmlinuz"
|
2017-07-25 08:16:34 +02:00
|
|
|
|
|
|
|
initrd = [
|
2018-05-17 07:37:37 +02:00
|
|
|
"/assets/coreos/${var.os_version}/coreos_production_pxe_image.cpio.gz",
|
2017-07-25 08:16:34 +02:00
|
|
|
]
|
|
|
|
|
2019-05-29 04:19:23 +02:00
|
|
|
args = flatten([
|
2017-11-17 08:19:51 +01:00
|
|
|
"initrd=coreos_production_pxe_image.cpio.gz",
|
2017-07-25 08:16:34 +02:00
|
|
|
"coreos.config.url=${var.matchbox_http_endpoint}/ignition?uuid=$${uuid}&mac=$${mac:hexhyp}",
|
|
|
|
"coreos.first_boot=yes",
|
|
|
|
"console=tty0",
|
|
|
|
"console=ttyS0",
|
2019-05-29 04:19:23 +02:00
|
|
|
var.kernel_args,
|
|
|
|
])
|
2017-07-25 08:16:34 +02:00
|
|
|
|
2019-10-06 21:57:15 +02:00
|
|
|
container_linux_config = data.template_file.cached-container-linux-install-configs.*.rendered[count.index]
|
2017-07-25 08:16:34 +02:00
|
|
|
}
|
|
|
|
|
2018-01-14 21:36:40 +01:00
|
|
|
data "template_file" "cached-container-linux-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_flavor = local.flavor
|
|
|
|
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
|
2017-07-25 08:16:34 +02:00
|
|
|
# profile uses -b baseurl to install from matchbox cache
|
2018-10-15 11:27:32 +02:00
|
|
|
baseurl_flag = "-b ${var.matchbox_http_endpoint}/assets/${local.flavor}"
|
2017-07-25 08:16:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-17 08:30:48 +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)
|
|
|
|
name = format("%s-flatcar-install-%s", var.cluster_name, concat(var.controllers.*.name, var.workers.*.name)[count.index])
|
2018-05-17 08:30:48 +02:00
|
|
|
|
2019-03-10 04:34:15 +01:00
|
|
|
kernel = "${var.download_protocol}://${local.channel}.release.flatcar-linux.net/amd64-usr/${var.os_version}/flatcar_production_pxe.vmlinuz"
|
2018-05-17 08:30:48 +02:00
|
|
|
|
|
|
|
initrd = [
|
2019-03-10 04:34:15 +01:00
|
|
|
"${var.download_protocol}://${local.channel}.release.flatcar-linux.net/amd64-usr/${var.os_version}/flatcar_production_pxe_image.cpio.gz",
|
2018-05-17 08:30:48 +02:00
|
|
|
]
|
|
|
|
|
2019-05-29 04:19:23 +02:00
|
|
|
args = flatten([
|
2018-05-17 08:30:48 +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",
|
|
|
|
"console=tty0",
|
|
|
|
"console=ttyS0",
|
2019-05-29 04:19:23 +02:00
|
|
|
var.kernel_args,
|
|
|
|
])
|
2018-05-17 08:30:48 +02:00
|
|
|
|
2019-10-06 21:57:15 +02:00
|
|
|
container_linux_config = data.template_file.container-linux-install-configs.*.rendered[count.index]
|
2018-05-17 08:30:48 +02:00
|
|
|
}
|
|
|
|
|
2018-10-15 11:27:32 +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-linux-install" {
|
2019-10-06 21:57:15 +02:00
|
|
|
count = length(var.controllers) + length(var.workers)
|
|
|
|
name = format("%s-cached-flatcar-linux-install-%s", var.cluster_name, concat(var.controllers.*.name, var.workers.*.name)[count.index])
|
2018-10-15 11:27:32 +02:00
|
|
|
|
|
|
|
kernel = "/assets/flatcar/${var.os_version}/flatcar_production_pxe.vmlinuz"
|
|
|
|
|
|
|
|
initrd = [
|
|
|
|
"/assets/flatcar/${var.os_version}/flatcar_production_pxe_image.cpio.gz",
|
|
|
|
]
|
|
|
|
|
2019-05-29 04:19:23 +02:00
|
|
|
args = flatten([
|
2018-10-15 11:27:32 +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",
|
|
|
|
"console=tty0",
|
|
|
|
"console=ttyS0",
|
2019-05-29 04:19:23 +02:00
|
|
|
var.kernel_args,
|
|
|
|
])
|
2018-10-15 11:27:32 +02:00
|
|
|
|
2019-10-06 21:57:15 +02:00
|
|
|
container_linux_config = data.template_file.cached-container-linux-install-configs.*.rendered[count.index]
|
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])
|
|
|
|
raw_ignition = data.ct_config.controller-ignitions.*.rendered[count.index]
|
2017-07-25 08:16:34 +02:00
|
|
|
}
|
|
|
|
|
2018-07-26 07:44:07 +02:00
|
|
|
data "ct_config" "controller-ignitions" {
|
2019-10-06 21:57:15 +02:00
|
|
|
count = length(var.controllers)
|
|
|
|
content = data.template_file.controller-configs.*.rendered[count.index]
|
2018-07-26 07:44:07 +02:00
|
|
|
pretty_print = false
|
2020-03-29 20:46:22 +02:00
|
|
|
snippets = lookup(var.snippets, var.controllers.*.name[count.index], [])
|
2018-07-26 07:44:07 +02:00
|
|
|
}
|
|
|
|
|
2017-09-23 20:49:12 +02:00
|
|
|
data "template_file" "controller-configs" {
|
2019-10-06 21:57:15 +02:00
|
|
|
count = length(var.controllers)
|
2017-09-23 20:49:12 +02:00
|
|
|
|
2019-12-28 21:07:10 +01:00
|
|
|
template = file("${path.module}/cl/controller.yaml")
|
2017-09-23 20:49:12 +02:00
|
|
|
|
2019-03-12 09:19:54 +01:00
|
|
|
vars = {
|
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-11-14 08:44:02 +01:00
|
|
|
cgroup_driver = var.os_channel == "flatcar-edge" ? "systemd" : "cgroupfs"
|
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
|
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])
|
|
|
|
raw_ignition = data.ct_config.worker-ignitions.*.rendered[count.index]
|
2018-07-26 07:44:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
data "ct_config" "worker-ignitions" {
|
2019-10-06 21:57:15 +02:00
|
|
|
count = length(var.workers)
|
|
|
|
content = data.template_file.worker-configs.*.rendered[count.index]
|
2018-07-26 07:44:07 +02:00
|
|
|
pretty_print = false
|
2020-03-29 20:46:22 +02:00
|
|
|
snippets = lookup(var.snippets, var.workers.*.name[count.index], [])
|
2017-09-23 20:49:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
data "template_file" "worker-configs" {
|
2019-10-06 21:57:15 +02:00
|
|
|
count = length(var.workers)
|
2017-09-23 20:49:12 +02:00
|
|
|
|
2019-12-28 21:07:10 +01:00
|
|
|
template = file("${path.module}/cl/worker.yaml")
|
2017-09-23 20:49:12 +02:00
|
|
|
|
2019-03-12 09:19:54 +01:00
|
|
|
vars = {
|
2019-10-06 21:57:15 +02:00
|
|
|
domain_name = var.workers.*.domain[count.index]
|
2019-11-14 08:44:02 +01:00
|
|
|
cgroup_driver = var.os_channel == "flatcar-edge" ? "systemd" : "cgroupfs"
|
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], []))
|
2017-09-23 20:49:12 +02:00
|
|
|
}
|
2017-07-25 08:16:34 +02:00
|
|
|
}
|