From 7bb4cde098319db9378a4f327294c96d645e892f Mon Sep 17 00:00:00 2001 From: Adrian Vladu Date: Wed, 31 May 2023 16:03:37 +0300 Subject: [PATCH] ignition: start kubeadm after network.target In certain baremetal environments, where there are multiple connected and/or disconnected network ports, the network target is reached more slowly, and the kubeadm.service might fail because it does not have the proper pre-kubeadm commands correctly done (like a ctr image pull) or it cannot connect to other k8s nodes. --- bootstrap/kubeadm/internal/ignition/clc/clc.go | 1 + bootstrap/kubeadm/internal/ignition/clc/clc_test.go | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bootstrap/kubeadm/internal/ignition/clc/clc.go b/bootstrap/kubeadm/internal/ignition/clc/clc.go index 4c4fb7a08391..b7cbaa1b43bd 100644 --- a/bootstrap/kubeadm/internal/ignition/clc/clc.go +++ b/bootstrap/kubeadm/internal/ignition/clc/clc.go @@ -96,6 +96,7 @@ systemd: Description=kubeadm # Run only once. After successful run, this file is moved to /tmp/. ConditionPathExists=/etc/kubeadm.yml + After=network.target [Service] # To not restart the unit when it exits, as it is expected. Type=oneshot diff --git a/bootstrap/kubeadm/internal/ignition/clc/clc_test.go b/bootstrap/kubeadm/internal/ignition/clc/clc_test.go index e61a5bdb2b2a..25b2ffe8be75 100644 --- a/bootstrap/kubeadm/internal/ignition/clc/clc_test.go +++ b/bootstrap/kubeadm/internal/ignition/clc/clc_test.go @@ -249,7 +249,7 @@ func TestRender(t *testing.T) { Systemd: types.Systemd{ Units: []types.Unit{ { - Contents: "[Unit]\nDescription=kubeadm\n# Run only once. After successful run, this file is moved to /tmp/.\nConditionPathExists=/etc/kubeadm.yml\n[Service]\n# To not restart the unit when it exits, as it is expected.\nType=oneshot\nExecStart=/etc/kubeadm.sh\n[Install]\nWantedBy=multi-user.target\n", + Contents: "[Unit]\nDescription=kubeadm\n# Run only once. After successful run, this file is moved to /tmp/.\nConditionPathExists=/etc/kubeadm.yml\nAfter=network.target\n[Service]\n# To not restart the unit when it exits, as it is expected.\nType=oneshot\nExecStart=/etc/kubeadm.sh\n[Install]\nWantedBy=multi-user.target\n", Enabled: pointer.Bool(true), Name: "kubeadm.service", }, @@ -340,7 +340,7 @@ func TestRender(t *testing.T) { Systemd: types.Systemd{ Units: []types.Unit{ { - Contents: "[Unit]\nDescription=kubeadm\n# Run only once. After successful run, this file is moved to /tmp/.\nConditionPathExists=/etc/kubeadm.yml\n[Service]\n# To not restart the unit when it exits, as it is expected.\nType=oneshot\nExecStart=/etc/kubeadm.sh\n[Install]\nWantedBy=multi-user.target\n", + Contents: "[Unit]\nDescription=kubeadm\n# Run only once. After successful run, this file is moved to /tmp/.\nConditionPathExists=/etc/kubeadm.yml\nAfter=network.target\n[Service]\n# To not restart the unit when it exits, as it is expected.\nType=oneshot\nExecStart=/etc/kubeadm.sh\n[Install]\nWantedBy=multi-user.target\n", Enabled: pointer.Bool(true), Name: "kubeadm.service", }, @@ -423,7 +423,7 @@ func TestRender(t *testing.T) { Systemd: types.Systemd{ Units: []types.Unit{ { - Contents: "[Unit]\nDescription=kubeadm\n# Run only once. After successful run, this file is moved to /tmp/.\nConditionPathExists=/etc/kubeadm.yml\n[Service]\n# To not restart the unit when it exits, as it is expected.\nType=oneshot\nExecStart=/etc/kubeadm.sh\n[Install]\nWantedBy=multi-user.target\n", + Contents: "[Unit]\nDescription=kubeadm\n# Run only once. After successful run, this file is moved to /tmp/.\nConditionPathExists=/etc/kubeadm.yml\nAfter=network.target\n[Service]\n# To not restart the unit when it exits, as it is expected.\nType=oneshot\nExecStart=/etc/kubeadm.sh\n[Install]\nWantedBy=multi-user.target\n", Enabled: pointer.Bool(true), Name: "kubeadm.service", }, @@ -550,7 +550,7 @@ func TestRender(t *testing.T) { Systemd: types.Systemd{ Units: []types.Unit{ { - Contents: "[Unit]\nDescription=kubeadm\n# Run only once. After successful run, this file is moved to /tmp/.\nConditionPathExists=/etc/kubeadm.yml\n[Service]\n# To not restart the unit when it exits, as it is expected.\nType=oneshot\nExecStart=/etc/kubeadm.sh\n[Install]\nWantedBy=multi-user.target\n", + Contents: "[Unit]\nDescription=kubeadm\n# Run only once. After successful run, this file is moved to /tmp/.\nConditionPathExists=/etc/kubeadm.yml\nAfter=network.target\n[Service]\n# To not restart the unit when it exits, as it is expected.\nType=oneshot\nExecStart=/etc/kubeadm.sh\n[Install]\nWantedBy=multi-user.target\n", Enabled: pointer.Bool(true), Name: "kubeadm.service", },