Created
April 23, 2021 21:47
-
-
Save eriksywu/0af9780a19774f216c01f58f7cb98ff0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kind: DaemonSet | |
apiVersion: apps/v1 | |
metadata: | |
name: downgradecontainerd | |
namespace: kube-system | |
labels: | |
app: downgradecontainerd | |
spec: | |
selector: | |
matchLabels: | |
name: downgradecontainerd | |
template: | |
metadata: | |
labels: | |
name: downgradecontainerd | |
spec: | |
hostPID: true | |
hostNetwork: true | |
nodeSelector: | |
beta.kubernetes.io/os: linux | |
containers: | |
- name: nsenter | |
image: alpine | |
imagePullPolicy: IfNotPresent | |
securityContext: | |
privileged: true | |
command: | |
- nsenter | |
- --target | |
- "1" | |
- --mount | |
- --uts | |
- --ipc | |
- --net | |
- --pid | |
- -- | |
- sh | |
- -c | |
- | | |
#! /bin/sh | |
set -u | |
docker --version | |
if [ $? -eq 0 ]; then | |
echo "docker node, skipping containerd downgrade" | |
sleep infinity | |
fi | |
while true; do | |
TARGET_VERSION="1.4.4" | |
CURRENT_VERSION=$(containerd -version | cut -d " " -f 3 | sed 's|v||' | cut -d "+" -f 1) | |
if [ -z ${CURRENT_VERSION} ]; then | |
echo "not a containerd node" | |
sleep infinity | |
else | |
echo "current containerd version = ${CURRENT_VERSION}" | |
fi | |
if [ "${CURRENT_VERSION}" = "${TARGET_VERSION}" ]; then | |
echo "containerd at target version of ${TARGET_VERSION}" | |
sleep infinity | |
fi | |
echo "installing containerd version ${TARGET_VERSION}" | |
apt-get -y -f install moby-containerd=${TARGET_VERSION}* moby-runc=1.0.0~rc92* --allow-downgrades | |
if [ $? -ne 0 ]; then | |
echo "downgrade was not successful, exited with status $?" | |
exit 1 | |
fi | |
CURRENT_VERSION=$(containerd -version | cut -d " " -f 3 | sed 's|v||' | cut -d "+" -f 1) | |
if [ $CURRENT_VERSION != "${TARGET_VERSION}" ]; then | |
echo "containerd version ${CURRENT_VERSION} not at ${TARGET_VERSION}" | |
exit 1 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment