Posted in Cloud, Kubernetes

Multi-node Kubernetes setup on Windows

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.

# Author: vishmule
## These steps will install VirtualBox and Vagrant on Windows VM
# Install chocolatey package manager for Windows.
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iwr -UseBasicParsing | iex
# Install VirtuaBox on Winodws
choco install virtualbox -y
# Install Vagrant on Windows
choco install vagrant -y
# Install Virtualbox guest plugin for Vagrant
vagrant plugin install vagrant-vbguest
# Download Wget package for Windows.
Install chocolatey package manager on Windows.
Install VirtualBox
Install Vagrant

Reboot VM here.

vagrant plugin install vagrant-vbguest

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 – (6G RAM & 4 vCPU)

worker1 – (2G RAM & 2CPU)

worker2 – (2G RAM & 2vCPU)

worker3 – (2G RAM & 2vCPU)

# Author: vishmule
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# General Vagrant VM configuration. = "centos/7"
config.ssh.insert_key = false
config.vm.synced_folder ".", "/vagrant", disabled: true
# KubeMaster
config.vm.define "kubemaster" do |master|
master.vm.hostname = "kubemaster" :private_network, ip: ""
master.vm.provider :virtualbox do |v|
v.memory = 6144
v.cpus = 4
v.linked_clone = true
# Worker1
config.vm.define "worker1" do |node|
node.vm.hostname = "worker1" :private_network, ip: ""
node.vm.provider :virtualbox do |v|
v.memory = 2048
v.cpus = 2
v.linked_clone = true
# Worker2
config.vm.define "worker2" do |node|
node.vm.hostname = "worker2" :private_network, ip: ""
node.vm.provider :virtualbox do |v|
v.memory = 2048
v.cpus = 2
v.linked_clone = true
# Worker3
config.vm.define "worker3" do |node|
node.vm.hostname = "worker3" :private_network, ip: ""
node.vm.provider :virtualbox do |v|
v.memory = 2048
v.cpus = 2
v.linked_clone = true
view raw Vagrantfile hosted with ❤ by GitHub

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

# Author: vishmule
# Configure VMs before installation of Kubernetes components
## Disable Selinux
setenforce 0
sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
## Update IP table setting
## This ensures that packets are properly processed by IP tables during filtering and port forwarding.
cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
sysctl –system
## Disable Swap in order to work kubelet smoothly
sed -i '/swap/d' /etc/fstab
swapoff -a
## Add Kubernetes Repo
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
## Install kubeadm and docker
yum install kubeadm docker -y
## Start and enabled docker, kubelet service
systemctl restart docker && systemctl enable docker
systemctl restart kubelet && systemctl enable kubelet
view raw hosted with ❤ by GitHub 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

# wget

Now run # sh

Next step is Kubernetes installation using kubeadm

# kubeadm init –apiserver-advertise-address= –pod-network-cidr

Perform intial steps.

Install network plugin for Kubernetes. I am using weave-net here.

kubectl apply -f “$(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 –token j414py.hm2alkc7jis4jsbm \
–discovery-token-ca-cert-hash sha256:46253866dac58f095f3e21ede72c685a33cf4cc8273bf9e810bece10c24db2fd

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.

Kubernetes is ready now


I have created this blog to share my learning from IT world. Hope you find it useful in your day to day work. Feel free to send me your feedback about my blog.

2 thoughts on “Multi-node Kubernetes setup on Windows

  1. Hi
    Thanks for this detailed blog post which I found really useful. Just a question on using Hyper-v I changed your instructions and use a hyper-v instead of Virtualbox but everytime I reboot my Win10 laptop, my VMs get a new Ip address which crashes the cluster. Any idea how to fix this?


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.