Here I m going to show how to install kubernetes on Ubuntu operating system.

Kubernetes:

According to the Kubernetes website: “Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications”.

Kubernetes comes from the Greek word called κυβερνήτης, it means helmsman or ship pilot, so that we can imagine that kubernetes acts as a manager for shipping containers.

Kubernetes is also referred to as k8s as there are 8 characters between k and s, similar to i18n referred to as Internationalization.

Install Kubernetes on Ubuntu:

We can install kubernetes in different modes based on our requirement. Following are the typical installation modes:

  • All-in-One Single-Node Installation
  • Single-Node etcd, Single-Master, and Multi-Worker Installation
  • Single-Node etcd, Multi-Master, and Multi-Worker Installation
  • Multi-Node etcd, Multi-Master, and Multi-Worker Installation

You can refer the kubernetes documentation to choose the right solution for your need.

All-in-One Single-Node Installation:

With All-in-One Single-Node installation, all the master and worker components are installed in a single node. It is much helpful for initial learning and testing the applications.

Note: This installation is not recommended or production environment.

As part of this tutorial, I am going to choose All-in-One Single-Node Installation with Minikube as it is the preferred and recommended way.

1. Installing Minikube:

Minikube is the easiest and the most recommended way to run all-in-one kubernetes cluster locally.

Prior to the minikube installation, we should have to install the virtual box if you haven’t done already.

1.1 Installing Virtual Box:

Terminal
cgoka@work:~$sudo apt-get install virtualbox
Install Kubernetes on Ubuntu

1.2 Installing Minikube:

Installing minikube in 3 steps:

  • Download the latest minikube from minikube releases
  • Make the minikube as executable
  • move the minikube to /usr/local/bin/ directory

to do the above 3 steps trigger the below command on your terminal.

Terminal
cgoka@work:~$curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.25.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
Install Kubernetes on Ubuntu

1.3 Start the minikube:

Terminal
goka@work:~$minikube start
Install Kubernetes on Ubuntu

1.4 Check minikube status:

Terminal
cgoka@work:~$minikube status
Install Kubernetes on Ubuntu

Everything looking good, we are able to install the all-in-one kubernetes cluster in the local environment. Let’s start accessing it.

2. Accessing Minikube:

We can access the kubernetes in two different modes:

  • The command line interface (kubectl) and
  • from the kubernetes dashboard (GUI).

kubectl is used to manage the kubernetes cluster resources and applications via the CLI. Let’s install kubectl and access minikube from cli.

2.1 installing kubectl:

Like minikube installation kubectl also have 3 different steps to install.

  • Download the kubectl from official releases
  • make kubectl as executable and
  • move kubectl to /usr/local/bin/kubectl
Terminal
cgoka@work:~$curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl

Make the kubectl as executable:

Terminal
cgoka@work:~$chmod +x ./kubectl

Move kubectl to /usr/local/bin/kubectl directory

Terminal
cgoka@work:~$sudo mv ./kubectl /usr/local/bin/kubectl
Install Kubernetes on Ubuntu

2.2 Access kubernetes using minikube dashboard:

To access the Minikube dashboard, we can use minikube dashboard command, which would open a new tab on our web browser, displaying the Kubernetes dashboard like below.

Terminal
cgoka@work:~$ minikube dashboard
Install Kubernetes On Ubuntu

3. Connecting Kubernets cluster:

To connect with kubernetes cluster kubectl needs a master node endpoint and credentials. While starting minikube, the startup process creates a default configuration file (inside .kube directory) which consists of all default required configurations.

Once the kubectl installed successfully, we can view the config file by running the below command.

Terminal
cgoka@work:~$kubectl config view
apiVersion: v1
clusters:
- cluster:
    certificate-authority: /home/cgoka/.minikube/ca.crt
    server: https://192.168.99.100:8443
  name: minikube
contexts:
- context:
    cluster: minikube
    user: minikube
  name: minikube
current-context: minikube
kind: Config
preferences: {}
users:
- name: minikube
  user:
    client-certificate: /home/cgoka/.minikube/client.crt
    client-key: /home/cgoka/.minikube/client.key

3.1 Start the minikube:

Terminal
cgoka@work:~$ minikube start
Starting local Kubernetes v1.9.0 cluster...
Starting VM...
Getting VM IP address...
Moving files into cluster...
Setting up certs...
Connecting to cluster...
Setting up kubeconfig...
Starting cluster components...
Kubectl is now configured to use the cluster.
Loading cached images from config file.

3.2 kubernetes cluster info using kubectl:

Install Kubernetes on Ubuntu
Terminal
cgoka@work:~$ kubectl cluster-info
Kubernetes master is running at https://192.168.99.100:8443

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

We can see that the kubernetes master is running at https://192.168.99.100:8443.

Now you are ready to deploy your containerized applications into kubernetes.

Happy Learning 🙂