Skip to content

Commit 9f6a122

Browse files
Fix the way we write configure-kube-proxy.sh
On flatcar, files in /run are recreated after the initrd pivots to the full system and executes init. This change adds a unit file that writes the file post-boot. Files written in /run during ignition run will be clobbered. Signed-off-by: Gabriel Adrian Samfira <[email protected]>
1 parent 7044ba8 commit 9f6a122

File tree

1 file changed

+51
-17
lines changed

1 file changed

+51
-17
lines changed

magnum_cluster_api/resources.py

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,15 @@ def get_object(self) -> objects.ClusterClass:
11831183
},
11841184
},
11851185
},
1186+
{
1187+
"name": "configureKubeProxy",
1188+
"required": True,
1189+
"schema": {
1190+
"openAPIV3Schema": {
1191+
"type": "string",
1192+
},
1193+
},
1194+
},
11861195
{
11871196
"name": "fixedSubnetId",
11881197
"required": True,
@@ -1638,27 +1647,41 @@ def get_object(self) -> objects.ClusterClass:
16381647
{
16391648
"op": "add",
16401649
"path": "/spec/template/spec/kubeadmConfigSpec/ignition",
1641-
"value": {
1642-
"containerLinuxConfig": {
1643-
"additionalConfig": textwrap.dedent(
1644-
"""\
1650+
"valueFrom": {
1651+
"template": textwrap.dedent(
1652+
"""\
1653+
containerLinuxConfig:
1654+
additionalConfig: |
16451655
systemd:
1646-
units:
1647-
1648-
enabled: true
1649-
- name: kubeadm.service
1650-
enabled: true
1651-
dropins:
1652-
- name: 10-flatcar.conf
1656+
units:
1657+
- name: write-configure-kube-proxy.service
1658+
enabled: true
16531659
contents: |
16541660
[Unit]
1655-
Requires=containerd.service coreos-metadata.service
1656-
After=containerd.service coreos-metadata.service
1661+
Description=Write configure-kube-proxy.sh
1662+
Requires=coreos-metadata.service
1663+
After=coreos-metadata.service
16571664
[Service]
1658-
EnvironmentFile=/run/metadata/flatcar
1659-
""" # noqa: E501
1660-
),
1661-
},
1665+
Type=oneshot
1666+
ExecStart=/usr/bin/mkdir -p /run/kubeadm
1667+
ExecStart=/bin/bash -c 'echo {{ .configureKubeProxy }} | /usr/bin/base64 -d > /run/kubeadm/configure-kube-proxy.sh'
1668+
ExecStart=/bin/chmod +x /run/kubeadm/configure-kube-proxy.sh
1669+
[Install]
1670+
WantedBy=multi-user.target
1671+
1672+
enabled: true
1673+
- name: kubeadm.service
1674+
enabled: true
1675+
dropins:
1676+
- name: 10-flatcar.conf
1677+
contents: |
1678+
[Unit]
1679+
Requires=containerd.service coreos-metadata.service write-configure-kube-proxy.service
1680+
After=containerd.service coreos-metadata.service write-configure-kube-proxy.service
1681+
[Service]
1682+
EnvironmentFile=/run/metadata/flatcar
1683+
""" # noqa: E501
1684+
),
16621685
},
16631686
},
16641687
{
@@ -2772,6 +2795,17 @@ def get_object(self) -> objects.Cluster:
27722795
)
27732796
or "",
27742797
},
2798+
{
2799+
"name": "configureKubeProxy",
2800+
"value": base64.encode_as_text(
2801+
importlib.resources.files(
2802+
"magnum_cluster_api.files.run.kubeadm"
2803+
)
2804+
.joinpath("configure-kube-proxy.sh")
2805+
.read_text()
2806+
)
2807+
or "",
2808+
},
27752809
{
27762810
"name": "fixedSubnetId",
27772811
"value": neutron.get_fixed_subnet_id(

0 commit comments

Comments
 (0)