Kubernetes Kubeadm with Flannel Networking up & running

Okay, so I am going to try and make this brief  for you to get going. You need a Kubernetes cluster working with Kubeadm? good you are in the right place.

First, lets get over the problems. What you need to see at the end is the following:

kube-system dummy-2088944543-1x359 1/1 Running 1 1d
kube-system etcd-master 1/1 Running 1 1d
kube-system kube-apiserver-master 1/1 Running 0 1d
kube-system kube-controller-manager-master 1/1 Running 1 1d
kube-system kube-discovery-1769846148-1khb9 1/1 Running 1 1d
kube-system kube-dns-2924299975-pg660 4/4 Running 4 1d
kube-system kube-flannel-ds-25l4t 2/2 Running 2 1d
kube-system kube-flannel-ds-9jtd5 2/2 Running 2 1d
kube-system kube-flannel-ds-lvskl 2/2 Running 8 1d
kube-system kube-proxy-l1hn5 1/1 Running 1 1d
kube-system kube-proxy-p1kbt 1/1 Running 1 1d
kube-system kube-proxy-x2b1m 1/1 Running 1 1d
kube-system kube-scheduler-master 1/1 Running 1 1d

Not this …

kube-system dummy-2088944543-1x359 1/1 Running 1 1d
kube-system etcd-master 1/1 Running 1 1d
kube-system kube-apiserver-master 1/1 Running 0 1d
kube-system kube-controller-manager-master 1/1 Running 1 1d
kube-system kube-discovery-1769846148-1khb9 1/1 Running 1 1d
kube-system kube-dns-2924299975-pg660 4/4 CrashLoopBackOff 4 1d
kube-system kube-flannel-ds-25l4t 2/2 Running 2 1d
kube-system kube-flannel-ds-9jtd5 2/2 Running 2 1d
kube-system kube-flannel-ds-lvskl 2/2 Running 8 1d
kube-system kube-proxy-l1hn5 1/1 CrashLoopBackOff 1 1d
kube-system kube-proxy-p1kbt 1/1 CrashLoopBackOff 1 1d
kube-system kube-proxy-x2b1m 1/1 CrashLoopBackOff 1 1d
kube-system kube-scheduler-master 1/1 Running 1 1d

To get it right, follow the following steps:

  • First initiate your cluster with kubeadm
# Don't forget to copy the joining output for this command, you will need it kubeadm join --token  
kubeadm init --api-advertise-addresses= --pod-network-cidr=10.244.0.0/16
  • Once your kubeadm is ready for joining running the following (to avoid getting the crashLoopBackOff message):
# Overwrite the exisiting address with the new advertised address
jq \
'.spec.containers[0].command |= .+ ["--advertise-address=_put_ip_here"]' \
/etc/kubernetes/manifests/kube-apiserver.json > /tmp/kube-apiserver.json
mv /tmp/kube-apiserver.json /etc/kubernetes/manifests/kube-apiserver.json

# setup the correct proxy parameters
kubectl -n kube-system get ds -l 'component=kube-proxy' -o json \
| jq '.items[0].spec.template.spec.containers[0].command |= .+ ["--proxy-mode=userspace"]' \
| kubectl apply -f - && kubectl -n kube-system delete pods -l 'component=kube-proxy'
kubectl apply -f 
  • finally, join your nodes using the following command (you should have noted that from earlier):
kubeadm join --token=_token_ _master-ip_

Once having followed these steps, you should be able to see all the services running for all your nodes (it takes about a minute to get the services running and in good shape so wait!).

For testing purposes run the following command to get a pod started.

kubectl run --image=weaveworks/hello-world hello 

I hope this helps!

Advertisements