Skip to content

Commit 7bb4cde

Browse files
committed
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.
1 parent e111168 commit 7bb4cde

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

bootstrap/kubeadm/internal/ignition/clc/clc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ systemd:
9696
Description=kubeadm
9797
# Run only once. After successful run, this file is moved to /tmp/.
9898
ConditionPathExists=/etc/kubeadm.yml
99+
After=network.target
99100
[Service]
100101
# To not restart the unit when it exits, as it is expected.
101102
Type=oneshot

bootstrap/kubeadm/internal/ignition/clc/clc_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ func TestRender(t *testing.T) {
249249
Systemd: types.Systemd{
250250
Units: []types.Unit{
251251
{
252-
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",
252+
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",
253253
Enabled: pointer.Bool(true),
254254
Name: "kubeadm.service",
255255
},
@@ -340,7 +340,7 @@ func TestRender(t *testing.T) {
340340
Systemd: types.Systemd{
341341
Units: []types.Unit{
342342
{
343-
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",
343+
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",
344344
Enabled: pointer.Bool(true),
345345
Name: "kubeadm.service",
346346
},
@@ -423,7 +423,7 @@ func TestRender(t *testing.T) {
423423
Systemd: types.Systemd{
424424
Units: []types.Unit{
425425
{
426-
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",
426+
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",
427427
Enabled: pointer.Bool(true),
428428
Name: "kubeadm.service",
429429
},
@@ -550,7 +550,7 @@ func TestRender(t *testing.T) {
550550
Systemd: types.Systemd{
551551
Units: []types.Unit{
552552
{
553-
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",
553+
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",
554554
Enabled: pointer.Bool(true),
555555
Name: "kubeadm.service",
556556
},

0 commit comments

Comments
 (0)