The container boom is a phenomenon we have seen strongly in recent years. Kubernetes solves many of our current problems with the container model to make our work easier. In this tutorial, we will see how to create a single node Kubernetes cluster, step by step, using Minikube in Ubuntu 20.04 LTS.
Step 1: Docker Run Time Setting
According to the official Minikube documentation, to implement Minikube we need a containerized runtime environment or a virtual machine manager like Docker, KVM or Virtual Box that can be used as a driver.
By default, Minikube uses Virtual Box as its driver. You must have VT-x (virtualization technology) enabled in your BIOS to run a virtual machine manager such as Virtual Box. However, if you are trying to configure the Minikube in a VM or a VPS (Virtual Private Server), you most likely have VT-x disabled, so you cannot use Virtual Box as an option.
To solve this problem, we need to configure the Docker runtime on our machine.
Install some necessary packages as prerequisite
curl – To transfer data between servers
sudo apt-get install whirlwind
apt-transport-https – allows the package manager to transfer files and data via https
sudo apt – install apt-transport-https
ca-certificates – allows the web browser and system to check security certificates
sudo apt-get install ca-certificates
software-properties-common – provides some useful scripts for adding and removing PPAs (Personal Package Archives)
sudo apt-get installation software-properties-common
Addition of docking stations for installation
Let’s add the GPG key and the archive by running the following commands
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –
sudo add-apt-repository deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable
Start an appropriate update to update the information in the repository.
sudo apt update
To make sure the installation is from the Docker repository, run the following command:
apt-cache docker-ce caching policy
The correct status output must contain something like
Docker Lake:
Installed: (no)
Docking Station Installation
Run the following command to install docker-ce (Docker – Community Edition)
Installing a Test Docker with the Hello World test image from Docker.
sudo-docker Hurrah for the world
You will see that the image works with this output:
Now that Docker is installed, we’re a little closer to installing the Minikube.
Step 2: Add a user to the Docker group
Right now, Docker requires root privileges to run. If we use Docker as a driver, it forces us to use Minikube as a root, which is not allowed.
We need to solve this problem by adding the current user to the Docker group to be able to use Docker without root privileges.
Follow these steps to add the current user to the Docker group.
sudo usermod -aG docker $USER && newgrp docker
Step 3: Installation of the minicube
Minikube is a single-node local cluster startup tool that allows you to quickly learn and evolve for Kubernetes.
To install the Minikube, first load the last binary with curl :
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
Run the following command to install the downloaded binary:
minikube-linux-amd64 install /usr/local/bin/minikube
You can now control your mini-cube with Docker as the driver by running it:
minicube start – driver=docker
You can see the output of the next mini cube from Docker
Pay attention: Recommended resources for Minikube are 2 GB memory with 2 CPUs for proper operation. The server I was using had less memory, so we see the memory warning in the screenshot above.
Let’s install Kubectl and deal with our K8 cluster as follows:
sudo snap install kubectl
Check the capsules that work with Kubectl (-A to see all capsules, including those in the Kube system).
Control box platforms -A
Minikube is now operational and we can start using our services with Kubectl.
Now let’s test a K8 installation with the Nginx server. Here is the YAML model for Nginx:
apiVersion: v1
View : Metadata Pod
: Name
: Reverse proxy tag
:
Asking: Backend
Specification : Container: – Image: nginx Name: nginx
We save it to a file called pod.yaml and apply it with Kubectl by running the following command.
kubectl apply -f pod.yaml
After a few seconds you can see the Nginx server working with the specified reverse-proxy name by running the following command
cubic capsules
Now let’s redirect it to one of the local ports on the test computer.
(By default, Nginx runs on port 80 in the Container, and we redirect it to port 8080 on the test machine).
8080:80 Forward Reverse Cab
And you will see that it is broadcast as shown below.
Now let’s open another terminal session and test it locally with curl. You can see how well the Nginx homepage is served.
local host: 8080
To access from a remote address outside the computer, I will use a tool called Ngrok. Simply put: Ngrok makes local servers behind NATs and firewalls accessible to the public Internet through secure tunnels.
We can easily do this by following these steps.
Install the Ngrok with a snap function :
sudo snap install ngrok
Create a tunnel on Nginx running on local port 8080 :
ngrock http 8080
HTTP and HTTPS URLs are displayed with the Ngrok domain as shown below. You can copy the printed URL and type it into your browser to access the public Internet.
You can see the homepage of the Nginx server running in our cluster in any browser, as shown below.
We now have a successful K8 cluster with Nginx as the reverse proxy.
Related Tags: