Skip to content

Instantly share code, notes, and snippets.

@marco74
Created June 9, 2022 12:06
Show Gist options
  • Save marco74/2b0e35c5b6e844560bf6066caf7df51c to your computer and use it in GitHub Desktop.
Save marco74/2b0e35c5b6e844560bf6066caf7df51c to your computer and use it in GitHub Desktop.
# Install prerequisites
sudo apt-get -y update
sudo apt-get -y install ca-certificates curl gnupg lsb-release
# Setup Docker's repository
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get -y update
# Install containerd
sudo apt-get -y install containerd.io
# Configure containerd
## comment the line with disabled_plugins in config.toml, this enables containerd cri plugin, after restart
sudo sed -i "s/^\(disabled_plugins\s*=\)/# \1/" /etc/containerd/config.toml
## containerd's CGroup Settings
cat <<EOF | sudo tee -a /etc/containerd/config.toml
### from https://github.com/kubernetes/kubernetes/issues/105762
version = 2
[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
EOF
## restart containerd
sudo systemctl restart containerd
# Firewall
## Load those kernel modules when restarting computer
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
## Load the same modules immediately
sudo modprobe overlay
sudo modprobe br_netfilter
## Settings for the firewall
cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
EOF
## Load sysctl settings now
sudo sysctl --system
# Kubernetes
## Setup repository
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
## Install latest version
sudo apt-get install -y kubelet kubeadm kubectl
# Setup
## Download images for later initialization joining
sudo kubeadm config images pull
echo "If this computer is considered to be the master use:"
echo " sudo kubeadm --pod-network-cidr=10.244.0.0/16 init"
echo "after that follow the instructions"
echo "Keep in mind to also install a CNI"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment