From 39bb4cac48d22dfac21113ed85e5c0d8eee8220d Mon Sep 17 00:00:00 2001 From: nyyu Date: Fri, 31 Dec 2021 18:04:47 +0100 Subject: [PATCH] k3s: update --- k3s-bin/.SRCINFO | 21 ++++++++------- k3s-bin/PKGBUILD | 18 ++++++++----- k3s-bin/k3s-killall.sh | 61 ++++++++++++++++++++++++++++++++++++++++++ k3s-bin/k3s.service | 9 +++++-- 4 files changed, 91 insertions(+), 18 deletions(-) create mode 100644 k3s-bin/k3s-killall.sh diff --git a/k3s-bin/.SRCINFO b/k3s-bin/.SRCINFO index a0b547c..35e9516 100644 --- a/k3s-bin/.SRCINFO +++ b/k3s-bin/.SRCINFO @@ -1,22 +1,25 @@ pkgbase = k3s-bin pkgdesc = Lightweight Kubernetes - pkgver = 1.22.3+k3s1 + pkgver = 1.22.5+k3s1 pkgrel = 1 url = https://k3s.io arch = x86_64 arch = armv7h arch = aarch64 license = Apache - conflicts = k3s-git + provides = k3s + conflicts = k3s source = k3s.service source = k3s.service.env - sha256sums = f4ae496b69b3dd376a28298df50297728a47761b041be522adf2537aa8a8c3d8 + source = k3s-killall.sh + sha256sums = 38f0e1f67a7eb4fa8ad3836dd34b6298bf45c9873560a2fe6bb391a16ad4c59d sha256sums = 667199fa6b811dde3aef3e626e2695a566ad64c9a03d19d0c94a1f104a7612d0 - source_x86_64 = k3s-1.22.3+k3s1-x86_64::https://github.com/rancher/k3s/releases/download/v1.22.3+k3s1/k3s - sha256sums_x86_64 = b22f0a1c18a62b58137759d419a0e077eed640c6784425756c5f04910d6a6866 - source_armv7h = k3s-1.22.3+k3s1-armv7h::https://github.com/rancher/k3s/releases/download/v1.22.3+k3s1/k3s-armhf - sha256sums_armv7h = f5bd416e2b760461c07b8419a4d6e89784325bcd6b7b125fa4c6ea8ac0625a31 - source_aarch64 = k3s-1.22.3+k3s1-aarch64::https://github.com/rancher/k3s/releases/download/v1.22.3+k3s1/k3s-arm64 - sha256sums_aarch64 = 3185cc41b8fc8a1e35ea8d92a11da82f0d6e64fa6e2eac5818dffb8ff1dd1363 + sha256sums = 73662123fb2273bcb520231838cbfa6360d0f4354fc958284c4bf07c1a9f027d + source_x86_64 = k3s-1.22.5+k3s1-x86_64::https://github.com/rancher/k3s/releases/download/v1.22.5+k3s1/k3s + sha256sums_x86_64 = f18e0e17f11d3052f00ca4428bd548b6bf936bcfb71d8ad49a91154a6b5e460f + source_armv7h = k3s-1.22.5+k3s1-armv7h::https://github.com/rancher/k3s/releases/download/v1.22.5+k3s1/k3s-armhf + sha256sums_armv7h = 8d5964532a66757f65ff784491727a8c283aec176e004688e8ac40c0554dc15e + source_aarch64 = k3s-1.22.5+k3s1-aarch64::https://github.com/rancher/k3s/releases/download/v1.22.5+k3s1/k3s-arm64 + sha256sums_aarch64 = 2eb878cbc660613c2b06745eaabfa97c6b6932e2822e09ab89bccf1f016a1e0a pkgname = k3s-bin diff --git a/k3s-bin/PKGBUILD b/k3s-bin/PKGBUILD index 663c60d..622d833 100644 --- a/k3s-bin/PKGBUILD +++ b/k3s-bin/PKGBUILD @@ -1,16 +1,18 @@ # Maintainer: duxet pkgname=k3s-bin -pkgver=1.22.3+k3s1 +pkgver=1.22.5+k3s1 pkgrel=1 pkgdesc="Lightweight Kubernetes" url="https://k3s.io" license=('Apache') arch=('x86_64' 'armv7h' 'aarch64') -conflicts=('k3s-git') +provides=('k3s') +conflicts=('k3s') source=( "k3s.service" "k3s.service.env" + "k3s-killall.sh" ) source_x86_64=( @@ -25,17 +27,19 @@ source_aarch64=( "k3s-${pkgver}-aarch64::https://github.com/rancher/k3s/releases/download/v${pkgver}/k3s-arm64" ) -sha256sums=('f4ae496b69b3dd376a28298df50297728a47761b041be522adf2537aa8a8c3d8' - '667199fa6b811dde3aef3e626e2695a566ad64c9a03d19d0c94a1f104a7612d0') -sha256sums_x86_64=('b22f0a1c18a62b58137759d419a0e077eed640c6784425756c5f04910d6a6866') -sha256sums_armv7h=('f5bd416e2b760461c07b8419a4d6e89784325bcd6b7b125fa4c6ea8ac0625a31') -sha256sums_aarch64=('3185cc41b8fc8a1e35ea8d92a11da82f0d6e64fa6e2eac5818dffb8ff1dd1363') +sha256sums=('571af7c8403f2f433afa50702a53658dbb9f846da7c6ac2a3ba6cc454039429a' + '667199fa6b811dde3aef3e626e2695a566ad64c9a03d19d0c94a1f104a7612d0' + '73662123fb2273bcb520231838cbfa6360d0f4354fc958284c4bf07c1a9f027d') +sha256sums_x86_64=('f18e0e17f11d3052f00ca4428bd548b6bf936bcfb71d8ad49a91154a6b5e460f') +sha256sums_armv7h=('8d5964532a66757f65ff784491727a8c283aec176e004688e8ac40c0554dc15e') +sha256sums_aarch64=('2eb878cbc660613c2b06745eaabfa97c6b6932e2822e09ab89bccf1f016a1e0a') package() { install -Dm 755 $srcdir/k3s-${pkgver}-${CARCH} $pkgdir/usr/bin/k3s + install -Dm 755 $srcdir/k3s-killall.sh $pkgdir/usr/bin/k3s-killall install -dm 755 $pkgdir/usr/lib/systemd/system install -dm 755 $pkgdir/etc/systemd/system diff --git a/k3s-bin/k3s-killall.sh b/k3s-bin/k3s-killall.sh new file mode 100644 index 0000000..fd03cf4 --- /dev/null +++ b/k3s-bin/k3s-killall.sh @@ -0,0 +1,61 @@ +#!/bin/sh +[ $(id -u) -eq 0 ] || exec sudo $0 $@ +for bin in /var/lib/rancher/k3s/data/**/bin/; do + [ -d $bin ] && export PATH=$PATH:$bin:$bin/aux +done +set -x +for service in /etc/systemd/system/k3s*.service; do + [ -s $service ] && systemctl stop $(basename $service) +done +for service in /etc/init.d/k3s*; do + [ -x $service ] && $service stop +done +pschildren() { + ps -e -o ppid= -o pid= | \ + sed -e 's/^\s*//g; s/\s\s*/\t/g;' | \ + grep -w "^$1" | \ + cut -f2 +} +pstree() { + for pid in $@; do + echo $pid + for child in $(pschildren $pid); do + pstree $child + done + done +} +killtree() { + kill -9 $( + { set +x; } 2>/dev/null; + pstree $@; + set -x; + ) 2>/dev/null +} +getshims() { + ps -e -o pid= -o args= | sed -e 's/^ *//; s/\s\s*/\t/;' | grep -w 'k3s/data/[^/]*/bin/containerd-shim' | cut -f1 +} +killtree $({ set +x; } 2>/dev/null; getshims; set -x) +do_unmount_and_remove() { + set +x + while read -r _ path _; do + case "$path" in $1*) echo "$path" ;; esac + done < /proc/self/mounts | sort -r | xargs -r -t -n 1 sh -c 'umount "$0" && rm -rf "$0"' + set -x +} +do_unmount_and_remove '/run/k3s' +do_unmount_and_remove '/var/lib/rancher/k3s' +do_unmount_and_remove '/var/lib/kubelet/pods' +do_unmount_and_remove '/var/lib/kubelet/plugins' +do_unmount_and_remove '/run/netns/cni-' +# Remove CNI namespaces +ip netns show 2>/dev/null | grep cni- | xargs -r -t -n 1 ip netns delete +# Delete network interface(s) that match 'master cni0' +ip link show 2>/dev/null | grep 'master cni0' | while read ignore iface ignore; do + iface=${iface%%@*} + [ -z "$iface" ] || ip link delete $iface +done +ip link delete cni0 +ip link delete flannel.1 +ip link delete flannel-v6.1 +rm -rf /var/lib/cni/ +iptables-save | grep -v KUBE- | grep -v CNI- | iptables-restore diff --git a/k3s-bin/k3s.service b/k3s-bin/k3s.service index fe760f4..7f07b53 100644 --- a/k3s-bin/k3s.service +++ b/k3s-bin/k3s.service @@ -2,16 +2,21 @@ Description=Lightweight Kubernetes Documentation=https://k3s.io After=network-online.target +Wants=network-online.target [Service] Type=notify -EnvironmentFile=/etc/systemd/system/k3s.service.env +EnvironmentFile=-/etc/default/%N +EnvironmentFile=-/etc/sysconfig/%N +EnvironmentFile=-/etc/systemd/system/k3s.service.env ExecStartPre=-/sbin/modprobe br_netfilter ExecStartPre=-/sbin/modprobe overlay ExecStart=/usr/bin/k3s server KillMode=process Delegate=yes -LimitNOFILE=infinity +# Having non-zero Limit*s causes performance problems due to accounting overhead +# in the kernel. We recommend using cgroups to do container-local accounting. +LimitNOFILE=1048576 LimitNPROC=infinity LimitCORE=infinity TasksMax=infinity