Installing Kubernetes - using kubeadm

Its quite easy to install kubernetes using kubeadm.

software used - kubeadm, kubectl, kubelet, calico(pod network)

This tutorial is made, based on this,

https://lukemarsden.github.io/docs/getting-started-guides/kubeadm/

https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/

https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/#tear-down

Prerequisties:

  1. ubuntu 16.04, 2 Core, 8 GB RAM - 2 system
  2. Network connectivity between the nodes, internet

Note: I am using Two Ubuntu 16.04 VMs with 16GB, 4 Core.

COMMON INSTALLATION METHOD FOR MASTER AND WORKER NODES:

Execute all below as ROOT user.

Disable the firewall:

service iptables stop

Installing docker

sudo -i
apt-get update
apt-get upgrade
apt-get install -y ebtables ethtool
apt-get install -y docker.io

Update the docker cgroup driver, execute this command as below:

cat << EOF > /etc/docker/daemon.json
{
  "exec-opts": ["native.cgroupdriver=cgroupfs"]
}
EOF

restart the docker:

service docker restart

Disable the swap

swapoff -a

Install kubernetes

apt-get update && apt-get install -y apt-transport-https
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
EOF
apt-get update
apt-get install -y kubelet kubeadm kubectl

To check the kubelet status:

service kubelet status
kubelet status

Note: kublet service will be exited and restarted frequently, till we setup master and worker node.

MASTER NODE SETUP:

Initialize the master node (run as root)

kubeadm init --kubernetes-version v1.8.0 --pod-network-cidr=10.244.0.0/16

Note : keep the output of the command in the text file. this has secret key info for joining the worker.

Move it normal user and setup the kubectl command access:

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

Now you can use kubctl command in the normal mode:

cloud@kube-1:~$ kubectl get nodes
NAME      STATUS     ROLES     AGE       VERSION
kube-1    NotReady   master    4m        v1.8.2
cloud@kube-1:~$

Install CALICO Pod Network

kubectl apply -f https://docs.projectcalico.org/v2.6/getting-started/kubernetes/installation/hosted/kubeadm/1.6/calico.yaml

Verify the calico pods are created:

cloud@kube-1:~$ kubectl get pods --all-namespaces
NAMESPACE     NAME                                       READY     STATUS    RESTARTS   AGE
kube-system   calico-etcd-z9lcz                          1/1       Running   0          1m
kube-system   calico-kube-controllers-6ff88bf6d4-ltdps   1/1       Running   0          1m
kube-system   calico-node-mldhd                          2/2       Running   0          1m
kube-system   etcd-kube-1                                1/1       Running   0          7m
kube-system   kube-apiserver-kube-1                      1/1       Running   0          7m
kube-system   kube-controller-manager-kube-1             1/1       Running   0          7m
kube-system   kube-dns-545bc4bfd4-5vmqg                  3/3       Running   0          7m
kube-system   kube-proxy-4k926                           1/1       Running   0          7m
kube-system   kube-scheduler-kube-1                      1/1       Running   0          6m
cloud@kube-1:~$

Move the master to accept the pod creation:

Note: Normally master node doesnot used for pod creation. it will be only worker nodes. To use master node also for pod creation , use it as below.

cloud@kube-1:~$ kubectl taint nodes --all node-role.kubernetes.io/master-
node "kube-1" untainted
cloud@kube-1:~$
cloud@kube-1:~$ kubectl get nodes
NAME      STATUS    ROLES     AGE       VERSION
kube-1    Ready     master    9m        v1.8.2
cloud@kube-1:~$
cloud@kube-1:~$ kubectl cluster-info
Kubernetes master is running at https://10.0.1.4:6443
KubeDNS is running at https://10.0.1.4:6443/api/v1/namespaces/kube-system/services/kube-dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
cloud@kube-1:~$

WORKER NODE SETUP:

Join to the master node using the output from "kubeadm init" in the master node

kubeadm join --token 909b7a.923e14e0deea48ba 10.0.1.4:6443 --discovery-token-ca-cert-hash sha256:17a68eed77e2d43789b5a96fad5eecacce8568c193ca2c93217b1a1d5f25b0d2

Verification:

cloud@kube-1:~$ kubectl get nodes
NAME      STATUS    ROLES     AGE       VERSION
kube-1    Ready     master    9m        v1.8.2
cloud@kube-1:~$

results matching ""

    No results matching ""