Skip to content

Commit

Permalink
bare-metal: support cached install for Flatcar
Browse files Browse the repository at this point in the history
Add support for the "cached install" variant (assets are fetched from
matchbox and not the upstream server) for Flatcar.

Also, remove a hardcoded `coreos` and use `${os_flavor}` instead to make
the code work for both Container Linux and Flatcar based installs.
  • Loading branch information
schu committed Oct 16, 2018
1 parent 8f0d2b5 commit fc3fa9b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bare-metal/container-linux/kubernetes/groups.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resource "matchbox_group" "install" {

name = "${format("install-%s", element(concat(var.controller_names, var.worker_names), count.index))}"

profile = "${local.flavor == "flatcar" ? element(matchbox_profile.flatcar-install.*.name, count.index) : var.cached_install == "true" ? element(matchbox_profile.cached-container-linux-install.*.name, count.index) : element(matchbox_profile.container-linux-install.*.name, count.index)}"
profile = "${local.flavor == "flatcar" ? var.cached_install == "true" ? element(matchbox_profile.cached-flatcar-linux-install.*.name, count.index) : element(matchbox_profile.flatcar-install.*.name, count.index) : var.cached_install == "true" ? element(matchbox_profile.cached-container-linux-install.*.name, count.index) : element(matchbox_profile.container-linux-install.*.name, count.index)}"

selector {
mac = "${element(concat(var.controller_macs, var.worker_macs), count.index)}"
Expand Down
28 changes: 26 additions & 2 deletions bare-metal/container-linux/kubernetes/profiles.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ data "template_file" "container-linux-install-configs" {
}

// Container Linux Install profile (from matchbox /assets cache)
// Note: Admin must have downloaded os_version into matchbox assets.
// Note: Admin must have downloaded os_version into matchbox assets/coreos.
resource "matchbox_profile" "cached-container-linux-install" {
count = "${length(var.controller_names) + length(var.worker_names)}"
name = "${format("%s-cached-container-linux-install-%s", var.cluster_name, element(concat(var.controller_names, var.worker_names), count.index))}"
Expand Down Expand Up @@ -87,7 +87,7 @@ data "template_file" "cached-container-linux-install-configs" {
ssh_authorized_key = "${var.ssh_authorized_key}"

# profile uses -b baseurl to install from matchbox cache
baseurl_flag = "-b ${var.matchbox_http_endpoint}/assets/coreos"
baseurl_flag = "-b ${var.matchbox_http_endpoint}/assets/${local.flavor}"
}
}

Expand All @@ -114,6 +114,30 @@ resource "matchbox_profile" "flatcar-install" {
container_linux_config = "${element(data.template_file.container-linux-install-configs.*.rendered, count.index)}"
}

// 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" {
count = "${length(var.controller_names) + length(var.worker_names)}"
name = "${format("%s-cached-flatcar-linux-install-%s", var.cluster_name, element(concat(var.controller_names, var.worker_names), count.index))}"

kernel = "/assets/flatcar/${var.os_version}/flatcar_production_pxe.vmlinuz"

initrd = [
"/assets/flatcar/${var.os_version}/flatcar_production_pxe_image.cpio.gz",
]

args = [
"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",
"${var.kernel_args}",
]

container_linux_config = "${element(data.template_file.cached-container-linux-install-configs.*.rendered, count.index)}"
}

// Kubernetes Controller profiles
resource "matchbox_profile" "controllers" {
count = "${length(var.controller_names)}"
Expand Down

0 comments on commit fc3fa9b

Please sign in to comment.