Skip to content

A easy walkthrough for setting up a Kubernetes cluster on Ubuntu( multinodes )

Guoxi Li edited this page Jan 5, 2016 · 1 revision

Actually there is a complete user-guild for creating a kubernetes cluster at github/kubernetes.

However, it is organized in a bad and unclear manner, which makes it difficult for beginners to find out where to start up.

Don't worry. I abstract it here.

tl;dr

All below is tested successfully on Ubuntu 14.04

Step 1 get kubernetes source code

git clone https://github.com/kubernetes/kubernetes.git
cd kubernetes

Step 2 customization of your own configuration

in the file cluster/Ubuntu/config-default.sh, you need to customize it according to your own settings. Below is a where you should modify:

export nodes="vcap@10.10.103.250 vcap@10.10.103.162 vcap@10.10.103.223"

export role="ai i i"

export NUM_MINIONS=${NUM_MINIONS:-3}

export SERVICE_CLUSTER_IP_RANGE=192.168.3.0/24

export FLANNEL_NET=172.16.0.0/16

variable nodes is all your cluster nodes, which in the form of username@hostname

variable role is all the roles of your above cluster nodes. Roles include a for master and i for minion. master and minion can be combined for nodes that are both master and minion.

variable NUM_MINIONS corresponds to the number of cluster nodes you've defined above.

Other variables you can leave them alone. In most cases, they can't affect your kubernetes cluster setting up.

Step 3 set up cluster

just type command below once and for all

cd kubernetes/cluster
KUBERNETES_PROVIDER=ubuntu ./kube-up.sh

to test if it works successfully, you need to add the cluster/ubuntu/binaries to PATH and type:

kubectl get nodes

that will show all the nodes in the cluster like this

NAME            LABELS                              STATUS   AGE
<hostname>      kubernetes.io/hostname=<hostname>   Ready    2s