Skip to content

Commit

Permalink
ignition: start kubeadm after network.target and containerd.service
Browse files Browse the repository at this point in the history
In certain baremetal environment, 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.
  • Loading branch information
ader1990 committed May 31, 2023
1 parent e111168 commit 6d3c06b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions bootstrap/kubeadm/internal/ignition/clc/clc.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ systemd:
Description=kubeadm
# Run only once. After successful run, this file is moved to /tmp/.
ConditionPathExists=/etc/kubeadm.yml
After=network.target
After=containerd.service
[Service]
# To not restart the unit when it exits, as it is expected.
Type=oneshot
Expand Down
8 changes: 4 additions & 4 deletions bootstrap/kubeadm/internal/ignition/clc/clc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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\nAfter=containerd.service\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",
},
Expand Down Expand Up @@ -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\nAfter=containerd.service\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",
},
Expand Down Expand Up @@ -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\nAfter=containerd.service\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",
},
Expand Down Expand Up @@ -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\nAfter=containerd.service\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",
},
Expand Down

0 comments on commit 6d3c06b

Please sign in to comment.