Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Remove Deprecated CoreOS from Bare Metal terraform #1246

Merged
merged 1 commit into from
Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ storage:
inline: |
#!/bin/bash -ex
curl --retry 10 "${ignition_endpoint}?{{.request.raw_query}}&os=installed" -o ignition.json
${os_flavor}-install \
flatcar-install \
-d ${install_disk} \
-C ${os_channel} \
-V ${os_version} \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ resource "matchbox_group" "install" {
concat(var.controller_names, var.worker_names)[count.index]
)

profile = local.flavor == "flatcar" ? var.cached_install == true ? matchbox_profile.cached-flatcar-linux-install[count.index].name : matchbox_profile.flatcar-install[count.index].name : var.cached_install == true ? matchbox_profile.cached-container-linux-install[count.index].name : matchbox_profile.container-linux-install[count.index].name

profile = var.cached_install == true ? matchbox_profile.cached-flatcar-linux-install[count.index].name : matchbox_profile.flatcar-install[count.index].name
selector = {
mac = concat(var.controller_macs, var.worker_macs)[count.index]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,86 +1,3 @@
locals {
# coreos-stable -> coreos flavor, stable channel
# flatcar-stable -> flatcar flavor, stable channel
flavor = split("-", var.os_channel)[0]

channel = split("-", var.os_channel)[1]
}

// CoreOS Container Linux Install profile (from release.core-os.net)
resource "matchbox_profile" "container-linux-install" {
count = length(var.controller_names) + length(var.worker_names)
name = format(
"%s-container-linux-install-%s",
var.cluster_name,
concat(var.controller_names, var.worker_names)[count.index]
)

kernel = "${var.download_protocol}://${local.channel}.release.core-os.net/amd64-usr/${var.os_version}/coreos_production_pxe.vmlinuz"

initrd = [
"${var.download_protocol}://${local.channel}.release.core-os.net/amd64-usr/${var.os_version}/coreos_production_pxe_image.cpio.gz",
]

args = flatten([
"initrd=coreos_production_pxe_image.cpio.gz",
"coreos.config.url=${var.matchbox_http_endpoint}/ignition?uuid=$${uuid}&mac=$${mac:hexhyp}",
"coreos.first_boot=yes",
"console=tty0",
"console=ttyS0",
var.kernel_args,
])

container_linux_config = templatefile("${path.module}/cl/install.yaml.tmpl", {
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
container_linux_oem = var.container_linux_oem
ssh_keys = jsonencode(var.ssh_keys)
# only cached-container-linux profile adds -b baseurl
baseurl_flag = ""
})
}

// CoreOS Container Linux Install profile (from matchbox /assets cache)
// 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,
concat(var.controller_names, var.worker_names)[count.index]
)

kernel = "/assets/coreos/${var.os_version}/coreos_production_pxe.vmlinuz"

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

args = flatten([
"initrd=coreos_production_pxe_image.cpio.gz",
"coreos.config.url=${var.matchbox_http_endpoint}/ignition?uuid=$${uuid}&mac=$${mac:hexhyp}",
"coreos.first_boot=yes",
"console=tty0",
"console=ttyS0",
var.kernel_args,
])

container_linux_config = templatefile("${path.module}/cl/install.yaml.tmpl", {
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
container_linux_oem = var.container_linux_oem
ssh_keys = jsonencode(var.ssh_keys)
# profile uses -b baseurl to install from matchbox cache
baseurl_flag = "-b ${var.matchbox_http_endpoint}/assets/${local.flavor}"
})
}

// Flatcar Container Linux install profile (from release.flatcar-linux.net)
resource "matchbox_profile" "flatcar-install" {
count = length(var.controller_names) + length(var.worker_names)
Expand All @@ -90,10 +7,10 @@ resource "matchbox_profile" "flatcar-install" {
concat(var.controller_names, var.worker_names)[count.index]
)

kernel = "${var.download_protocol}://${local.channel}.release.flatcar-linux.net/amd64-usr/${var.os_version}/flatcar_production_pxe.vmlinuz"
kernel = "${var.download_protocol}://${var.os_channel}.release.flatcar-linux.net/amd64-usr/${var.os_version}/flatcar_production_pxe.vmlinuz"

initrd = [
"${var.download_protocol}://${local.channel}.release.flatcar-linux.net/amd64-usr/${var.os_version}/flatcar_production_pxe_image.cpio.gz",
"${var.download_protocol}://${var.os_channel}.release.flatcar-linux.net/amd64-usr/${var.os_version}/flatcar_production_pxe_image.cpio.gz",
]

args = flatten([
Expand All @@ -106,8 +23,7 @@ resource "matchbox_profile" "flatcar-install" {
])

container_linux_config = templatefile("${path.module}/cl/install.yaml.tmpl", {
os_flavor = local.flavor
os_channel = local.channel
os_channel = var.os_channel
os_version = var.os_version
ignition_endpoint = format("%s/ignition", var.matchbox_http_endpoint)
install_disk = var.install_disk
Expand Down Expand Up @@ -144,15 +60,14 @@ resource "matchbox_profile" "cached-flatcar-linux-install" {
])

container_linux_config = templatefile("${path.module}/cl/install.yaml.tmpl", {
os_flavor = local.flavor
os_channel = local.channel
os_channel = var.os_channel
os_version = var.os_version
ignition_endpoint = format("%s/ignition", var.matchbox_http_endpoint)
install_disk = var.install_disk
container_linux_oem = var.container_linux_oem
ssh_keys = jsonencode(var.ssh_keys)
# profile uses -b baseurl to install from matchbox cache
baseurl_flag = "-b ${var.matchbox_http_endpoint}/assets/${local.flavor}"
baseurl_flag = "-b ${var.matchbox_http_endpoint}/assets/flatcar"
})
}

Expand Down Expand Up @@ -221,7 +136,7 @@ data "ct_config" "worker-ignitions" {
locals {
# TODO: Probably it is not needed anymore with terraform 0.12
# Hack to workaround https://github.com/hashicorp/terraform/issues/17251
# Default CoreOS Container Linux config snippets map every node names to list("\n") so
# Default Flatcar Container Linux config snippets map every node names to list("\n") so
# all lookups succeed
total_length = length(var.controller_names) + length(var.worker_names)
clc_defaults = zipmap(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ variable "matchbox_http_endpoint" {

variable "os_channel" {
type = string
description = "Channel for a CoreOS Container Linux derivative (coreos-stable, coreos-beta, coreos-alpha, flatcar-stable, flatcar-beta, flatcar-alpha)"
default = "stable"
description = "Flatcar Container Linux channel to install from (stable, beta, alpha, edge)"
}

variable "os_version" {
type = string
description = "Version for a CoreOS Container Linux derivative to PXE and install (coreos-stable, coreos-beta, coreos-alpha, flatcar-stable, flatcar-beta, flatcar-alpha)"
default = "current"
description = "Flatcar Container Linux version to install (for example '2191.5.0' - see https://www.flatcar-linux.org/releases/)"
}

# machines
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration-reference/platforms/baremetal.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ os_version = var.custom_default_os_version
| `worker_domains` | Ordered list of worker FQDNs. Example ["node2.example.com", "node3.example.com"] | - | list(string) | true |
| `ssh_pubkeys` | List of SSH public keys for user `core`. Each element must be specified in a valid OpenSSH public key format, as defined in RFC 4253 Section 6.6, e.g. "ssh-rsa AAAAB3N...". | - | list(string) | true |
| `os_version` | Flatcar Container Linux version to install. Version such as "2303.3.1" or "current". | "current" | string | false |
| `os_channel` | Flatcar Container Linux channel to install from ("flatcar-stable", "flatcar-beta", "flatcar-alpha", "flatcar-edge"). | "flatcar-stable" | string | false |
| `os_channel` | Flatcar Container Linux channel to install from ("stable", "beta", "alpha", "edge"). | "stable" | string | false |
| `enable_tls_bootstrap` | Enable TLS bootstraping for Kubelet. | true | bool | false |
| `encrypt_pod_traffic` | Enable in-cluster pod traffic encryption. If true `network_mtu` is reduced by 60 to make room for the encryption header. | false | bool | false |
| `ignore_x509_cn_check` | Ignore check of common name in x509 certificates. If any application is built pre golang 1.15 then API server rejects x509 from such application, enable this to get around apiserver. | false | bool | false |
Expand Down
Loading