From 77273105014df54cef060c87d4018f797717e967 Mon Sep 17 00:00:00 2001 From: sandervanvugt Date: Tue, 5 Mar 2024 09:24:08 +0100 Subject: [PATCH] message --- setup-container-new.sh | 65 ++++++++++++++++++++++++++++++++++++++++++ setup-kubetools-new.sh | 52 +++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100755 setup-container-new.sh create mode 100755 setup-kubetools-new.sh diff --git a/setup-container-new.sh b/setup-container-new.sh new file mode 100755 index 0000000..55ab656 --- /dev/null +++ b/setup-container-new.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# script that runs +# https://kubernetes.io/docs/setup/production-environment/container-runtime + +# changes March 14 2023: introduced $PLATFORM to have this work on amd64 as well as arm64 + +# setting MYOS variable +MYOS=$(hostnamectl | awk '/Operating/ { print $3 }') +OSVERSION=$(hostnamectl | awk '/Operating/ { print $4 }') +# beta: building in ARM support +[ $(arch) = aarch64 ] && PLATFORM=arm64 +[ $(arch) = x86_64 ] && PLATFORM=amd64 + +if [ $MYOS = "Ubuntu" ] +then + ### setting up container runtime prereq + cat <<- EOF | sudo tee /etc/modules-load.d/containerd.conf + overlay + br_netfilter + EOF + + sudo modprobe overlay + sudo modprobe br_netfilter + + # Setup required sysctl params, these persist across reboots. + cat <<- EOF | sudo tee /etc/sysctl.d/99-kubernetes-cri.conf + net.bridge.bridge-nf-call-iptables = 1 + net.ipv4.ip_forward = 1 + net.bridge.bridge-nf-call-ip6tables = 1 + EOF + + # Apply sysctl params without reboot + sudo sysctl --system + + # (Install containerd) + + sudo apt-get update && sudo apt-get install -y containerd + # hopefully temporary bugfix as the containerd version provided in Ubu repo is tool old + # added Jan 26th 2023 + # this needs to be updated when a recent enough containerd version will be in Ubuntu repos + sudo systemctl stop containerd + # cleanup old files from previous attempt if existing + [ -d bin ] && rm -rf bin + wget https://github.com/containerd/containerd/releases/download/v1.7.13/containerd-1.7.13-linux-${PLATFORM}.tar.gz + tar xvf containerd-1.7.13-linux-${PLATFORM}.tar.gz + sudo mv bin/* /usr/bin/ + # Configure containerd + sudo mkdir -p /etc/containerd + cat <<- TOML | sudo tee /etc/containerd/config.toml +version = 2 +[plugins] + [plugins."io.containerd.grpc.v1.cri"] + [plugins."io.containerd.grpc.v1.cri".containerd] + discard_unpacked_layers = true + [plugins."io.containerd.grpc.v1.cri".containerd.runtimes] + [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc] + runtime_type = "io.containerd.runc.v2" + [plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options] + SystemdCgroup = true + TOML + + # Restart containerd + sudo systemctl restart containerd +fi + diff --git a/setup-kubetools-new.sh b/setup-kubetools-new.sh new file mode 100755 index 0000000..3eedd47 --- /dev/null +++ b/setup-kubetools-new.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# kubeadm installation instructions as on +# https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/ + +# this script supports Ubuntu 20.04 LTS and later only +# run this script with sudo + +if ! [ $USER = root ] +then + echo run this script with sudo + exit 3 +fi + +# setting MYOS variable +MYOS=$(hostnamectl | awk '/Operating/ { print $3 }') +OSVERSION=$(hostnamectl | awk '/Operating/ { print $4 }') + +if [ $MYOS = "Ubuntu" ] +then + echo RUNNING UBUNTU CONFIG + cat < /etc/sysctl.d/k8s.conf +net.bridge.bridge-nf-call-ip6tables = 1 +net.bridge.bridge-nf-call-iptables = 1 +EOF +sysctl --system + +sudo crictl config --set \ + runtime-endpoint=unix:///run/containerd/containerd.sock +echo 'after initializing the control node, follow instructions and use kubectl apply -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/calico.yaml to install the calico plugin (control node only). On the worker nodes, use sudo kubeadm join ... to join'