Create VM

  • 2 vCPUs for Master, 1 CPU for Worker
  • 4G RAM
  • 30G storage
  • Ubuntu iso
  • Set the default network adapter to connect to the “Bridged adapter” to enable traffic between the VM and the host machine.

Prepare VM

  1. Change to Root
sudo su
  1. Turn off swap
swapoff -a

Edit /ect/fstab to comment out the line

#UUID=d0200036-b211-4e6e-a194-ac2e51dfb27d none         swap sw  
  1. Configure iptables to add new 3 lines
vi /etc/ufw/sysctl.conf
net/bridge/bridge-nf-call-ip6tables = 1
net/bridge/bridge-nf-call-iptables = 1
net/bridge/bridge-nf-call-arptables = 1
  1. Reboot

  2. Install ebtables and ethtool

sudo su
apt-get install ebtables ethtool
  1. Reboot

Install Kubeadm

  1. Change to Root
sudo su
  1. Install Docker
apt-get install -y docker.io
  1. Install Curl
apt-get install curl
  1. Retrieve the key for the Kubernetes repo and add it to your key manager
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
  1. Add the kubernetes repo
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF
  1. Update and install kubeadm, kubelet, kubectl
apt-get update
apt-get install -y kubelet kubeadm kubectl

Clone worker

  • Check Reinitialize the MAC address of all network cards
  • Full clone

Set hostname

  1. Change to Root
sudo su
  1. Modify /etc/hosts Add Master and all workers IP in each machine.
192.168.1.x master
192.168.1.y worker-y
192.168.1.z worker-z
  1. Set hostname
vi /etc/hostname

Change default to specific name.

Create a Cluster on Master machine

  1. Init kubeadm with Calico CNI
kubeadm init --pod-network-cidr=192.168.0.0/16

Remember the token in output to join a node later.

  1. Start cluster
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
  1. Install Calico network plugin.
kubectl apply -f https://docs.projectcalico.org/v2.6/getting-started/kubernetes/installation/hosted/kubeadm/1.6/calico.yaml
  1. Untaint the master so that it will be available for scheduling workloads
kubectl taint nodes --all node-role.kubernetes.io/master-

Join Node

  1. Install ssh
sudo apt-get install openssh-server
  1. Enable service
sudo service ssh status
  1. Access to worker node and execute the command with token above
ssh username@worker-ip-address
sudo su
kubeadm join...

Test

Get nodes:

sudo kubectl get nodes