I used VirtualBox image of Ubuntu 16.04.6 Xenial from OSBoxes
Role | FQDN | IP | OS | RAM | CPU |
---|---|---|---|---|---|
Master | kmaster.example.com | 192.168.56.2 | Ubuntu 16.04.6 | 2G | 2 |
Worker | kworker.example.com | 192.168.56.3 | Ubuntu 16.04.6 | 1G | 1 |
Worker | kworker.example.com | 192.168.56.4 | Ubuntu 16.04.6 | 1G | 1 |
You can use virualbox Host only network to set these IP. Then update the followings:
/etc/hostname
/etc/hosts
/etc/network/interfaces #to give static IP from new Hostonly network
Perform all the commands as root user unless otherwise specified
ufw disable
swapoff -a; sed -i '/swap/d' /etc/fstab
cat >>/etc/sysctl.d/kubernetes.conf<<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system
{
apt install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt update
apt install -y docker-ce=5:19.03.10~3-0~ubuntu-xenial containerd.io
}
{
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list
}
apt update && apt install -y kubeadm=1.18.5-00 kubelet=1.18.5-00 kubectl=1.18.5-00
Update the below command with the ip address of kmaster
kubeadm init --apiserver-advertise-address=172.16.16.100 --pod-network-cidr=192.168.0.0/16 --ignore-preflight-errors=all
kubectl --kubeconfig=/etc/kubernetes/admin.conf create -f https://docs.projectcalico.org/v3.14/manifests/calico.yaml
kubeadm token create --print-join-command
If you want to be able to run kubectl commands as non-root user, then as a non-root user perform these
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
Use the output from kubeadm token create command in previous step from the master server and run here.
kubectl get nodes
kubectl get cs