0
votes

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
  1. Init kubeadm

    sudo kubeadm init --apiserver-advertise-address=192.168.50.2

  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

  3. Setup weave

    kubectl apply --filename https://git.io/weave-kube-1.6

  4. Validate that master mode is Ready and that dns pod is Running.

  5. Join node with no errors.

    kubeadm join --token 2f17fd.c5f6abcccdfa8c7a 192.168.50.2:6443

  6. 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
2

2 Answers

1
votes

Your problem is the default route in the machine. need to correct default route fist.

  • un configure current config 'kubeadm reset'
  • Install kubernets 1.6.4
  • remove the default route ' ip route delete default via 10.0.2.2'
  • add the prod network default route 'ip route add default via 192.168.50.1'
  • configure kubeadm 'kubeadm init --apiserver-advertise-address=192.168.50.2'
  • install the wave rbac and wave kube

Hope this helps.

0
votes

In order for the networking overlay to work in Kubernetes 1.6, you need to enable the RBAC rules.

From: https://github.com/weaveworks/weave/issues/2777

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: weave-net
rules:
- apiGroups:
  - ""
  resources:
  - pods
  - namespaces
  - nodes
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - extensions
  resources:
  - networkpolicies
  verbs:
  - get
  - list
  - watch
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: weave-net
  namespace: kube-system
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: weave-net
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: weave-net
subjects:
- kind: ServiceAccount
  name: weave-net
  namespace: kube-system

After that, the nodes will be in Ready state.