Skip to content

Commit 4f18d8c

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 550efe8 commit 4f18d8c

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
@@ -1190,6 +1190,15 @@ def get_object(self) -> objects.ClusterClass:
11901190
},
11911191
},
11921192
},
1193+
{
1194+
"name": "configureKubeProxy",
1195+
"required": True,
1196+
"schema": {
1197+
"openAPIV3Schema": {
1198+
"type": "string",
1199+
},
1200+
},
1201+
},
11931202
{
11941203
"name": "fixedSubnetId",
11951204
"required": True,
@@ -1645,27 +1654,41 @@ def get_object(self) -> objects.ClusterClass:
16451654
{
16461655
"op": "add",
16471656
"path": "/spec/template/spec/kubeadmConfigSpec/ignition",
1648-
"value": {
1649-
"containerLinuxConfig": {
1650-
"additionalConfig": textwrap.dedent(
1651-
"""\
1657+
"valueFrom": {
1658+
"template": textwrap.dedent(
1659+
"""\
1660+
containerLinuxConfig:
1661+
additionalConfig: |
16521662
systemd:
1653-
units:
1654-
1655-
enabled: true
1656-
- name: kubeadm.service
1657-
enabled: true
1658-
dropins:
1659-
- name: 10-flatcar.conf
1663+
units:
1664+
- name: write-configure-kube-proxy.service
1665+
enabled: true
16601666
contents: |
16611667
[Unit]
1662-
Requires=containerd.service coreos-metadata.service
1663-
After=containerd.service coreos-metadata.service
1668+
Description=Write configure-kube-proxy.sh
1669+
Requires=coreos-metadata.service
1670+
After=coreos-metadata.service
16641671
[Service]
1665-
EnvironmentFile=/run/metadata/flatcar
1666-
""" # noqa: E501
1667-
),
1668-
},
1672+
Type=oneshot
1673+
ExecStart=/usr/bin/mkdir -p /run/kubeadm
1674+
ExecStart=/bin/bash -c 'echo {{ .configureKubeProxy }} | /usr/bin/base64 -d > /run/kubeadm/configure-kube-proxy.sh'
1675+
ExecStart=/bin/chmod +x /run/kubeadm/configure-kube-proxy.sh
1676+
[Install]
1677+
WantedBy=multi-user.target
1678+
1679+
enabled: true
1680+
- name: kubeadm.service
1681+
enabled: true
1682+
dropins:
1683+
- name: 10-flatcar.conf
1684+
contents: |
1685+
[Unit]
1686+
Requires=containerd.service coreos-metadata.service write-configure-kube-proxy.service
1687+
After=containerd.service coreos-metadata.service write-configure-kube-proxy.service
1688+
[Service]
1689+
EnvironmentFile=/run/metadata/flatcar
1690+
""" # noqa: E501
1691+
),
16691692
},
16701693
},
16711694
{
@@ -2801,6 +2824,17 @@ def get_object(self) -> objects.Cluster:
28012824
)
28022825
or "",
28032826
},
2827+
{
2828+
"name": "configureKubeProxy",
2829+
"value": base64.encode_as_text(
2830+
importlib.resources.files(
2831+
"magnum_cluster_api.files.run.kubeadm"
2832+
)
2833+
.joinpath("configure-kube-proxy.sh")
2834+
.read_text()
2835+
)
2836+
or "",
2837+
},
28042838
{
28052839
"name": "fixedSubnetId",
28062840
"value": neutron.get_fixed_subnet_id(

0 commit comments

Comments
 (0)