In my previous post, I presented an easy way how to deploy Kubernetes cluster with Rancher. Kubernetes is hard to install without using third party tools, but luckily they released an official tool for simple deployment kubeadm. Please note that kubeadm is still in Alpha and not ready for production use, but it is good enough to play with on development environments. Kubernetes installation with kubeadm really simplifies deployment procedure and it is easy to use. Also, I find it very stable during my testing. kubeadm is a part of Kubernetes distribution starting with 1.4.0 release, but it does not track same release process at the moment. I’m expecting it to be ready for Kubernetes 1.6.

In this post, I will show you how to use kubeadm tool and some tips for installing Kubernetes on Vagrant environment. Everything is done manually for a better understanding of the process, but it could be easily automated with some configuration management tool like SaltStack. Here is Vagrantfile I used to run 3 VMs:

I also added additional network interface for Kubernetes cluster networking and a simple shell command to update hosts file during provisioning. This is required by Kubernetes networking to work when running on Vagrant because the first interface is NAT bridge and all nodes have the same IP address. After all VMs are up and running the first step is to add official Kubernetes repo and to install all required packages:

--api-advertise-addresses 192.168.33.10 to select which interface to use

--pod-network-cidr 10.244.0.0/16 is required for flannel network

--token 8c2350.f55343444a6ffc46 if omitted token will be auto-generated

A note from official docs on networking with kubeadm:

You must install a pod network add-on so that your pods can communicate with each other. It is necessary to do this before you try to deploy any applications to your cluster, and before kube-dns will start up. Note also that kubeadm only supports CNI based networks and therefore kubenet based networks will not work.

Flannel networking without Etcd

In this example, I will use Flannel experimental feature to use Kubernetes API as a datastore instead of Etcd. Options used to start Flannel containers:

1

/opt/bin/flanneld--iface=enp0s8--ip-masq--kube-subnet-mgr

--iface=enp0s8 parameter is required if you have multiple NICs. Also, I added KUBERNETES_SERVICE_HOST=192.168.33.10 and KUBERNETES_SERVICE_PORT=6443 environment variables for flannel to be able to reach Kubernetes API. Otherwise flannel will try to reach Kubernetes API at https://10.96.0.1:443, which for some reason is not accessible from agents. I’m not quite sure if this is a bug.

Adding Kubernetes dashboard

Accessing Kubernetes dashboard or any other service from your localhost is easy. You just need to find NodePort of the service and to create forward rule on VirtualBox. Find NodePort for kubernetes-dashboard service:

Would you know a way to deploy the above setup using a private kubernetes build? I have a clone of the kubernetes repository and have made some changes to it. Now I want to deploy those changes to a new cluster using the above approach.

Sorry, but I never did that and I don’t know if it is possible or not.

Traiano Welcome

Hi Alex, great article, thanks! One Issue I’m having though, I’m at the step where I want to expose the dashboard to the Mac computer I’m running VirtualBox on, however the networking of the dashboard service seems different to what you have in the article (so not sure how to expose it):