This commit is contained in:
sandervanvugt 2024-03-11 11:48:34 +01:00
parent 641b033bf1
commit 3ce7aba5b1

View File

@ -5,16 +5,27 @@
# this script supports Ubuntu 20.04 LTS and later only
# run this script with sudo
if ! [ $USER = root ]
if ! [ -f /tmp/container.txt ]
then
echo run this script with sudo
exit 3
echo run ./setup-container.sh before running this script
exit 4
fi
# setting MYOS variable
MYOS=$(hostnamectl | awk '/Operating/ { print $3 }')
OSVERSION=$(hostnamectl | awk '/Operating/ { print $4 }')
# detecting latest Kubernetes version
KUBEVERSION=$(curl -s https://api.github.com/repos/kubernetes/kubernetes/releases/latest | jq -r '.tag_name')
KUBEVERSION=${KUBEVERSION%.*}
# setting previous version
VERSION=${KUBEVERSION#*.}
PREVIOUSVERSION=$(( VERSION - 1 ))
echo $PREVIOUSVERSION
exit
if [ $MYOS = "Ubuntu" ]
then
echo RUNNING UBUNTU CONFIG
@ -23,23 +34,24 @@ then
EOF
sudo apt-get update && sudo apt-get install -y apt-transport-https curl
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
curl -fsSL https://pkgs.k8s.io/core:/stable:/${KUBEVERSION}/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/${KUBEVERSION}/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sleep 2
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
swapoff -a
sudo swapoff -a
sed -i 's/\/swap/#\/swap/' /etc/fstab
sudo sed -i 's/\/swap/#\/swap/' /etc/fstab
fi
# Set iptables bridging
cat <<EOF > /etc/sysctl.d/k8s.conf
sudo cat <<EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system
sudo sysctl --system
sudo crictl config --set \
runtime-endpoint=unix:///run/containerd/containerd.sock