Kuber­netes (also known as K8s) enables efficient man­age­ment of large numbers of con­tain­ers and automates many processes in software de­vel­op­ment. With just a few steps, you can install a powerful Kuber­netes cluster and start using it pro­duct­ively right away.

IONOS Cloud Managed Kuber­netes
Container workloads in expert hands

The ideal platform for demanding, highly scalable container ap­plic­a­tions. Managed Kuber­netes works with many cloud-native solutions and includes 24/7 expert support.

Step 1: Prepare the system

In this tutorial, we’ll demon­strate in­stalling Kuber­netes on Ubuntu.

First, prepare the system by updating it to the latest version and in­stalling all necessary de­pend­en­cies. Open the terminal and run a system update to ensure all packages are current:

sudo apt update && sudo apt upgrade -y
bash

Next, install the key utilities required for in­stalling Kuber­netes and Minikube. You can use the following command:

sudo apt install -y curl wget apt-transport-https ca-certificates gnupg lsb-release
bash

These tools ensure you can securely use external sources and easily download and install ad­di­tion­al software packages.

Step 2: Install kubectl

Kuber­netes works with different servers: the master and various nodes. These do not ne­ces­sar­ily have to be on different physical servers. Virtual machines make it possible to run multiple Kuber­netes nodes on a single computer. For testing purposes, the free program Minikube has proven es­pe­cially useful. It lets you work with Kuber­netes locally. Since Minikube requires either a virtual machine or Docker, it depends on a hy­per­visor or container software. You’ll also need the tool kubectl.

Note

In this Kuber­netes tutorial, we’ll use Docker. You can, however, use vir­tu­al­isa­tion software such as Vir­tu­al­Box instead.

First, install kubectl (Kube Control) on your system. This program is required to manage clusters.

curl -LO "https://dl.k8s.io/release/$(curl -Ls https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/
bash
Note

In­stall­a­tion commands depend on your system ar­chi­tec­ture.

Step 3: Install Docker

Before using Minikube, make sure Docker is installed on your system. Docker acts as the container runtime and allows Minikube to run Kuber­netes clusters without vir­tu­al­isa­tion software. Install Docker with the following command:

sudo apt install -y docker.io
bash

To use Docker without root priv­ileges, add your user account to the Docker group:

sudo usermod -aG docker $USER
newgrp docker
bash

You may need to log out and back in for the group change to take effect. Test the in­stall­a­tion with:

docker run hello-world
bash

If you see a short success message, Docker is installed and ready for Minikube.

Step 4: Install and start Minikube

Next, install Minikube in a com­pat­ible version and use Docker as the driver. First, download the ap­pro­pri­ate version of Minikube, make the file ex­ecut­able, and move it to a system directory so the command is globally available:

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-arm64
chmod +x minikube-linux-arm64
sudo mv minikube-linux-arm64 /usr/local/bin/minikube
bash

After in­stall­a­tion, check if Minikube is set up correctly:

minikube version
bash

Then, start Minikube with:

minikube start --driver=docker
bash

Minikube uses Docker as the container runtime in this scenario and creates the Kuber­netes cluster directly within the Docker en­vir­on­ment. When Minikube starts, kubectl should be auto­mat­ic­ally con­figured. To switch from the command line to a GUI, enter another command. This will open the dashboard in your default browser.

minikube dashboard
bash
Image: Kubernetes dashboard
Empty Kuber­netes dashboard

Step 5: Try Kuber­netes out

When you start Minikube, it auto­mat­ic­ally creates a cluster with a single node. You can check this with kubectl:

kubectl get nodes
bash

Through the dashboard, you can now create de­ploy­ments. Click the Create button (the plus sign in the upper right) to open a web-based editor. In JSON or YAML format, you can create a de­ploy­ment there. Once you’ve done this, Kuber­netes auto­mat­ic­ally generates multiple pods. You can adjust the desired number by scaling the de­ploy­ment. You’ll find this function by clicking the three-dot button next to the de­ploy­ment.

Image: Kubernetes dashboard with a deployment and three pods
Kuber­netes: De­ploy­ment and pods in the dashboard
Image: Scaling a Deployment in Kubernetes
Kuber­netes: Scaling your de­ploy­ment

Al­tern­at­ively, you can create de­ploy­ments via the terminal, as long as the content is already packaged in a Docker image stored in a re­pos­it­ory:

kubectl create deployment --image=[path to the image]
bash

You can retrieve a variety of in­form­a­tion using command-line commands.

Which de­ploy­ments are available?

kubectl get deployments
bash

How many pods are there?

kubectl get pods
bash

Which services are available?

kubectl get services
bash

Which nodes are active?

kubectl get nodes
bash
Image: Terminal with various Kubernetes commands and outputs
Kuber­netes commands in the terminal

Step 6: Publish a de­ploy­ment

So far, you have started your de­ploy­ment but have not yet published it. To publish it, create a service:

kubectl expose deploy test-deployment
bash

This way, the service is published only within the cluster. To access the de­ploy­ment from outside the cluster, add ad­di­tion­al flags:

kubectl expose deploy test-deployment --type=LoadBalancer --port=8080
bash

With Minikube, you can then start the service:

minikube service test-deployment
bash

If you want to delete the service, there’s also a command for that:

kubectl delete service test-deployment
bash

The de­ploy­ment can also be deleted:

kubectl delete deployment test-deployment
bash

To finally shut down Minikube, stop the process:

minikube stop
bash

If you no longer want to work with the VM or the container runtime, you can delete it as well.

minikube delete
bash

Afterward, all con­fig­ur­a­tions, created de­ploy­ments, and pods are removed. When you start Minikube again, you will be working with an empty cluster.

Go to Main Menu