John Siu's personal blog

Tech - Business Tool, Personal Toys

Kubernetes Installation

This serve as a starting point for installing Kubernetes on multiple Ubuntu Servers.


H = Hands-on, C = Concept

Kubernetes Version: 1.11

Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.3", GitCommit:"a4529464e4629c21224b3d52edfe0ea91b072862", GitTreeState:"clean", BuildDate:"2018-09-09T18:02:47Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.3", GitCommit:"a4529464e4629c21224b3d52edfe0ea91b072862", GitTreeState:"clean", BuildDate:"2018-09-09T17:53:03Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}

Prepare all nodes

If you are creating your own Linux virtual/machines for k8s:

Turn off swap and update /etc/fstab

sudo swapoff -a
sudo sed -i '/swap/ s/^/#/' /etc/fstab

Network config

sudo echo net.bridge.bridge-nf-call-iptables=1 >> /etc/sysctl.d/10-network-security.conf

Kernel Modules

sudo echo ip_vs_wrr >> /etc/modules
sudo echo ip_vs_sh >> /etc/modules
sudo echo ip_vs >> /etc/modules
sudo echo ip_vs_rr >> /etc/modules

Set Timezone (EST)


sudo timedatectl set-timezone EST

Install Docker (all nodes)

sudo su -
apt -y install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt -y install docker-ce

Install kubectl kubeadm kubelet (all nodes)

apt-get update && apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main

apt-get update
apt-get install -y kubelet kubeadm kubectl

apt-mark hold kubelet kubeadm kubectl


Master node

Init as root

sudo kubeadm init

Setup kubctl for user

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

Other node (as root)

The first node will give a command line to join the cluster like following:

kubeadm join --token 8jrmrd.sskhizsrsndj10zx --discovery-token-ca-cert-hash sha256:a7b98ae8e51a598141d9e9678669ac1372afca7cda1c4e603070adb34fbd2985

Install pod add-on

Install Weave Net from master node

kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"


This conclude the Kubernetes installation. Next post will have commands that can test out Kubernetes capabilities.

30 Sep 2018 #kubernetes

comments powered by Disqus