Ensure kubelet is not running when we update the bind mount

When updating the bind mount we need to ensure that kubelet is
not running (otherwise puppet complains that the mount point is
busy and the re-mount fails).

Story: 2008972
Task: 43354

Change-Id: I1fa3a8dab5b4b9c9a46ec52584ed362b1327eca7
Signed-off-by: Chris Friesen <chris.friesen@windriver.com>
This commit is contained in:
Chris Friesen 2021-09-16 14:52:40 -06:00
parent 6f23470482
commit 4608eb26c2

View File

@ -731,10 +731,25 @@ class platform::kubernetes::master::upgrade_kubelet
inherits ::platform::kubernetes::params {
# Update kubeadm/kubelet bindmounts if needed.
require platform::kubernetes::bindmounts
include platform::kubernetes::bindmounts
exec { 'restart kubelet':
command => '/usr/local/sbin/pmon-restart kubelet'
# Tell pmon to stop kubelet so it doesn't try to restart it
exec { 'stop kubelet':
command => '/usr/local/sbin/pmon-stop kubelet'
}
# Mask restarting kubelet and stop it now so that we can unmount
# and re-mount the bind mount.
-> exec { 'mask kubelet':
command => '/usr/bin/systemctl mask --now kubelet',
before => Mount['/usr/local/kubernetes/current/stage2'],
}
# Unmask and restart kubelet after the bind mount is updated.
-> exec { 'unmask kubelet':
command => '/usr/bin/systemctl unmask kubelet',
require => Mount['/usr/local/kubernetes/current/stage2'],
}
-> exec { 'restart kubelet':
command => '/usr/local/sbin/pmon-start kubelet'
}
}
@ -744,7 +759,7 @@ class platform::kubernetes::worker::upgrade_kubelet
include ::platform::dockerdistribution::params
# Update kubeadm/kubelet bindmounts if needed.
require platform::kubernetes::bindmounts
include platform::kubernetes::bindmounts
# workers use kubelet.conf rather than admin.conf
$local_registry_auth = "${::platform::dockerdistribution::params::registry_username}:${::platform::dockerdistribution::params::registry_password}" # lint:ignore:140chars
@ -762,6 +777,21 @@ class platform::kubernetes::worker::upgrade_kubelet
logoutput => true,
}
# Tell pmon to stop kubelet so it doesn't try to restart it
-> exec { 'stop kubelet':
command => '/usr/local/sbin/pmon-stop kubelet'
}
# Mask restarting kubelet and stop it now so that we can unmount
# and re-mount the bind mount.
-> exec { 'mask kubelet':
command => '/usr/bin/systemctl mask --now kubelet',
before => Mount['/usr/local/kubernetes/current/stage2'],
}
# Unmask and restart kubelet after the bind mount is updated.
-> exec { 'unmask kubelet':
command => '/usr/bin/systemctl unmask kubelet',
require => Mount['/usr/local/kubernetes/current/stage2'],
}
-> exec { 'restart kubelet':
command => '/usr/local/sbin/pmon-restart kubelet'
}