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

Commit 6322284

Browse files
author
Imran Pochi
authored
Merge pull request #1317 from kinvolk/imran/baremetal-feature-parity
Baremetal platform feature parity
2 parents 9d2aeee + c8b7a39 commit 6322284

File tree

11 files changed

+331
-154
lines changed

11 files changed

+331
-154
lines changed

assets/terraform-modules/bare-metal/flatcar-linux/kubernetes/cl/install.yaml.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ storage:
3232
#!/bin/bash -ex
3333
curl --retry 10 "${ignition_endpoint}?{{.request.raw_query}}&os=installed" -o ignition.json
3434
flatcar-install \
35+
%{~ if install_to_smallest_disk ~}
36+
-s \
37+
%{~ else ~}
3538
-d ${install_disk} \
39+
%{~ endif ~}
3640
-C ${os_channel} \
3741
-V ${os_version} \
3842
-o "${container_linux_oem}" \

assets/terraform-modules/bare-metal/flatcar-linux/kubernetes/profiles.tf

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ resource "matchbox_profile" "flatcar-install" {
2323
])
2424

2525
container_linux_config = templatefile("${path.module}/cl/install.yaml.tmpl", {
26-
os_channel = var.os_channel
27-
os_version = var.os_version
28-
ignition_endpoint = format("%s/ignition", var.matchbox_http_endpoint)
29-
install_disk = var.install_disk
30-
container_linux_oem = var.container_linux_oem
31-
ssh_keys = jsonencode(var.ssh_keys)
26+
os_channel = var.os_channel
27+
os_version = var.os_version
28+
ignition_endpoint = format("%s/ignition", var.matchbox_http_endpoint)
29+
install_disk = var.install_disk
30+
container_linux_oem = var.container_linux_oem
31+
ssh_keys = jsonencode(var.ssh_keys)
32+
install_to_smallest_disk = var.install_to_smallest_disk
3233
# only cached-container-linux profile adds -b baseurl
3334
baseurl_flag = ""
3435
})
@@ -60,12 +61,13 @@ resource "matchbox_profile" "cached-flatcar-linux-install" {
6061
])
6162

6263
container_linux_config = templatefile("${path.module}/cl/install.yaml.tmpl", {
63-
os_channel = var.os_channel
64-
os_version = var.os_version
65-
ignition_endpoint = format("%s/ignition", var.matchbox_http_endpoint)
66-
install_disk = var.install_disk
67-
container_linux_oem = var.container_linux_oem
68-
ssh_keys = jsonencode(var.ssh_keys)
64+
os_channel = var.os_channel
65+
os_version = var.os_version
66+
ignition_endpoint = format("%s/ignition", var.matchbox_http_endpoint)
67+
install_disk = var.install_disk
68+
container_linux_oem = var.container_linux_oem
69+
ssh_keys = jsonencode(var.ssh_keys)
70+
install_to_smallest_disk = var.install_to_smallest_disk
6971
# profile uses -b baseurl to install from matchbox cache
7072
baseurl_flag = "-b ${var.matchbox_http_endpoint}/assets/flatcar"
7173
})
@@ -102,8 +104,7 @@ data "ct_config" "controller-ignitions" {
102104
})
103105
pretty_print = false
104106

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

109110
// Kubernetes Worker profiles
@@ -129,21 +130,6 @@ data "ct_config" "worker-ignitions" {
129130
})
130131
pretty_print = false
131132

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

136-
locals {
137-
# TODO: Probably it is not needed anymore with terraform 0.12
138-
# Hack to workaround https://github.com/hashicorp/terraform/issues/17251
139-
# Default Flatcar Container Linux config snippets map every node names to list("\n") so
140-
# all lookups succeed
141-
total_length = length(var.controller_names) + length(var.worker_names)
142-
clc_defaults = zipmap(
143-
concat(var.controller_names, var.worker_names),
144-
chunklist([for i in range(local.total_length) : "\n"], 1),
145-
)
146-
147-
# Union of the default and user specific snippets, later overrides prior.
148-
clc_map = merge(local.clc_defaults, var.clc_snippets)
149-
}

assets/terraform-modules/bare-metal/flatcar-linux/kubernetes/variables.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ variable "worker_domains" {
5656
}
5757

5858
variable "clc_snippets" {
59-
type = map(string)
59+
type = map(list(string))
6060
description = "Map from machine names to lists of Container Linux Config snippets"
6161
default = {}
6262
}
@@ -202,3 +202,9 @@ variable "conntrack_max_per_core" {
202202
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)."
203203
type = number
204204
}
205+
206+
variable "install_to_smallest_disk" {
207+
description = "Install Flatcar Container Linux to the smallest disk."
208+
type = bool
209+
default = false
210+
}

ci/baremetal/baremetal-cluster.lokocfg.envsubst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,20 @@ cluster "bare-metal" {
4242
}
4343

4444
conntrack_max_per_core = 65000
45+
46+
install_to_smallest_disk = "true"
47+
48+
clc_snippets = {
49+
"node1" = [
50+
file("./clc-snippet.yaml"),
51+
]
52+
"node2" = [
53+
file("./clc-snippet.yaml"),
54+
]
55+
"node3" = [
56+
file("./clc-snippet.yaml"),
57+
]
58+
}
4559
}
4660

4761
component "inspektor-gadget" {}

ci/baremetal/clc-snippet.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
storage:
2+
files:
3+
- path: /opt/clc_snippet_hello
4+
filesystem: root
5+
contents:
6+
inline: Hello, world!
7+
mode: 0644
8+
user:
9+
id: 500
10+
group:
11+
id: 500

0 commit comments

Comments
 (0)