Chris Friesen 1fffbe7c9b 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 also requires the following two changes to go in at the same
time.  All three must be in place for the symlinks to work properly.

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

Story: 2011047
Task: 49915

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.

PASS:
Do backup on AIO-SX while running K8s 1.25, ensure that after a restore
we are also running K8s 1.25.   (NOTE: this test resulted in hitting
CGTS-55971 multiple times so the restore didn't complete successfully,
but the K8s symlinks were created as expected.)

Change-Id: Iffc4ed57c64c8cffd648345d7e03c7d9448ea891
Signed-off-by: Chris Friesen <chris.friesen@windriver.com>
2024-04-29 17:06:15 -06:00

71 lines
2.7 KiB
Makefile
Executable File

#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1
_k8s_name := kubernetes
_bindir := /usr/bin
_local_sbindir := /usr/local/sbin
_symlinkdir := /var/lib/kubernetes
DEBIAN_DESTDIR := $(CURDIR)/debian/tmp
stage_link = ln -v -sf ${1}${2}/${3} ${DEBIAN_DESTDIR}${2}/${3}
%:
dh $@ --builddirectory=contrib
override_dh_auto_build:
mkdir -pv contrib
cp -rv init contrib
override_dh_install:
# 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,${_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}
install -v -m 644 -t ${DEBIAN_DESTDIR}/etc/${_k8s_name} contrib/init/systemd/environ/config
install -v -m 644 -t ${DEBIAN_DESTDIR}/etc/${_k8s_name} contrib/init/systemd/environ/kubelet
install -v -m 644 -t ${DEBIAN_DESTDIR}/etc/${_k8s_name} contrib/init/systemd/environ/kubelet.kubeconfig
install -v -m 644 -t ${DEBIAN_DESTDIR}/etc/${_k8s_name} contrib/init/systemd/environ/proxy
# install config files
install -v -d -m 0755 ${DEBIAN_DESTDIR}/usr/lib/tmpfiles.d
install -v -p -m 0644 -t ${DEBIAN_DESTDIR}/usr/lib/tmpfiles.d contrib/init/systemd/tmpfiles.d/kubernetes.conf
mkdir -p ${DEBIAN_DESTDIR}/run
install -v -d -m 0755 ${DEBIAN_DESTDIR}/run/${_k8s_name}/
# install service files
install -v -d -m 0755 ${DEBIAN_DESTDIR}/usr/lib/systemd/system
install -v -m 0644 -t ${DEBIAN_DESTDIR}/usr/lib/systemd/system contrib/init/systemd/kubelet.service
# install the place the kubelet defaults to put volumes (/var/lib/kubelet)
install -v -d ${DEBIAN_DESTDIR}/var/lib/kubelet
# enable CPU and Memory accounting
install -v -d -m 0755 ${DEBIAN_DESTDIR}/etc/systemd/system.conf.d
install -v -p -m 0644 -t ${DEBIAN_DESTDIR}/etc/systemd/system.conf.d debian/kubernetes-accounting.conf
# install scripts
install -v -m 0700 -d ${DEBIAN_DESTDIR}${_local_sbindir}
install -v -m 0700 -t ${DEBIAN_DESTDIR}${_local_sbindir} debian/sanitize_kubelet_reserved_cpus.sh
dh_install
override_dh_usrlocal:
override_dh_auto_test: