Skip to content

Instantly share code, notes, and snippets.

@michaelact
Last active December 20, 2021 06:09
Show Gist options
  • Save michaelact/8353864bcfc34b0fb4468ef92e5932a7 to your computer and use it in GitHub Desktop.
Save michaelact/8353864bcfc34b0fb4468ef92e5932a7 to your computer and use it in GitHub Desktop.
Install k8s + CRI-O
#!/bin/bash
# Create the .conf file to load the modules at bootup
cat <<EOF | sudo tee /etc/modules-load.d/crio.conf
overlay
br_netfilter
EOF
sudo modprobe overlay
sudo modprobe br_netfilter
# Set up 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
sudo sysctl --system
sudo swapoff -a
# Install CRI-O
cat <<EOF | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/ /
EOF
cat <<EOF | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable:cri-o:$VERSION.list
deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/$VERSION/$OS/ /
EOF
curl -L https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable:cri-o:$VERSION/$OS/Release.key | sudo apt-key --keyring /etc/apt/trusted.gpg.d/libcontainers.gpg add -
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/Release.key | sudo apt-key --keyring /etc/apt/trusted.gpg.d/libcontainers.gpg add -
sudo apt-get update
sudo apt-get install -y buildah cri-o cri-o-runc
cat <<EOF | sudo tee /etc/crio/crio.conf.d/02-cgroup-manager.conf
[crio.runtime]
conmon_cgroup = "pod"
EOF
sudo systemctl daemon-reload
sudo systemctl enable crio --now
# Install Kubectl, Kubeadm, Kubelet
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl
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
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
sudo systemctl enable kubelet
# Change Kubelet Configuration to use CRI-O
sudo echo "KUBELET_EXTRA_ARGS=--container-runtime=remote --container-runtime-endpoint=unix:///var/run/crio/crio.sock" >> /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
@michaelact
Copy link
Author

michaelact commented Dec 18, 2021

eXample:

#!/bin/bash

export OS=xUbuntu_20.04
export VERSION=1.22
wget https://gist.githubusercontent.com/michaelact/8353864bcfc34b0fb4468ef92e5932a7/raw/73e43f5e53d375e9cb97a5c912ba4ed02e3a5130/install-k8s.sh -O - | sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment