Chris Friesen 15db2d6990 clean up feature gates on k8s upgrade
During a K8s feature upgrade from 1.23 to 1.24 we need to remove
the "RemoveSelfLink=false" feature gate from kube-apiserver.

We had previously handled updating the kubeadm configmap, which
was sufficient to handle the running system.  However, in order
to properly handle backup and restore after the K8s upgrade to
1.24 (and just for general tidiness) we need to also remove the
feature gate from the saved service parameters and from the
last_kube_extra_config_bootstrap.yaml file.

It's possible that there are other kube-apiserver feature gates
specified by the end user, this adds a bit of complexity to the
code.

Test Plan:
PASS: Test python script and bash script in isolation.
PASS: End-to-end test with k8s upgrade and backup/restore with
      manual modification of service parameters and yaml file.
      Tested with AIO-DX, AIO-SX unoptimised restore, and
      AIO-SX optimised restore.
PASS: K8s upgrade using the new code, ensure service parameter
      and last_kube_extra_config_bootstrap.yaml have been
      updated with "RemoveSelfLink=false" feature gate removed.

Closes-Bug: 1999095
Signed-off-by: Chris Friesen <chris.friesen@windriver.com>
Change-Id: I82ecd821d4e1745ab0f480f9f9c0178757521038
2022-12-07 18:13:47 -06:00

76 lines
3.0 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
_curr_stage1 := /usr/local/kubernetes/current/stage1
_curr_stage2 := /usr/local/kubernetes/current/stage2
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:
# Current staged directories
install -v -m 755 -d ${DEBIAN_DESTDIR}${_curr_stage1}
install -v -m 755 -d ${DEBIAN_DESTDIR}${_curr_stage2}
# 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)
# 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 -v -m 644 -t ${DEBIAN_DESTDIR}/etc/${_k8s_name} debian/kubelet_override.yaml
# 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
install -v -m 0700 -t ${DEBIAN_DESTDIR}${_local_sbindir} debian/upgrade_k8s_config.sh
install -v -m 0700 -t ${DEBIAN_DESTDIR}${_local_sbindir} debian/sanitize_feature_gates.py
dh_install
override_dh_usrlocal:
override_dh_auto_test: