Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matsonkepson/5af78aff2a4c45a7789f7c4a674aa741 to your computer and use it in GitHub Desktop.
Save matsonkepson/5af78aff2a4c45a7789f7c4a674aa741 to your computer and use it in GitHub Desktop.
Installing k8s manually
#On all nodes
#ubu 18.04
#upgrade system
sudo apt update && sudo apt upgrade
#on all nodes activate kernel modules
cat <<_EOFF | sudo tee /etc/modules-load.d/containerd.conf
overlay
br_netfilter
_EOFF
sudo modprobe overlay
sudo modprobe br_netfilter overlay
cat <<_EOFF | 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
_EOFF
sudo sysctl --system
#On all nodes, Install and configure containerd.
sudo apt-get install -y containerd
sudo mkdir -p /etc/containerd
sudo containerd config default | sudo tee /etc/containerd/config.toml
sudo systemctl restart containerd
#On all nodes, disable swap.
sudo swapoff -a
#sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
sudo sed -i 's/\/swap/\#\/swap/g' /etc/fstab
#On all nodes, install kubeadm, kubelet, and kubectl
sudo apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
cat <<_EOFF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
_EOFF
sudo apt update && sudo apt-get install -y kubelet=1.20.1-00 kubeadm=1.20.1-00 kubectl=1.20.1-00
sudo apt-mark hold kubelet kubeadm kubectl
#########################
#On the control plane node only,
#install helm
sudo snap install helm --classic
#initialize the cluster and set up kubectl access.
sudo kubeadm init --pod-network-cidr 192.168.0.0/16
#To start using your cluster, you need to run the following as a regular user:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
#check version
kubectl version
#get the token in case you have forget your old one
kubeadm token create --print-join-command
#apply network
kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
#label new hosts as worker nodes
for i in $(kubectl get nodes |awk '/<none>/ {print$1}')
do
kubectl label node $i node-role.kubernetes.io/worker=worker
done
#apply metrics server
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment