How to install kubernetes with kubeadm on ubuntu

Kubernetes is a container orchestration system that manages containers at scale. It was initially developed by Google based on its experience running containers in production.
It’s an open source tool now.

Kubeadm is a single-node kubernetes cluster created by the k8s community to simplify the deployment process. Kubeadm automates the installation and configuration of Kubernetes components such as the API server, Controller Manager, and Kube DNS.

Read Also: Dockerize node js app

Install kubeadm:

In this section, We will install the operating system level packages required by Kubernetes. now, we’re ready to go ahead and do the install.

1. Install Docker:

It is a container runtime and It is the component that runs your containers.

sudo su
apt-get update
apt-get install -y docker.io

2. Install HTTPS support (if necessary):

apt-get update
apt-get install -y apt-transport-https

3. Install Curl (if necessary):

apt-get install curl

4. Retrieve the key for the Kubernetes repo and add it to your key manager:

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

5. Add the kubernetes repo to your system:

cat </etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF

6. Actually, install the three pieces we’ll need, kubeadm, kubelet, and kubectl:

apt-get update
apt-get install -y kubelet kubeadm kubectl

At this point, We have all the tools we need. We can create a cluster and deploy.

Create a cluster:

We can create a single-node kubernetes cluster. Part of this process, We need to choose the network providers. There are several network providers available like flannel, weave, and calico etc.

In this example, We use calico as our network plugin. For Calico, we need to add the –pod-network-cidr switch, as in:

kubeadm init --pod-network-cidr=192.168.0.0/16

It will take some time and eventually return some output.

To make kubectl work for your non-root user, run these commands, which are also part of the kubeadm init output:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

Install calico network plugin

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

Check if all the pods are running

kubectl get pods --all-namespaces

This pods will take some time to start and run

If it is a single node cluster, you need to untaint the master to schedule workloads

kubectl taint nodes --all node-role.kubernetes.io/master-

Now, the fully functional kubernetes cluster is ready to run your workloads.

Consider reading:  Dockerize bash script

If you have any issues using this tutorial please feel free to comment below.

Leave a Reply

Your email address will not be published.


*