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

baremetal: configure and persist kernel args #1489

Merged
merged 2 commits into from
Jun 17, 2021
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 @@ -8,6 +8,7 @@ module "controller_profile" {
os_version = var.os_version
http_endpoint = var.matchbox_http_endpoint
kernel_args = var.kernel_args
kernel_console = var.kernel_console
install_disk = var.install_disk
install_to_smallest_disk = var.install_to_smallest_disk
container_linux_oem = var.container_linux_oem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ variable "kernel_args" {
default = []
}

variable "kernel_console" {
description = "The kernel arguments to configure the console at PXE boot and in /usr/share/oem/grub.cfg."
type = list(string)
default = ["console=tty0", "console=ttyS0"]
}

variable "enable_reporting" {
type = bool
description = "Enable usage or analytics reporting to upstreams (Calico)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module "worker_profile" {
os_version = var.os_version
http_endpoint = var.matchbox_http_endpoint
kernel_args = var.kernel_args
kernel_console = var.kernel_console
install_disk = var.install_disk
install_to_smallest_disk = var.install_to_smallest_disk
container_linux_oem = var.container_linux_oem
Expand Down
10 changes: 6 additions & 4 deletions assets/terraform-modules/matchbox-flatcar/profiles.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ resource "matchbox_profile" "flatcar-install" {
"initrd=flatcar_production_pxe_image.cpio.gz",
"ignition.config.url=${var.http_endpoint}/ignition?uuid=$${uuid}&mac=$${mac:hexhyp}",
"flatcar.first_boot=yes",
"console=tty0",
"console=ttyS0",
var.kernel_console,
var.kernel_args,
])

Expand All @@ -27,6 +26,8 @@ resource "matchbox_profile" "flatcar-install" {
container_linux_oem = var.container_linux_oem
ssh_keys = jsonencode(var.ssh_keys)
install_to_smallest_disk = var.install_to_smallest_disk
kernel_console = join(" ", var.kernel_console)
kernel_args = join(" ", var.kernel_args)
# only cached-container-linux profile adds -b baseurl
baseurl_flag = ""
})
Expand All @@ -50,8 +51,7 @@ resource "matchbox_profile" "cached-flatcar-linux-install" {
"initrd=flatcar_production_pxe_image.cpio.gz",
"ignition.config.url=${var.http_endpoint}/ignition?uuid=$${uuid}&mac=$${mac:hexhyp}",
"flatcar.first_boot=yes",
"console=tty0",
"console=ttyS0",
var.kernel_console,
var.kernel_args,
])

Expand All @@ -63,6 +63,8 @@ resource "matchbox_profile" "cached-flatcar-linux-install" {
container_linux_oem = var.container_linux_oem
ssh_keys = jsonencode(var.ssh_keys)
install_to_smallest_disk = var.install_to_smallest_disk
kernel_console = join(" ", var.kernel_console)
kernel_args = join(" ", var.kernel_args)
# profile uses -b baseurl to install from matchbox cache
baseurl_flag = "-b ${var.http_endpoint}/assets/flatcar"
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ storage:
contents:
inline: |
#!/bin/bash -ex
# unmount any leftovers at the beginning before we modify the disk the mount uses
umount /tmp/oemfs || true
curl --retry 10 "${ignition_endpoint}?{{.request.raw_query}}&os=installed" -o ignition.json
flatcar-install \
%{~ if install_to_smallest_disk ~}
Expand All @@ -43,6 +45,13 @@ storage:
${baseurl_flag} \
-i ignition.json
udevadm settle
OEM_DEV="$(blkid -t "LABEL=OEM" -o device)"
mkdir -p /tmp/oemfs
mount "$${OEM_DEV}" /tmp/oemfs
# append to file on newly created partition, do not remove the defaults
echo 'set linux_append="${kernel_args}"' >> /tmp/oemfs/grub.cfg
echo 'set linux_console="${kernel_console}"' >> /tmp/oemfs/grub.cfg
umount /tmp/oemfs
systemctl reboot
passwd:
users:
Expand Down
8 changes: 7 additions & 1 deletion assets/terraform-modules/matchbox-flatcar/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,16 @@ variable "container_linux_oem" {

variable "kernel_args" {
type = list(string)
description = "Additional kernel arguments to provide at PXE boot."
description = "Additional kernel arguments to provide at PXE boot and in /usr/share/oem/grub.cfg."
default = []
}

variable "kernel_console" {
type = list(string)
description = "The kernel arguments to configure the console at PXE boot and in /usr/share/oem/grub.cfg."
default = ["console=tty0", "console=ttyS0"]
}

variable "install_to_smallest_disk" {
type = bool
description = "Install Flatcar Container Linux to the smallest disk."
Expand Down
3 changes: 2 additions & 1 deletion docs/configuration-reference/platforms/baremetal.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ os_version = var.custom_default_os_version
| `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 |
| `install_to_smallest_disk` | Installs Flatcar Container Linux to the smallest disk. | false | bool | false |
| `install_disk` | Disk device where Flatcar Container Linux should be installed. | "/dev/sda" | string | false |
| `kernel_args` | Additional kernel args to provide at PXE boot. | ["kvm-intel.nested=1"] | list(string) | false |
| `kernel_args` | Additional kernel args to provide at PXE boot and in /usr/share/oem/grub.cfg. | [] | list(string) | false |
| `kernel_console` | The kernel arguments to configure the console at PXE boot and in `/usr/share/oem/grub.cfg`. | ["console=tty0", "console=ttyS0"] | list(string) | false |
pothos marked this conversation as resolved.
Show resolved Hide resolved
pothos marked this conversation as resolved.
Show resolved Hide resolved
| `download_protocol` | Protocol iPXE uses to download the kernel and initrd. iPXE must be compiled with crypto support for https. Unused if `cached_install` is true. Use `http` if the iPXE boot using `https` is slow or does not work due to SSL settings. | "https" | string | false |
| `network_ip_autodetection_method` | Method to detect host IPv4 address. Accepted values include 'first-found', 'can-reach=<DESTINATION>', 'interface=<INTERFACE-REGEX>', 'skip-interface=<INTERFACE-REGEX>, 'cidr=<CIDR>'. | "first-found" | string | false |
| `oidc` | OIDC configuration block. | - | object | false |
Expand Down
24 changes: 12 additions & 12 deletions pkg/assets/generated_assets.go

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions pkg/platform/baremetal/baremetal.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type config struct {
InstallToSmallestDisk bool `hcl:"install_to_smallest_disk,optional"`
InstallDisk string `hcl:"install_disk,optional"`
KernelArgs []string `hcl:"kernel_args,optional"`
KernelConsole []string `hcl:"kernel_console,optional"`
DownloadProtocol string `hcl:"download_protocol,optional"`
NetworkIPAutodetectionMethod string `hcl:"network_ip_autodetection_method,optional"`
CLCSnippets map[string][]string `hcl:"clc_snippets,optional"`
Expand Down Expand Up @@ -246,6 +247,7 @@ func createTerraformConfigFile(cfg *config, terraformPath string) error {
InstallDisk string
InstallToSmallestDisk bool
KernelArgs []string
KernelConsole []string
DownloadProtocol string
NetworkIPAutodetectionMethod string
CLCSnippets map[string][]string
Expand Down Expand Up @@ -279,6 +281,7 @@ func createTerraformConfigFile(cfg *config, terraformPath string) error {
InstallDisk: cfg.InstallDisk,
InstallToSmallestDisk: cfg.InstallToSmallestDisk,
KernelArgs: cfg.KernelArgs,
KernelConsole: cfg.KernelConsole,
DownloadProtocol: cfg.DownloadProtocol,
NetworkIPAutodetectionMethod: cfg.NetworkIPAutodetectionMethod,
CLCSnippets: cfg.CLCSnippets,
Expand Down
8 changes: 8 additions & 0 deletions pkg/platform/baremetal/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ module "bare-metal-{{.ClusterName}}" {
]
{{- end }}

{{- if .KernelConsole }}
kernel_console = [
{{- range $arg := .KernelConsole }}
"{{ $arg }}",
{{- end }}
]
{{- end }}

download_protocol = "{{ .DownloadProtocol }}"

network_ip_autodetection_method = "{{ .NetworkIPAutodetectionMethod }}"
Expand Down