How do I install Kubernetes on Ubuntu and set up a cluster

0 votes
How do I install Kubernetes on Ubuntu and set up a cluster?
Feb 22, 2019 in Kubernetes by Isha
2,203 views

1 answer to this question.

0 votes

Hey Isha, Follow these steps to create a kube cluster with one master and one node on ubuntu.

Execute these steps on master as well as nodes:

$ sudo su
$ apt-get update
Turn off the swap space:
swapoff -a

Go to the following file and comment out the line which mentions swap.

nano /etc/fstab

Go to /etc/hostname of master node and change the name to kmaster

Go to /etc/hostname of the worker node and change it to knode

Go to /etc/hosts file of the master and add the IP address of your kmaster and knode

Do the same for all the worker nodes.

Make the IP addresses static. Go to

nano /etc/network/interfaces

and add these lines:

auto enp0s8
iface enp0s8 inet static
address <IP-Address-Of-VM>

Install Docker

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

Install Kubernetes Environment

$ 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
EOF
$ apt-get update

Install kubeadm, kubectl and kubelet

$ apt-get install -y kubelet kubeadm kubectl 

Change the config file of kubernetes, go to the following file:

nano /etc/systemd/system/kubelet.service.d/10-kubeadm.conf

Add this:

Environment=”cgroup-driver=systemd/cgroup-driver=cgroupfs”

Execute this only on Kubernetes master:

kubeadm init --apiserver-advertise-address=<ip-address-of-kmaster-vm> --pod-network-cidr=192.168.0.0/16

Run these commands as a non root user:

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

Go to the worker node and execute the join command mentioned in the master

Verify if all your pods are running from the master:

$ kubectl get pods -o wide --all-namespaces

And your cluster is ready :)

answered Feb 22, 2019 by Hemant

Related Questions In Kubernetes

0 votes
1 answer
0 votes
1 answer

How do I set up a k8s cluster on windows?

Hey @Nadia, follow these steps to create ...READ MORE

answered Feb 25, 2019 in Kubernetes by Roshan
641 views
0 votes
1 answer

How do you set-up Mongo replica set on Kubernetes?

Follow these steps To create a Kubernetes 1.5 ...READ MORE

answered Aug 30, 2018 in Kubernetes by Kalgi
• 52,350 points
2,022 views
0 votes
1 answer

Set up kubernetes cluster on ubuntu

Do kubeadm reset and start all over ...READ MORE

answered Oct 5, 2018 in Kubernetes by Kalgi
• 52,350 points
787 views
+1 vote
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17, 2019 in Others by anonymous
15,487 views
0 votes
2 answers
0 votes
1 answer

How do I run kubernetes on AWS

There are two main ways to use ...READ MORE

answered Oct 26, 2018 in Kubernetes by Kalgi
• 52,350 points
772 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP