Jump to content

Kubernetes Guide for Master and Nodes installation on your Ubuntu Machine


Recommended Posts

In this guide we will be installing Kubernetes Master server, together with installing Kubernetes Node servers and connecting them to the Master server. Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications from a Master server instance.
 

0. Requirements:

  • KVM Linux server running on Ubuntu 16.04 OS.
 

1. Preparing Your VPS For Installation Of Kubernetes:

Both, Master server and Node servers has to be prepared with required packages. Firstly, update your package list (commands will be initiated as root. If done by other user, use "sudo"):
apt-get update
Afterwards, when the packages list are updates, proceed with installation of apt-transport-https package:
apt-get install -y apt-transport-https
Afterwards, install Docker that will be the container system for Kubernetes:
apt install docker.io -y
When the installation will be completed, start and enable Docker service:
systemctl start docker && systemctl enable docker

2. Installation Of Kubernetes:

Since the required packages and other instances have been installed, we can now proceed with installation of Kubernetes server. Firstly let's download and add the key for Kubernetes Installation:
Now let's create a file with your text editor (We will be using "nano" for this one, however you can use any other):
nano /etc/apt/sources.list.d/kubernetes.list
In the file enter the following line, save and close it:
deb http://apt.kubernetes.io/ kubernetes-xenial main
Now, let's install the Kubernetes with required packets:
apt-get update && apt-get install -y kubelet kubeadm kubectl kubernetes-cni

3. Setting Up Kubernetes Master Server:

The following command will setup the configuration files and boot up the whole Master server.
sudo kubeadm init
!!!Important!!!, do not close terminal after this command is completed, since you will receive your unique token key, which is required for Node server to connect. The setup will take about couple of minutes. Following command should be used as additional user with sudo rights:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
The formed token with connection command should look like this:
kubeadm join <master node IP>:6443 --token i5s534.38o26swycl0gd0gr --discovery-token-ca-cert-hash sha256:4b4c8d9652e925dffe0f28c73984c27d821cd998f63525dd45378a762517dea3
 
The token should be valid only for 24 hours. If you would like to add other nodes to your cluster after some time, new token can be generated with using
kubeadm token generate

4. Connecting Node Server To Master:

This is the easiest part. When you will have your Master server running, for your Node servers, repeat the "1. Preparing your VPS for installation of Kubernetes" and "2. Installation of Kubernetes" parts of this guide for general installation of Kubernetes. When the Node server will have Kubernetes installed, use the command that was generated for you at the end of Master node configuration:
kubeadm join <master node IP>:6443 --token 
i5s534.38o26swycl0gd0gr --discovery-token-ca-cert-hash 
sha256:4b4c8d9652e925dffe0f28c73984c27d821cd998f63525dd45378a762517dea3
Instead of master node IP server will have generated your Master server's IP address so no additional adjustments will be required. If you will use your separately generated token, you should adjust the --token code to the one that will be generated for you.

5. Finishing Up The Setup:

To check if everything was correct, from the Master node initiate the command
kubectl get nodes

Command results should look similar to:

NAME                     STATUS    ROLES     AGE       VERSION
Node.hostname   Ready     <none>    1d        v1.11.2
Master.hostname   Ready     master    1d        v1.11.2
...

You can now set services for you cluster or scale it's size by adding additional servers to the cluster in the same way as you have added the first node. For more information on cluster management, loads of useful information is provided in the Kubernetes Documentation. Good luck with your cluster!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...