Jim Gauld 4e57f638bd Update K8S packaging move kubectl to stage1 symlink
This updates kubernetes packaging to move the kubectl
binary and associated bash-completions to stage1 symlink.

This change supports Kubernetes version skew policy
upgrade optimizations. This ensures that the kubectl binary
remains compatible with the control-plane version.

Test Plan:
PASS: build-pkgs, build-image

PASS: Install ISO on AIO-SX for each K8S version
      (i.e., 1.29.2, 1.30.6, 1.31.5, 1.32.2):
      - Verify kubectl commands work, including bash-completion.
      - Verify binaries located under stage1 directory, e.g.,
        find /usr/local/kubernetes -name kubectl
        /usr/local/kubernetes/1.29.2/stage1/usr/share/bash-completion/completions/kubectl
        /usr/local/kubernetes/1.29.2/stage1/usr/bin/kubectl
        ..
      - Verify the binary is symlinked to stage1, e.g.,
        ls -l /usr/bin/kubectl
        /usr/bin/kubectl -> /var/lib/kubernetes/stage1/usr/bin/kubectl

Story:2011415
Task: 51998

Depends-On: https://review.opendev.org/c/starlingx/integ/+/947756

Change-Id: Ifc68cdbd0163e52027e2c9f51de4860c9b797be9
Signed-off-by: Jim Gauld <James.Gauld@windriver.com>
2025-04-22 19:29:27 -04: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}/stage1,/usr/share/bash-completion/completions,kubectl)
$(call stage_link,${_symlinkdir}/stage2,${_bindir},kubelet)
$(call stage_link,${_symlinkdir}/stage1,${_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 -p -m 0700 -t ${DEBIAN_DESTDIR}${_bindir} debian/kubelet-cgroup-setup.sh
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: