Update kubelet system overrides on unlock

Add logic to the `platform::kubernetes::configuration` method
to generate the kubelet's systemd override file. This
change ensures the file is generated every time a host is
unlocked. This facilitates delivery of systemd service changes
via patches to existing installs.

We only want to update on lock and unlock, so we need to
check that the flag is_initial_k8s_config is not
set before creating the resource in platform::kubernetes::configuration.
This ensures that the file is only regenerated on host unlock and
not during the initial installation, which is currently handled
in platform::kubernetes::master::init.

This change is needed by bug 2027810 to ensure that the
orphan volume cleanup script is executed as part of the systemd
ExecStartPre kubelet service override.

This bug is an update for this reverted commit:
https://review.opendev.org/c/starlingx/stx-puppet/+/896154

Test Plan:
PASS - Verify successful installation from an ISO on AIO-SX with
       the controller unlocked.
PASS - Verify successful installation from an ISO on AIO-DX with
       the controllers unlocked.
PASS - Verify successful installation from an ISO on STANDARD with
       the controllers unlocked.
PASS - Verify that kube-stx-override.conf is updated on AIO-SX:
       - Update the kube-stx-override.conf.erb file.
       - Lock/Unlock the AIO-SX host.
       - Verify that kube-stx-override.conf has been updated.
PASS - Verify that kube-stx-override.conf is updated on STANDARD:
       - Update the kube-stx-override.conf.erb file on compute-0.
       - Lock/Unlock compute-0 and verify that kube-stx-override.conf
         is updated.

Partial-Bug: 2027810
Change-Id: Id473fd0e2c807d1e9d1e3fdd707bc3e9e36688b1
Signed-off-by: Gleb Aronsky <gleb.aronsky@windriver.com>
This commit is contained in:
Gleb Aronsky 2023-10-20 08:56:44 -07:00 committed by Aronsky, Gleb
parent 01729f91ae
commit 88f8f06d39
1 changed files with 14 additions and 0 deletions

View File

@ -101,6 +101,20 @@ define platform::kubernetes::pull_images_from_registry (
class platform::kubernetes::configuration {
# Check to ensure that this code is not executed
# during install and reinstall. We want to
# only execute this block for lock and unlock
if ! str2bool($::is_initial_k8s_config) {
# Add kubelet service override
file { '/etc/systemd/system/kubelet.service.d/kube-stx-override.conf':
ensure => file,
content => template('platform/kube-stx-override.conf.erb'),
owner => 'root',
group => 'root',
mode => '0644',
}
}
if ($::personality == 'controller') {
# Cron job to cleanup stale CNI cache files that are more than
# 1 day old and are not associated with any currently running pod.