Jump to content

This is a read-only backup copy of Wikitech. The live site can be found at wikitech.wikimedia.org

Kubernetes/Packages

From Wikitech

Intro

For a variety of reasons, we deploy our kubernetes components in WMF production (Tools/Toolforge is a completely different environment) using Debian packages. Those are:

kubernetes-client one has kubectl in it, kubernetes-master has kube-apiserver, kube-scheduler, kube-controller-manager and kuberetes-node has kubelet and kube-proxy components.

Packaging

We usually build on the older debian version and copy the resulting packages to newer debian versions as needed.

The packages are build using Git-buildpackage . Upstream vendors all dependencies so uscan can be used to build a orig tarbal from the git tag.


Double-check that the environment variables DEBEMAIL and DEBFULLNAME are set correctly before running debchange (dch).

export NEW_VERSION=1.34.13 # Kubernetes version you want to package
uscan --download-version ${NEW_VERSION}
gbp import-orig ../kubernetes_${NEW_VERSION}.orig.tar.xz

# Push the updated branches and upstream tag to gerrit (without review, it's upstream code only)
git push gerrit master
git push gerrit upstream
git push gerrit upstream/${NEW_VERSION}

# Rebase patches (if required)
gbp pq rebase
# ... rebase the patches, see https://honk.sigxcpu.org/projects/git-buildpackage/manual-html/gbp.patches.html
gbp pq export

# Update the kubernetes-clientXYZ package name in debian/control
export VERSION_MM="${NEW_VERSION%.*}"
export VERSION_MM_NODOT="${VERSION_MM//./}"
sed "s/^Package: kubernetes-client.*/Package: kubernetes-client${VERSION_MM_NODOT}/" -i debian/control
# Rename the package related files accordingly
for f in debian/kubernetes-client*.*; do
    suffix="${f#*.}"
    new="debian/kubernetes-client${VERSION_MM_NODOT}.${suffix}"
    git mv "$f" "$new"
done
# Update the version reference in files
sed -i -E "s/(kubectl-?)[0-9]+\.[0-9]+/\1${VERSION_MM}/" debian/kubernetes-client*.*

# Bump the changelog, edit as needed
gbp dch -D trixie-wikimedia

# Commit your changes and send them for review
git commit ... 
git review
  • Merge
  • Check out operations/debs/kubernetes on the build host:
    git clone "https://gerrit.wikimedia.org/r/operations/debs/kubernetes"
    
  • Build the packages:
BACKPORTS=yes gbp buildpackage --git-pbuilder --git-no-pbuilder-autoconf --git-dist=trixie -sa -uc -us

Publishing

When building a new Kubernetes minor version, you will have to add a new apt component first in modules/aptrepo/files/distributions-wikimedia

# On apt1002, copy the packages from the build host
# pbuilder-result is an rsync alias to /var/cache/pbuilder/result on the build host.
rsync -vaz build2001.codfw.wmnet::pbuilder-result/bookworm-amd64/kubernetes*<PACKAGE VERSION>* .

# Import packages to the corresponding kubernetes apt component
# components are listed at https://apt.wikimedia.org/wikimedia/dists/<version>/component
sudo -i reprepro -C component/kubernetesXY --ignore=wrongdistribution include bookworm-wikimedia /path/to/<PACKAGE>.changes

# Kubernetes packages can be copied between distros:
sudo -i reprepro -C component/kubernetesXY copysrc trixie-wikimedia bookworm-wikimedia kubernetes