Install Minikube Kubernetes on Debian 12 (Bookworm)

For automating the deployment, scaling, and maintenance of containerized applications, there is a free and open-source container orchestration engine called Kubernetes. The Cloud Native Computing Foundation (CNCF) hosts the open-source endeavor.

Minikube is a minimal Kubernetes implementation that builds a single-node, simple cluster as a virtual machine on your local system. Windows, macOS, and Linux operating systems all support Minikube.

Here are the reasons for using Minikube;

  • It’s a really simple setup procedure.
  • Alternatives for flexible deployment.
  • All the main operating systems are supported.

Minikube has the following cool features;

  • Supports the most recent Kubernetes release and six earlier minor versions.
  • (Mac OS, Linux, and Windows) cross-platform.
  • Applications for Kubernetes that are simple to deploy with add-ons.
  • Supports typical CI settings.
  • Deploy as a VM, a container, or on bare metal.
  • Several container runtimes i.e. CRI-O, containerd, docker are supported.
  • Advanced features include LoadBalancer, filesystem
    mounts, FeatureGates, and network policy.
  • Direct API endpoint for incredibly quick image load and construction.

With the help of the Minikube program, users may manage a Kubernetes cluster with just one node. It is simple to set up and provides developers with the ideal testing environment to observe how their containerized application will function on Kubernetes.

Minikube OS Hardware Requirements

The following are prerequisites for running minikube;

  • A minimum of 2 GB of memory.
  • 2 CPUs (or more).
  • A minimum of 20 GB of storage.
  • Container i.e., docker, containerd, CRI-O.
  • Virtual machine manager i.e., KVM, Hyper-V, VMware workstation, etc.

Installing Minikube Local Kubernetes on Debian 12

The following steps will take you through how to setup minikube local kubernetes on Debian 12(Bookworm). We will use Kernel-based Virtual Machine(KVM) as our virtual machine manager in this guide.

1. Install KVM Virtualization stack

Refer to the following on installing KVM on Debian 12;

After installing KVM successfully;

Start and enable KVM:

sudo systemctl enable --now libvirtd

Confirm if kernel modules are loaded:

$ lsmod | grep -i kvm
kvm_intel             380928  0
kvm                  1146880  1 kvm_intel
irqbypass              16384  1 kvm

To enable the system user to issue the commands, add them to the KVM group:

sudo usermod -aG libvirt $USER 
newgrp libvirt

2. Install Kubectl

Kubectl helps in management of Kubernetes cluster. With the use of curl command, obtain the latest release by running the following command:

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

You can also install kubectl using Snap package manager:

#snap install kubectl --classic

Now, you can verify the kubectl version installed:

$ kubectl version --client -o json
{
  "clientVersion": {
    "major": "1",
    "minor": "28",
    "gitVersion": "v1.28.3",
    "gitCommit": "a8a1abc25cad87333840cd7d54be2efaf31a3177",
    "gitTreeState": "clean",
    "buildDate": "2023-10-18T11:42:52Z",
    "goVersion": "go1.20.10",
    "compiler": "gc",
    "platform": "linux/amd64"
  },
  "kustomizeVersion": "v5.0.4-0.20230601165947-6ce0bf390ce3"
}

3. Install Minikube on Debian 12

Now that you have KVM and kubectl installed on Debian 12, we proceed to install minikube. You can navigate to Github release page to obtain the latest minikube or you can use the wget command;

wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 -O minikube

Make the downloaded minikube file executable, then move to its $PATH;

chmod +x minikube 
sudo mv minikube /usr/local/bin/

Docker-driver for KVM is also required, you can download as shown below;

wget https://storage.googleapis.com/minikube/releases/latest/docker-machine-driver-kvm2

Make the downloaded docker-driver file executable, then move to its $PATH;

chmod +x docker-machine-driver-kvm2
sudo mv docker-machine-driver-kvm2 /usr/local/bin/

Now confirm the minikube version installed;

$ minikube version
minikube version: v1.31.2
commit: fd7ecd9c4599bef9f04c0986c4a0187f98a4396e

Run Minikube Local Kubernetes on Debian 12. We will run Minikube by specifying KVM driver as follows;

$ minikube start --driver=kvm 
😄  minikube v1.31.2 on  Debian 12
✨  Using the kvm2 driver based on existing profile
👍  Starting control plane node minikube in cluster minikube
🔄  Restarting existing kvm2 VM for "minikube" ...
🐳  Preparing Kubernetes v1.27.4 on Docker 24.0.4 ...
🔗  Configuring bridge CNI (Container Networking Interface) ...
🔎  Verifying Kubernetes components...
    ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟  Enabled addons: storage-provisioner, default-storageclass
🏄  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

Run the following command to make KVM as the default driver;

minikube config set driver kvm2 
minikube start

4. Minikube Instance Management

Use the following commands to administer Minikube.

#Start minikube
minikube start

#Stop minikube
minikube stop

#Restart minikube
minikube restart

#ssh into minikube
minikube ssh

#Pause minikube
minikube pause

#Unpause minikube
minikube unpause

#List available addons
minikube addons list

#delete minikube
minikube delete

5. Enabling Minikube Plugins

Minikube consists of many plugins that can enabled to function, let’s have a look at some of the plugins we can configure:

Enable Load Balancing

When the load balancer starts up, a single IP address is created and all traffic is forwarded to the service using this address. To assist in configuring the IP Address, you must enable the MetalLB plugin.
Run the following command to enable MetalLB;

$ minikube addons enable metallb
❗  metallb is a 3rd party addon and is not maintained or verified by minikube maintainers, enable at your own risk.
❗  metallb does not currently have an associated maintainer.
    ▪ Using image quay.io/metallb/speaker:v0.9.6
    ▪ Using image quay.io/metallb/controller:v0.9.6
🌟  The 'metallb' addon is enabled

To get the minikube IP address;

$ minikube ip
192.168.39.130

Well done, now define an IP range for the subnet above. Execute the command:

$ minikube addons configure metallb
-- Enter Load Balancer Start IP: 192.168.39.19  <- Specify the Load Balancer Start IP Address
-- Enter Load Balancer End IP: 192.168.39.30  <- Specify the Load Balancer End IP Address
    ▪ Using image quay.io/metallb/speaker:v0.9.6
    ▪ Using image quay.io/metallb/controller:v0.9.6
✅  metallb was successfully configured

Create the Nginx pod that we will expose its service using Load Balancer:

$ kubectl create deployment webserver --image=nginx
deployment.apps/webserver created

To expose the service using the Load Balancer:

$ kubectl expose deployment webserver --type="LoadBalancer" --port 80 --target-port 80
deployment.apps/webserver created

Confirm the service was created:

$ kubectl get svc
NAME         TYPE           CLUSTER-IP      EXTERNAL-IP     PORT(S)        AGE
kubernetes   ClusterIP      10.96.0.1       <none>          443/TCP        44m
webserver    LoadBalancer   10.102.37.234   192.168.39.19   80:31514/TCP   5s

Now, we can access Nginx from the server’s IP’ http://<Ip_address:80 in the browser:

5. Using Ingress in Minikube

With the aid of load balancing, SSL termination, and name-based virtual hosting, the Ingress Kubernetes API object controls external access to the services in a cluster. Through ingress, services within the cluster are accessible via HTTP and HTTPS routes from the outside cluster.

Now, enable the ingress addon:

$ minikube addons enable ingress
💡  ingress is an addon maintained by Kubernetes. For any concerns contact minikube on GitHub.
You can view the list of minikube maintainers at: https://github.com/kubernetes/minikube/blob/master/OWNERS
    ▪ Using image registry.k8s.io/ingress-nginx/kube-webhook-certgen:v20230407
    ▪ Using image registry.k8s.io/ingress-nginx/kube-webhook-certgen:v20230407
    ▪ Using image registry.k8s.io/ingress-nginx/controller:v1.8.1
🔎  Verifying ingress addon...
🌟  The 'ingress' addon is enabled

Verify whether the ingress controller is active:

$ kubectl get pods -n ingress-nginx
NAME                                        READY   STATUS      RESTARTS   AGE
ingress-nginx-admission-create-4n5d4        0/1     Completed   0          2m26s
ingress-nginx-admission-patch-sb66q         0/1     Completed   0          2m26s
ingress-nginx-controller-7799c6795f-8td4b   1/1     Running     0          2m26s

Create a manifest using vim, call it ingress.yaml, then edit the specs as shown, just change the hostname to suit you:

$ vim ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
    - host: nginx.cloudspinx.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: webserver
                port:
                  number: 80

Save and close the file, then run the command below to create the ingress object using ingress.yaml:

$ kubectl create -f ingress.yaml
ingress.networking.k8s.io/example-ingress created

Confirm if the object has been created successfully:

$ kubectl get ingress
NAME              CLASS   HOSTS                   ADDRESS          PORTS   AGE
example-ingress   nginx   nginx.techviewleo.com   192.168.39.130   80      108s

Obtain the minikube IP to run the deployment on the web:

$ minikube ip
192.168.39.130

Configure /etc/hosts and add the host in the yaml file and minikube IP as shown below:

$ sudo vim /etc/hosts 
192.168.39.130 nginx.techviewleo.com

Enter the URL nginx.cloudspinx.com into your web browser to check the success of the deployment via ingress. You ought to view the Nginx home page below:

6. Persistent Volumes on Minikube

Hostpath persistent volumes are supported out of the box by Minikube. Unless you specify –driver=none, –driver=docker, or –driver=podman, the persistent volumes are mapped to a directory inside the operating minikube instance, which is often a virtual machine.

The following folders created in the Minikube VM are configured in minikube to allow storage persistent;

  • /data*
  • /var/lib/minikube
  • /var/lib/docker
  • /var/lib/containerd
  • /var/lib/buildkit
  • /var/lib/containers
  • /tmp/hostpath_pv*
  • /tmp/hostpath-provisioner*

A sample Persistent Volume configuration for data persistence in the /data directory is shown below;

yaml
apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv0001
spec:
  accessModes:
    - ReadWriteOnce
  capacity:
    storage: 5Gi
  hostPath:
    path: /data/pv0001/

7. Minikube Dashboard

Use the command below to access the minikube dashboard;

$ minikube dashboard
🔌  Enabling dashboard ...
    ▪ Using image docker.io/kubernetesui/metrics-scraper:v1.0.8
    ▪ Using image docker.io/kubernetesui/dashboard:v2.7.0
💡  Some dashboard features require the metrics-server addon. To enable all features please run:

	minikube addons enable metrics-server	


🤔  Verifying dashboard health ...
🚀  Launching proxy ...
🤔  Verifying proxy health ...

With this command, the proxy is opened in the built-in web browser and the dashboard add-on is enabled. This is shown in the screenshot below;

Use the following command to run it without opening a dashboard directly in the browser;

 minikube dashboard --url

8. Changing Minikube Container Runtimes

A software element that may execute containers on a host operating system is a container runtime, commonly referred to as a container engine.

The container runtimes include the following ;

  • containerd
  • cri-o
  • Docker

Run the command below to specifically choose a container runtime, such as Docker, using Minikube;

$ minikube start --container-runtime=docker
✨  Using the kvm2 driver based on existing profile
👍  Starting control plane node minikube in cluster minikube
🏃  Updating the running kvm2 "minikube" VM ...
🐳  Preparing Kubernetes v1.27.4 on Docker 24.0.4 ...
🔎  Verifying Kubernetes components...
    ▪ Using image quay.io/metallb/speaker:v0.9.6
    ▪ Using image quay.io/metallb/controller:v0.9.6
    ▪ Using image docker.io/kubernetesui/metrics-scraper:v1.0.8
    ▪ Using image docker.io/kubernetesui/dashboard:v2.7.0
    ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
    ▪ Using image registry.k8s.io/ingress-nginx/controller:v1.8.1
    ▪ Using image registry.k8s.io/ingress-nginx/kube-webhook-certgen:v20230407
    ▪ Using image registry.k8s.io/ingress-nginx/kube-webhook-certgen:v20230407
🔎  Verifying ingress addon...
💡  Some dashboard features require the metrics-server addon. To enable all features please run:

	minikube addons enable metrics-server	


🌟  Enabled addons: default-storageclass, metallb, storage-provisioner, dashboard, ingress
🏄  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

9. Minikube Usage Examples

Check the below usage examples of Minikube:

Deploy an Application

We have demonstrated how to deploy Nginx application using Minikube. Run the command below to deploy Nginx app.

 kubectl create deployment webserver --image=nginx

Confirm the created deployment:

$ kubectl get deployments
NAME        READY   UP-TO-DATE   AVAILABLE   AGE
webserver   1/1     1            1           55m

Check the created Nginx pod:

$ kubectl get pods
NAME                         READY   STATUS    RESTARTS      AGE
webserver-566cf946c6-pz5jq   1/1     Running   1 (10m ago)   57m

Access pod’s shell:

kubectl exec -ti webserver-566cf946c6-pz5jq -- /bin/bash

Expose a Service

We have covered how to expose a service using a Load Balancer above, now let’s have a look at how we can expose a service using a NodePort. Expose the webserver as a NodePort service to outside traffic:

kubectl delete svc webserver
kubectl expose deployment webserver --type="NodePort" --port 80

Check the service created:

$ kubectl get services
NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
kubernetes   ClusterIP   10.96.0.1       <none>        443/TCP        106m
webserver    NodePort    10.109.109.50   <none>        80:30614/TCP   110s

Check the external IP address to access the service:

$ kubectl get service webserver
NAME        TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
webserver   NodePort   10.109.109.50   <none>        80:30614/TCP   42s

Scaling the Nginx Deployments

Now, try scaling the Nginx deployments up by six:

$ kubectl scale deployment webserver --replicas=6
deployment.apps/webserver scaled

Verify the replicas created:

$ kubectl get pods
NAME                         READY   STATUS    RESTARTS      AGE
webserver-566cf946c6-2wks4   1/1     Running   0             24s
webserver-566cf946c6-988zr   1/1     Running   0             24s
webserver-566cf946c6-pz5jq   1/1     Running   1 (20m ago)   68m
webserver-566cf946c6-vksbk   1/1     Running   0             24s
webserver-566cf946c6-w2hhj   1/1     Running   0             24s
webserver-566cf946c6-w2zrs   1/1     Running   0             24s

As per the output above, 5 more pods have been added.

Closing Thoughts

That concludes the matter. Minikube is a great tool for quickly setting up a local Kubernetes cluster on Windows, Linux, and macOS. Minikube is one of the most popular ways to deploy K8s clusters while using Ingress to expose apps to the outside world because of its sophisticated capabilities, which include filesystem mounts, load balancing, and a variety of add-on options. Minikube is high on the developer’s priority list since it allows you to select the CRI that you want.

Your IT Journey Starts Here!

Ready to level up your IT skills? Our new eLearning platform is coming soon to help you master the latest technologies.

Be the first to know when we launch! Join our waitlist now.

Join our Linux and open source community. Subscribe to our newsletter for tips, tricks, and collaboration opportunities!

Recent Post

Leave a Comment

Your email address will not be published. Required fields are marked *

Related Post

GlassFish is an open-source application server project started by Sun Microsystems for the Java EE platform, then sponsored by Oracle […]

This article will cover how to install Wine 8.x on Rocky Linux 8 / AlmaLinux 8. Wine is an application […]

Java is a high-level object-oriented programming language and computing platform intended to let application developers write once and run everywhere. […]

Let's Connect

Unleash the full potential of your business with CloudSpinx. Our expert solutions specialists are standing by to answer your questions and tailor a plan that perfectly aligns with your unique needs.
You will get a response from our solutions specialist within 12 hours
We understand emergencies can be stressful. For immediate assistance, chat with us now

Contact CloudSpinx today!

Download CloudSpinx Profile

Discover the full spectrum of our expertise and services by downloading our detailed Company Profile. Simply enter your first name, last name, and email address.