We can create mulit-node kubernetes setup on Windows laptop/VM as well. Mostly if you want to learn or try and test Kubernetes concepts.
I am using Windows 2012 server, it will work on other Windows version as well.
We use Virtualbox and Vagrant to configure Kubernetes nodes.
Perform following steps as pre-requisites.
Reboot VM here.
Create Vagrantfile for 4 Kubernetes nodes (1 master and 3 worker nodes). I am using following values for memory and CPU, you can use as per your hardware resource. you can remove 1 worker node as well. Using CentOS image for this setup.
kubemaster – 192.168.56.2 (6G RAM & 4 vCPU)
worker1 – 192.168.56.3 (2G RAM & 2CPU)
worker2 – 192.168.56.4 (2G RAM & 2vCPU)
worker3 – 192.168.56.5 (2G RAM & 2vCPU)
Once you created a file in user’s home directory execute vagrant status. It will read the Vagrantfile and show the status of all VMs as not created.
Now run # vagrant up
I will take few mins to complete the installation as it will download CentOS image first and then create 4 linked clones for kubernetes nodes.
Now check vagrant status. It should show all 4 VMs as running.
Now next step is to configure Kubernetes nodes. SSH to kubemaster and create configure-vm.sh
configure.sh file which will perform following required configuration before installing Kubernetes
a. Disable SELINUX using sentenforce and udpate the config file
b. Update IP table settting, This ensures the packets are properly processed by IP tables during filtering and port forwarding.
c. Disable swap in order to work kubelet smoothly.
d. Add Kubernetes repo
e. Install Kubeadm and docker
f. Enable and start kubelet and docker
# vagrant ssh kubemaster
# sudo -i
# yum install wget -y
Now run # sh configure-vm.sh
Next step is Kubernetes installation using kubeadm
# kubeadm init –apiserver-advertise-address=192.168.56.2 –pod-network-cidr 10.32.0.0/12
Perform intial steps.
Install network plugin for Kubernetes. I am using weave-net here.
kubectl apply -f “https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d ‘\n’)”
We are done with all the configuration on kubemaster now. Copy kubeadm join command and save it.
kubeadm join 192.168.56.2:6443 –token j414py.hm2alkc7jis4jsbm \
Now exit from kubemaster and login to worker nodes1, 2 and 3 and copy configure-vm.sha and run it.
run kubeadm join comamnd to add the node in kubernetes cluster
Perform the same steps on remaining worker nodes.
That’s it Kubernetes configuration is completed now. Check status of all the nodes.