Setup K8s cluster via kubeadm




Kubernetes is an open source software tool for managing containerised workloads. It enables development teams to automate the deployment, scaling and management of applications. The kubeadm tool helps bootstrap a minimum viable Kubernetes cluster that conforms to best practices. This guide will walk you through how to install Kubernetes on Ubuntu 16.04.



Prerequisites

  • 3 Linux servers running Ubuntu 16.04
  • Access to a user account on each system with sudo or root privileges
  • The apt package manager, included by default
  • Command-line/terminal window (Ctrl-Alt-T)


Steps to Install Kubernetes on Ubuntu

Setup repository

Get the Docker gpg key:

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

Add the Docker repository:

$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"

Get the Kubernetes gpg key:

$ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -

Add the Kubernetes repository:

$ cat << EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF

Update your packages:

$ sudo apt-get update

Install Docker, kubelet, kubeadm, and kubectl:

$ sudo apt-get install -y docker-ce=18.06.1~ce~3-0~ubuntu kubelet=1.15.7-00 kubeadm=1.15.7-00 kubectl=1.15.7-00

Hold them at the current version:

$ sudo apt-mark hold docker-ce kubelet kubeadm kubectl

Add the iptables rule to sysctl.conf:

$ echo "net.bridge.bridge-nf-call-iptables=1" | sudo tee -a /etc/sysctl.conf

Enable iptables immediately:

$ sudo sysctl -p

Initialize the cluster (run only on the master):

$ sudo kubeadm init --pod-network-cidr=10.244.0.0/16

Set up local kubeconfig (run only on the master):

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

Apply Flannel CNI network overlay (run only on the master) :

$ kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

Join the worker nodes to the cluster:

$ sudo kubeadm join [your unique string from the kubeadm init command]

Verify the worker nodes have joined the cluster successfully:

$ kubectl get nodes

Comments

Popular posts from this blog

Mysql to CSV

Secure server with Firewalld