Skip to content

Instantly share code, notes, and snippets.

@alexeldeib
Last active June 10, 2023 00:44
Show Gist options
  • Save alexeldeib/015e0f4abdbc2b31aabde7c43e13f003 to your computer and use it in GitHub Desktop.
Save alexeldeib/015e0f4abdbc2b31aabde7c43e13f003 to your computer and use it in GitHub Desktop.
Rebuild AKS node kernel for iolatency support

AKS iolatency rebuild

NODE_NAME="$(kubectl get node -o jsonpath="{.items[0].metadata.name}")"
kubectl node-shell $NODE_NAME

copy rebuild_kernel.sh into /opt/rebuild_kernel.sh or similar, and bash rebuild_kernel.sh

it'll reboot into the new kernel if successful.

comment out the last three lines to rebuild only without installing new kernel and rebooting.

# remove node-shell limits from cgroup if necessary
set -euo pipefail
echo $$ >> /sys/fs/cgroup/system.slice/containerd.service/cgroup.procs
mkdir -p /etc/apt/sources.list.d
tee /etc/apt/sources.list.d/deb-src.list > /dev/null <<'EOF'
deb-src http://archive.ubuntu.com/ubuntu jammy main
deb-src http://archive.ubuntu.com/ubuntu jammy-updates main
EOF
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -yq libncurses-dev fakeroot git gawk flex bison python3-dev python3 python3-pip openssl libcap-dev libssl-dev dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf llvm dh-make pahole < /dev/null
# linux-azure-5.15.98 for example, removes "-1039-azure" and "-custom"
apt-get source linux-image-unsigned-$(uname -r)
kernel_base="$(uname -r | cut -d'-' -f1 | cut -d'.' -f1-)"
kernel_dir="linux-azure-${kernel_base}"
cd "${kernel_dir}"
chmod a+x debian/rules
chmod a+x debian/scripts/*
chmod a+x debian/scripts/misc/*
LANG=C fakeroot debian/rules clean
# enable iolatency
sed -i 's/# CONFIG_BLK_CGROUP_IOLATENCY is not set/CONFIG_BLK_CGROUP_IOLATENCY=y/g' ./debian.azure/config/config.common.ubuntu
sed -i -E "s/CONFIG_BLK_CGROUP_IOLATENCY[[:space:]]+policy<\{'amd64': 'n', 'arm64': 'n', 'armhf': 'n', 'ppc64el': 'n', 's390x': 'n'\}>/CONFIG_BLK_CGROUP_IOLATENCY policy<\{'amd64': 'y', 'arm64': 'n', 'armhf': 'n', 'ppc64el': 'n', 's390x': 'n'\}>/g" ./debian.master/config/annotations
rm -r /opt/linux-azure-5.15.0/debian/linux-libc-dev/usr/include/* || true
LANG=C fakeroot debian/rules binary
# cd ..
# dpkg -i *.deb
# update-grub
# reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment