Skip to content

Commit

Permalink
Fix the way we write configure-kube-proxy.sh
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
gabriel-samfira committed Jan 16, 2025
1 parent 7044ba8 commit 9f6a122
Showing 1 changed file with 51 additions and 17 deletions.
68 changes: 51 additions & 17 deletions magnum_cluster_api/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,15 @@ def get_object(self) -> objects.ClusterClass:
},
},
},
{
"name": "configureKubeProxy",
"required": True,
"schema": {
"openAPIV3Schema": {
"type": "string",
},
},
},
{
"name": "fixedSubnetId",
"required": True,
Expand Down Expand Up @@ -1638,27 +1647,41 @@ def get_object(self) -> objects.ClusterClass:
{
"op": "add",
"path": "/spec/template/spec/kubeadmConfigSpec/ignition",
"value": {
"containerLinuxConfig": {
"additionalConfig": textwrap.dedent(
"""\
"valueFrom": {
"template": textwrap.dedent(
"""\
containerLinuxConfig:
additionalConfig: |
systemd:
units:
- name: [email protected]
enabled: true
- name: kubeadm.service
enabled: true
dropins:
- name: 10-flatcar.conf
units:
- name: write-configure-kube-proxy.service
enabled: true
contents: |
[Unit]
Requires=containerd.service coreos-metadata.service
After=containerd.service coreos-metadata.service
Description=Write configure-kube-proxy.sh
Requires=coreos-metadata.service
After=coreos-metadata.service
[Service]
EnvironmentFile=/run/metadata/flatcar
""" # noqa: E501
),
},
Type=oneshot
ExecStart=/usr/bin/mkdir -p /run/kubeadm
ExecStart=/bin/bash -c 'echo {{ .configureKubeProxy }} | /usr/bin/base64 -d > /run/kubeadm/configure-kube-proxy.sh'
ExecStart=/bin/chmod +x /run/kubeadm/configure-kube-proxy.sh
[Install]
WantedBy=multi-user.target
- name: [email protected]
enabled: true
- name: kubeadm.service
enabled: true
dropins:
- name: 10-flatcar.conf
contents: |
[Unit]
Requires=containerd.service coreos-metadata.service write-configure-kube-proxy.service
After=containerd.service coreos-metadata.service write-configure-kube-proxy.service
[Service]
EnvironmentFile=/run/metadata/flatcar
""" # noqa: E501
),
},
},
{
Expand Down Expand Up @@ -2772,6 +2795,17 @@ def get_object(self) -> objects.Cluster:
)
or "",
},
{
"name": "configureKubeProxy",
"value": base64.encode_as_text(
importlib.resources.files(
"magnum_cluster_api.files.run.kubeadm"
)
.joinpath("configure-kube-proxy.sh")
.read_text()
)
or "",
},
{
"name": "fixedSubnetId",
"value": neutron.get_fixed_subnet_id(
Expand Down

0 comments on commit 9f6a122

Please sign in to comment.