Skip to content

Commit 40a8e25

Browse files
tormath1pothos
andcommitted
templates: add flatcar-sysext template
This template allows to use a plain Flatcar image from the Flatcar release server without building with the image-builder. This template will consume Kubernetes systemd-sysext image from the flatcar/sysext-bakery release artifacts. This template will emit a /run/reboot-required file flag when a new Kubernetes release has been downloaded and that we need to coordinate the reboot of the node using Kured for example. Signed-off-by: Mathieu Tortuyaux <[email protected]> Co-authored-by: Kai Lüke <[email protected]>
1 parent 85aed76 commit 40a8e25

File tree

4 files changed

+461
-2
lines changed

4 files changed

+461
-2
lines changed

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ e2e-templates: $(addprefix $(E2E_NO_ARTIFACT_TEMPLATES_DIR)/, \
157157
cluster-template-without-lb.yaml \
158158
cluster-template.yaml \
159159
cluster-template-flatcar.yaml \
160-
cluster-template-k8s-upgrade.yaml)
160+
cluster-template-k8s-upgrade.yaml \
161+
cluster-template-flatcar-sysext.yaml)
161162
# Currently no templates that require CI artifacts
162163
# $(addprefix $(E2E_TEMPLATES_DIR)/, add-templates-here.yaml) \
163164
@@ -403,7 +404,8 @@ release-notes: $(RELEASE_NOTES) ## Generate release notes
403404
templates: ## Generate cluster templates
404405
templates: templates/cluster-template.yaml \
405406
templates/cluster-template-without-lb.yaml \
406-
templates/cluster-template-flatcar.yaml
407+
templates/cluster-template-flatcar.yaml \
408+
templates/cluster-template-flatcar-sysext.yaml
407409

408410
templates/cluster-template.yaml: kustomize/v1alpha7/default $(KUSTOMIZE) FORCE
409411
$(KUSTOMIZE) build "$<" > "$@"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
resources:
4+
- ../default
5+
6+
patches:
7+
- path: patch-flatcar.yaml
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
---
2+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha7
3+
kind: OpenStackCluster
4+
metadata:
5+
name: ${CLUSTER_NAME}
6+
spec:
7+
apiServerLoadBalancer:
8+
$patch: delete
9+
---
10+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
11+
kind: KubeadmControlPlane
12+
metadata:
13+
name: "${CLUSTER_NAME}-control-plane"
14+
spec:
15+
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
16+
kubeadmConfigSpec:
17+
joinConfiguration:
18+
nodeRegistration:
19+
name: $${COREOS_OPENSTACK_HOSTNAME}
20+
kubeletExtraArgs:
21+
provider-id: null
22+
initConfiguration:
23+
nodeRegistration:
24+
name: $${COREOS_OPENSTACK_HOSTNAME}
25+
kubeletExtraArgs:
26+
# Fixme(lentzi90): This is here just to override the value set in the default
27+
# kustomization. It will be replaced with a value that works for flatcar in
28+
# https://github.com/kubernetes-sigs/cluster-api-provider-openstack/pull/1564
29+
provider-id: null
30+
format: ignition
31+
ignition:
32+
containerLinuxConfig:
33+
additionalConfig: |
34+
storage:
35+
links:
36+
- path: /etc/extensions/kubernetes.raw
37+
hard: false
38+
target: /opt/extensions/kubernetes/kubernetes-${KUBERNETES_VERSION}-x86-64.raw
39+
files:
40+
- path: /etc/sysupdate.kubernetes.d/kubernetes-${KUBERNETES_VERSION%.*}.conf
41+
mode: 0644
42+
contents:
43+
remote:
44+
url: https://github.com/flatcar/sysext-bakery/releases/download/latest/kubernetes-${KUBERNETES_VERSION%.*}.conf
45+
- path: /etc/sysupdate.d/noop.conf
46+
mode: 0644
47+
contents:
48+
remote:
49+
url: https://github.com/flatcar/sysext-bakery/releases/download/latest/noop.conf
50+
- path: /opt/extensions/kubernetes/kubernetes-${KUBERNETES_VERSION}-x86-64.raw
51+
contents:
52+
remote:
53+
url: https://github.com/flatcar/sysext-bakery/releases/download/latest/kubernetes-${KUBERNETES_VERSION}-x86-64.raw
54+
systemd:
55+
units:
56+
- name: systemd-sysupdate.service
57+
dropins:
58+
- name: kubernetes.conf
59+
contents: |
60+
[Service]
61+
ExecStartPre=/usr/bin/sh -c "readlink --canonicalize /etc/extensions/kubernetes.raw > /tmp/kubernetes"
62+
ExecStartPre=/usr/lib/systemd/systemd-sysupdate -C kubernetes update
63+
ExecStartPost=/usr/bin/sh -c "readlink --canonicalize /etc/extensions/kubernetes.raw > /tmp/kubernetes-new"
64+
ExecStartPost=/usr/bin/sh -c "if ! cmp --silent /tmp/kubernetes /tmp/kubernetes-new; then touch /run/reboot-required; fi"
65+
- name: update-engine.service
66+
# Set this to 'false' if you want to enable Flatcar auto-update
67+
masked: true
68+
- name: locksmithd.service
69+
# NOTE: To coordinate the node reboot in this context, we recommend to use Kured.
70+
masked: true
71+
- name: systemd-sysupdate.timer
72+
# Set this to 'true' if you want to enable the Kubernetes auto-update.
73+
# NOTE: Only patches version will be pulled.
74+
enabled: false
75+
76+
enabled: true
77+
- name: kubeadm.service
78+
enabled: true
79+
dropins:
80+
- name: 10-flatcar.conf
81+
contents: |
82+
[Unit]
83+
Requires=containerd.service coreos-metadata.service
84+
After=containerd.service coreos-metadata.service
85+
[Service]
86+
EnvironmentFile=/run/metadata/flatcar
87+
preKubeadmCommands:
88+
- export COREOS_OPENSTACK_HOSTNAME=$${COREOS_OPENSTACK_HOSTNAME%.*}
89+
- envsubst < /etc/kubeadm.yml > /etc/kubeadm.yml.tmp
90+
- mv /etc/kubeadm.yml.tmp /etc/kubeadm.yml
91+
---
92+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
93+
kind: KubeadmConfigTemplate
94+
metadata:
95+
name: ${CLUSTER_NAME}-md-0
96+
spec:
97+
template:
98+
spec:
99+
joinConfiguration:
100+
nodeRegistration:
101+
name: $${COREOS_OPENSTACK_HOSTNAME}
102+
kubeletExtraArgs:
103+
# Fixme(lentzi90): This is here just to override the value set in the default
104+
# kustomization. It will be replaced with a value that works for flatcar in
105+
# https://github.com/kubernetes-sigs/cluster-api-provider-openstack/pull/1564
106+
provider-id: null
107+
preKubeadmCommands:
108+
- export COREOS_OPENSTACK_HOSTNAME=$${COREOS_OPENSTACK_HOSTNAME%.*}
109+
- envsubst < /etc/kubeadm.yml > /etc/kubeadm.yml.tmp
110+
- mv /etc/kubeadm.yml.tmp /etc/kubeadm.yml
111+
format: ignition
112+
ignition:
113+
containerLinuxConfig:
114+
additionalConfig: |
115+
storage:
116+
links:
117+
- path: /etc/extensions/kubernetes.raw
118+
hard: false
119+
target: /opt/extensions/kubernetes/kubernetes-${KUBERNETES_VERSION}-x86-64.raw
120+
files:
121+
- path: /etc/sysupdate.kubernetes.d/kubernetes-${KUBERNETES_VERSION%.*}.conf
122+
mode: 0644
123+
contents:
124+
remote:
125+
url: https://github.com/flatcar/sysext-bakery/releases/download/latest/kubernetes-${KUBERNETES_VERSION%.*}.conf
126+
- path: /etc/sysupdate.d/noop.conf
127+
mode: 0644
128+
contents:
129+
remote:
130+
url: https://github.com/flatcar/sysext-bakery/releases/download/latest/noop.conf
131+
- path: /opt/extensions/kubernetes/kubernetes-${KUBERNETES_VERSION}-x86-64.raw
132+
contents:
133+
remote:
134+
url: https://github.com/flatcar/sysext-bakery/releases/download/latest/kubernetes-${KUBERNETES_VERSION}-x86-64.raw
135+
systemd:
136+
units:
137+
- name: systemd-sysupdate.service
138+
dropins:
139+
- name: kubernetes.conf
140+
contents: |
141+
[Service]
142+
ExecStartPre=/usr/bin/sh -c "readlink --canonicalize /etc/extensions/kubernetes.raw > /tmp/kubernetes"
143+
ExecStartPre=/usr/lib/systemd/systemd-sysupdate -C kubernetes update
144+
ExecStartPost=/usr/bin/sh -c "readlink --canonicalize /etc/extensions/kubernetes.raw > /tmp/kubernetes-new"
145+
ExecStartPost=/usr/bin/sh -c "if ! cmp --silent /tmp/kubernetes /tmp/kubernetes-new; then touch /run/reboot-required; fi"
146+
- name: update-engine.service
147+
# Set this to 'false' if you want to enable Flatcar auto-update
148+
masked: true
149+
- name: locksmithd.service
150+
# NOTE: To coordinate the node reboot in this context, we recommend to use Kured.
151+
masked: true
152+
- name: systemd-sysupdate.timer
153+
# Set this to 'true' if you want to enable the Kubernetes auto-update.
154+
# NOTE: Only patches version will be pulled.
155+
enabled: false
156+
157+
enabled: true
158+
- name: kubeadm.service
159+
enabled: true
160+
dropins:
161+
- name: 10-flatcar.conf
162+
contents: |
163+
[Unit]
164+
Requires=containerd.service coreos-metadata.service
165+
After=containerd.service coreos-metadata.service
166+
[Service]
167+
EnvironmentFile=/run/metadata/flatcar
168+
---
169+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha7
170+
kind: OpenStackMachineTemplate
171+
metadata:
172+
name: ${CLUSTER_NAME}-md-0
173+
spec:
174+
template:
175+
spec:
176+
image: ${FLATCAR_IMAGE_NAME}
177+
---
178+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha7
179+
kind: OpenStackMachineTemplate
180+
metadata:
181+
name: ${CLUSTER_NAME}-control-plane
182+
spec:
183+
template:
184+
spec:
185+
image: ${FLATCAR_IMAGE_NAME}

0 commit comments

Comments
 (0)