use symlinks instead of bind mounts for K8s versioning

Switch to using "stage1" and "stage2" symlinks under
/var/lib/kubernetes to select versions for kubeadm, kubelet,
and kubectl.

We have been using bind mounts to select K8s versions, but they are not
well supported by Puppet and suffer from fragility since you cannot
remove a bind mount while an executable is still running from it.  They
also need to be re-created when creating an OSTree hotfix.

Symlinks suffer from no such issues, they just need to be created in
a filesystem that is not managed by OSTree.

Note: this has a dependency on changes in the ansible-playbooks and
stx-puppet repos, all three must be in place for the symlinks to
work properly.  The other commits are:

https://review.opendev.org/c/starlingx/stx-puppet/+/916338
https://review.opendev.org/c/starlingx/ansible-playbooks/+/916336

TEST PLAN:

PASS:
Perform default install on AIO-SX, ensure no issues and K8s works as
expected.

PASS:
Perform default install on Standard lab, ensure no issues and K8s works
as expected.

PASS:
Install with K8s 1.24 on AIO-SX, do orchestrated upgrade covering
multiple K8s versions.  Ensure no issues and K8s works as expected.

PASS:
Install with K8s 1.24 on Standard lab, do  manual K8s upgrade, ensure
no issues and K8s works as expected.

Change-Id: Iffc4ed57c64c8cffd648345d7e03c7d9448ea891
Signed-off-by: Chris Friesen <chris.friesen@windriver.com>
This commit is contained in:
Chris Friesen 2022-12-10 20:09:58 -06:00
parent a933669618
commit 3a483339be
3 changed files with 16 additions and 19 deletions

View File

@ -1,6 +1,5 @@
etc/systemd/system/kubelet.service.d
usr/share/bash-completion/completions
usr/local/kubernetes/current/stage1
usr/local/kubernetes/current/stage2
var/lib/kubelet
var/lib/kubernetes
run/kubernetes

View File

@ -1,6 +1,6 @@
/usr/local/kubernetes/current/stage1/usr/bin/kubeadm /usr/bin/kubeadm
/usr/local/kubernetes/current/stage2/usr/bin/kubelet /usr/bin/kubelet
/usr/local/kubernetes/current/stage2/usr/bin/kubelet-cgroup-setup.sh /usr/bin/kubelet-cgroup-setup.sh
/usr/local/kubernetes/current/stage2/usr/bin/kubectl /usr/bin/kubectl
/usr/local/kubernetes/current/stage2/etc/systemd/system/kubelet.service.d/kubeadm.conf /etc/systemd/system/kubelet.service.d/kubeadm.conf
/usr/local/kubernetes/current/stage2/usr/share/bash-completion/completions/kubectl /usr/share/bash-completion/completions/kubectl
/var/lib/kubernetes/stage1/usr/bin/kubeadm /usr/bin/kubeadm
/var/lib/kubernetes/stage2/usr/bin/kubelet /usr/bin/kubelet
/var/lib/kubernetes/stage2/usr/bin/kubelet-cgroup-setup.sh /usr/bin/kubelet-cgroup-setup.sh
/var/lib/kubernetes/stage2/usr/bin/kubectl /usr/bin/kubectl
/var/lib/kubernetes/stage2/etc/systemd/system/kubelet.service.d/kubeadm.conf /etc/systemd/system/kubelet.service.d/kubeadm.conf
/var/lib/kubernetes/stage2/usr/share/bash-completion/completions/kubectl /usr/share/bash-completion/completions/kubectl

View File

@ -6,8 +6,7 @@
_k8s_name := kubernetes
_bindir := /usr/bin
_local_sbindir := /usr/local/sbin
_curr_stage1 := /usr/local/kubernetes/current/stage1
_curr_stage2 := /usr/local/kubernetes/current/stage2
_symlinkdir := /var/lib/kubernetes
DEBIAN_DESTDIR := $(CURDIR)/debian/tmp
@ -22,20 +21,19 @@ override_dh_auto_build:
cp -rv init contrib
override_dh_install:
# Current staged directories
install -v -m 755 -d ${DEBIAN_DESTDIR}${_curr_stage1}
install -v -m 755 -d ${DEBIAN_DESTDIR}${_curr_stage2}
# location for stage1 and state2 version symlinks
install -v -m 755 -d ${DEBIAN_DESTDIR}${_symlinkdir}
# Symlink targets
install -v -m 755 -d ${DEBIAN_DESTDIR}${_bindir}
install -v -m 755 -d ${DEBIAN_DESTDIR}/etc/systemd/system/kubelet.service.d
install -v -m 755 -d ${DEBIAN_DESTDIR}/usr/share/bash-completion/completions
$(call stage_link,${_curr_stage1},${_bindir},kubeadm)
$(call stage_link,${_curr_stage2},/etc/systemd/system/kubelet.service.d,kubeadm.conf)
$(call stage_link,${_curr_stage2},/usr/share/bash-completion/completions,kubectl)
$(call stage_link,${_curr_stage2},${_bindir},kubelet-cgroup-setup.sh)
$(call stage_link,${_curr_stage2},${_bindir},kubelet)
$(call stage_link,${_curr_stage2},${_bindir},kubectl)
$(call stage_link,${_symlinkdir}/stage1,${_bindir},kubeadm)
$(call stage_link,${_symlinkdir}/stage2,/etc/systemd/system/kubelet.service.d,kubeadm.conf)
$(call stage_link,${_symlinkdir}/stage2,/usr/share/bash-completion/completions,kubectl)
$(call stage_link,${_symlinkdir}/stage2,${_bindir},kubelet-cgroup-setup.sh)
$(call stage_link,${_symlinkdir}/stage2,${_bindir},kubelet)
$(call stage_link,${_symlinkdir}/stage2,${_bindir},kubectl)
# install environment files
install -v -d -m 0755 ${DEBIAN_DESTDIR}/etc/${_k8s_name}