Learn how to use Kubeadm to install Kubernetes in mins

2 minute read


Long time ago, the way to install kubernetes was quite complicate. After kubernetes 1.4, we can use Kubeadm to install a kubernetes cluster with only two steps. Now, let’s start our journey.


  • Ubuntu 16.04


  • install.sh
apt-get update && apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
apt-get update
# Install docker if you don't have it already.
apt-get install -y docker.io
apt-get install -y kubelet kubeadm kubectl kubernetes-cni

Install basic dependencies

$ chmod +x install.sh
$ sudo ./install.sh

Install Kubernetes core service

$ sudo kubeadm init


  • –apiserver-advertise-address: IP address of api server
  • –apiserver-bind-port: port no. of api server (default 6443).
  • –pod-network-cidr: range of virtaul IP for pods.
  • –kubernetes-version: specified Kubernetes version (recommend 1.6+)

Config Kubectl

$ mkdir -p $HOME/.kube/config/
$ sudo cp /etc/kubernetes/admin.conf $HOME/.kube/config/
$ sudo chown $(id -u):$(id -g) $HOME/.kube/config/admin.conf

Now, you can use a standalone Kubernetes! Have fun :)

$ kubectl get pod


  • Nodes stall in NotReady status due to cni config uninitialized
$ kubectl describe nodes
KubeletNotReady runtime network not ready: NetworkReady=false reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized

Kubernetes introduces RBAC since v1.6, we need to create correspond Service Account, RBAC rules and flannel daemonset so that kubelet can communicate with api server correctly. Execute following commands and wait for couple seconds before nodes turn into Ready status.

$ kubectl create -f https://raw.githubusercontent.com/coreos/flannel/v0.9.0/Documentation/kube-flannel.yml

Advanced CMD

Remove Kubernetes

  • NOTICE: this cmd will remove all kubernetes related services and data.
$ sudo kubeadm reset

Add compute node

Once kubeadm init is finished, you will see the command below with a valid token. Execute the command on new compute node to join the kubernetes cluster.

$ sudo kubeadm join --token <token> <api server ip>:<port>

Access remote Kubernetes api server

$ cp admin.conf <path>/admin.conf
$ kubectl --kubeconfig <path>/admin.conf proxy
Starting to serve on
$ kubectl get pod --server=

Further Readings


comments powered by Disqus