Skip to content
This repository was archived by the owner on Jun 29, 2022. It is now read-only.
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 @@ -32,7 +32,11 @@ storage:
#!/bin/bash -ex
curl --retry 10 "${ignition_endpoint}?{{.request.raw_query}}&os=installed" -o ignition.json
flatcar-install \
%{~ if install_to_smallest_disk ~}
-s \
%{~ else ~}
-d ${install_disk} \
%{~ endif ~}
-C ${os_channel} \
-V ${os_version} \
-o "${container_linux_oem}" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ resource "matchbox_profile" "flatcar-install" {
])

container_linux_config = templatefile("${path.module}/cl/install.yaml.tmpl", {
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)
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)
install_to_smallest_disk = var.install_to_smallest_disk
# only cached-container-linux profile adds -b baseurl
baseurl_flag = ""
})
Expand Down Expand Up @@ -60,12 +61,13 @@ resource "matchbox_profile" "cached-flatcar-linux-install" {
])

container_linux_config = templatefile("${path.module}/cl/install.yaml.tmpl", {
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)
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)
install_to_smallest_disk = var.install_to_smallest_disk
# profile uses -b baseurl to install from matchbox cache
baseurl_flag = "-b ${var.matchbox_http_endpoint}/assets/flatcar"
})
Expand Down Expand Up @@ -102,8 +104,7 @@ data "ct_config" "controller-ignitions" {
})
pretty_print = false

# Must use direct lookup. Cannot use lookup(map, key) since it only works for flat maps
snippets = local.clc_map[var.controller_names[count.index]]
snippets = lookup(var.clc_snippets, var.controller_names[count.index], [])
}

// Kubernetes Worker profiles
Expand All @@ -129,21 +130,6 @@ data "ct_config" "worker-ignitions" {
})
pretty_print = false

# Must use direct lookup. Cannot use lookup(map, key) since it only works for flat maps
snippets = local.clc_map[var.worker_names[count.index]]
snippets = lookup(var.clc_snippets, var.worker_names[count.index], [])
}

locals {
# TODO: Probably it is not needed anymore with terraform 0.12
# Hack to workaround https://github.com/hashicorp/terraform/issues/17251
# 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(
concat(var.controller_names, var.worker_names),
chunklist([for i in range(local.total_length) : "\n"], 1),
)

# Union of the default and user specific snippets, later overrides prior.
clc_map = merge(local.clc_defaults, var.clc_snippets)
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ variable "worker_domains" {
}

variable "clc_snippets" {
type = map(string)
type = map(list(string))
description = "Map from machine names to lists of Container Linux Config snippets"
default = {}
}
Expand Down Expand Up @@ -202,3 +202,9 @@ variable "conntrack_max_per_core" {
description = "--conntrack-max-per-core value for kube-proxy. Maximum number of NAT connections to track per CPU core (0 to leave the limit as-is and ignore the conntrack-min kube-proxy flag)."
type = number
}

variable "install_to_smallest_disk" {
description = "Install Flatcar Container Linux to the smallest disk."
type = bool
default = false
}
14 changes: 14 additions & 0 deletions ci/baremetal/baremetal-cluster.lokocfg.envsubst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@ cluster "bare-metal" {
}

conntrack_max_per_core = 65000

install_to_smallest_disk = "true"

clc_snippets = {
"node1" = [
file("./clc-snippet.yaml"),
]
"node2" = [
file("./clc-snippet.yaml"),
]
"node3" = [
file("./clc-snippet.yaml"),
]
}
}

component "inspektor-gadget" {}
11 changes: 11 additions & 0 deletions ci/baremetal/clc-snippet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
storage:
files:
- path: /opt/clc_snippet_hello
filesystem: root
contents:
inline: Hello, world!
mode: 0644
user:
id: 500
group:
id: 500
Loading