I am trying to setup kubernetes using kubeadm 1.6. The master and nodes are created using Vagrant with Ubuntu 16.04 box. I followed all the instructions and can't figure this out.
vagrant file:
Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-16.04"
config.vm.box_check_update = false
config.vm.provider "virtualbox" do |vb|
vb.cpus = 2
vb.memory = "1024"
end
config.vm.provision "shell", path: "provision.sh"
config.vm.define "master" do |c|
c.vm.hostname = "master"
c.vm.network "private_network", ip: "192.168.50.2", netmask: "255.255.255.0", auto_config: true, virtualbox__intnet: "k8s-net"
c.vm.provision :shell, inline: "sed 's/127\.0\.0\.1.*master.*/192\.168\.50\.2 master/' -i /etc/hosts"
end
config.vm.define "node1" do |c|
c.vm.hostname = "node1"
c.vm.network "private_network", ip: "192.168.50.3", netmask: "255.255.255.0", auto_config: true, virtualbox__intnet: "k8s-net"
c.vm.provision :shell, inline: "sed 's/127\.0\.0\.1.*node1.*/192\.168\.50\.3 node1/' -i /etc/hosts"
end
config.vm.define "node2" do |c|
c.vm.hostname = "node2"
c.vm.network "private_network", ip: "192.168.50.4", netmask: "255.255.255.0", auto_config: true, virtualbox__intnet: "k8s-net"
c.vm.provision :shell, inline: "sed 's/127\.0\.0\.1.*node2.*/192\.168\.50\.4 node2/' -i /etc/hosts"
end
end
Init kubeadm
sudo kubeadm init --apiserver-advertise-address=192.168.50.2
Run the provided commands
sudo cp /etc/kubernetes/admin.conf $HOME/ sudo chown $(id -u):$(id -g) $HOME/admin.conf export KUBECONFIG=$HOME/admin.conf
Setup weave
kubectl apply --filename https://git.io/weave-kube-1.6
Validate that master mode is Ready and that dns pod is Running.
Join node with no errors.
kubeadm join --token 2f17fd.c5f6abcccdfa8c7a 192.168.50.2:6443
Node appears on master, but never gets into Ready state. Running kubectl describe node node1 shows this error:
KubeletNotReady runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized
Why am I getting this error? I tried installing kubeadm 1.5.6 and I get the same error.
Please help.
Update Found the solution here: How to get kube-dns working in Vagrant cluster using kubeadm and Weave
First, find the public IP by running the following on master.
kubectl get svc
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes 10.96.0.1 <none> 443/TCP 1h
In each node, make sure that any process using 10.96.0.1 (in my case) is routed to master that is on 10.30.3.41.
So on each Node (you can skip master) use route to set the redirect.
route add 10.96.0.1 gw 10.30.3.41