How to Set Up a Kubernetes Cluster Using Minicube on Debian 11
Minikube is a free and open-source tool that comes with a set of built-in add-ons that helps you to set up a Kubernetes cluster in your local system. The 'minicube' command provides several subcommands that allow you to manage the Kubernetes cluster via the command line interface. Minikube is Cross-platform and supports many operating systems, including Linux, macOS, and Windows. It can be deployed as a VM, a container, or on bare metal.
This tutorial will teach how to install Minikube on Debian 11.
Requirements
- A Fresh Debian 11 is installed on your system.
- A root password is set up on your system.
Install Docker
Before installing Minikube, the Docker package must be installed on your server. If not installed, you can install it using the following command.
apt install docker.io -y
After installing Docker, you can verify the Docker version using the following command.
docker --version
You should see the following output.
Docker version 20.10.5+dfsg1, build 55c4c88
Install Kubectl
Kubectl is a tool to deploy and manage applications on Kubernetes. By default, Kubectl is not available in the Debian 11 default repository. So, you will need to install it using Snap.
First, install the Snap package using the following command.
apt install snapd -y
Next, create a symbolic link for Snap package using the following command.
ln -s /var/lib/snapd/snap /snap
Next, add a Snap path to your system profile.
echo 'export PATH=$PATH:/var/lib/snapd/snap/bin' | tee -a /etc/profile.d/snap.sh
Next, start and enable the Snap service with the following command.
systemctl enable --now snapd.service snapd.socket
Next, install the kubectl package using the following command.
snap install kubectl --classic
Next, create a symbolic link of kubectl package using the following command.
ln -s /snap/kubectl/current/kubectl /usr/bin/
Now, verify the kubectl version using the following command.
kubectl version -o yaml
You should see the following output:
clientVersion: buildDate: "2022-12-09T16:23:44Z" compiler: gc gitCommit: b46a3f887ca979b1a5d14fd39cb1af43e7e5d12d gitTreeState: clean gitVersion: v1.26.0 goVersion: go1.19.4 major: "1" minor: "26" platform: linux/amd64 kustomizeVersion: v4.5.7
Install Minikube
By default, the Minikube package is not included in the Debian default repo. So you will need to download the Minikube binary to your system.
First, download Minikube with the following command.
wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 -O minikube
Next, copy the Minikube binary to the system path.
cp minikube /usr/local/bin/
Next, set the executable permission with the following command.
chmod +x /usr/local/bin/minikube
Now, verify the Minikube version using the following command.
minikube version
You will get the following output.
minikube version: v1.28.0 commit: 986b1ebd987211ed16f8cc10aed7d2c42fc8392f
Once you are done, you can proceed to the next step.
Start Minikube
At this point, all the required packages are installed. You can now start Minikube with the following command:
minikube start --force
This will download the docker image and configure the Kubernetes cluster as shown below:
???? minikube v1.28.0 on Debian 11.6 (kvm/amd64) ? minikube skips various validations when --force is supplied; this may lead to unexpected behavior ? Automatically selected the docker driver. Other choices: none, ssh ???? The "docker" driver should not be used with root privileges. If you wish to continue as root, use --force. ???? If you are running minikube within a VM, consider using --driver=none: ???? https://minikube.sigs.k8s.io/docs/reference/drivers/none/ ???? Using Docker driver with root privileges ???? Starting control plane node minikube in cluster minikube ???? Pulling base image ... ???? Downloading Kubernetes v1.25.3 preload ... > preloaded-images-k8s-v18-v1...: 385.44 MiB / 385.44 MiB 100.00% 37.08 M > gcr.io/k8s-minikube/kicbase: 386.27 MiB / 386.27 MiB 100.00% 27.51 MiB > gcr.io/k8s-minikube/kicbase: 0 B [________________________] ?% ? p/s 10s ???? Creating docker container (CPUs=2, Memory=2200MB) ... ???? Preparing Kubernetes v1.25.3 on Docker 20.10.20 ... ? Generating certificates and keys ... ? Booting up control plane ... ? Configuring RBAC rules ... ???? Verifying Kubernetes components... ? Using image gcr.io/k8s-minikube/storage-provisioner:v5 ???? Enabled addons: default-storageclass, storage-provisioner ???? Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
You can now check the cluster status with the following command:
kubectl cluster-info
You should see the following output:
Kubernetes control plane is running at https://192.168.49.2:8443 CoreDNS is running at https://192.168.49.2:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To check the running nodes, run the following command:
kubectl get nodes
Output:
NAME STATUS ROLES AGE VERSION minikube Ready control-plane 67s v1.25.3
You can also access the Minikube container with the following command:
minikube ssh
Output:
docker@minikube:~$
Now, exit from the container shell using the following command:
$exit
You can stop and delete Kubernetes cluster anytime with the following command:
minikube stop
minikube delete
You can check the status of Minikube with the following command:
minikube status
Output:
minikube type: Control Plane host: Running kubelet: Running apiserver: Running kubeconfig: Configured
Once you are done, you can proceed to the next step.
Access Minikube Kubernetes Dashboard
By default, Minikube provides a web dashboard that can be used to manage your cluster.
You can list all the minikube addons with the following command:
minikube addons list
You should see the following output:
|-----------------------------|----------|--------------|--------------------------------| | ADDON NAME | PROFILE | STATUS | MAINTAINER | |-----------------------------|----------|--------------|--------------------------------| | ambassador | minikube | disabled | 3rd party (Ambassador) | | auto-pause | minikube | disabled | Google | | cloud-spanner | minikube | disabled | Google | | csi-hostpath-driver | minikube | disabled | Kubernetes | | dashboard | minikube | disabled | Kubernetes | | default-storageclass | minikube | enabled ? | Kubernetes | | efk | minikube | disabled | 3rd party (Elastic) | | freshpod | minikube | disabled | Google | | gcp-auth | minikube | disabled | Google | | gvisor | minikube | disabled | Google | | headlamp | minikube | disabled | 3rd party (kinvolk.io) | | helm-tiller | minikube | disabled | 3rd party (Helm) | | inaccel | minikube | disabled | 3rd party (InAccel | | | | | [[email protected]]) | | ingress | minikube | disabled | Kubernetes | | ingress-dns | minikube | disabled | Google | | istio | minikube | disabled | 3rd party (Istio) | | istio-provisioner | minikube | disabled | 3rd party (Istio) | | kong | minikube | disabled | 3rd party (Kong HQ) | | kubevirt | minikube | disabled | 3rd party (KubeVirt) | | logviewer | minikube | disabled | 3rd party (unknown) | | metallb | minikube | disabled | 3rd party (MetalLB) | | metrics-server | minikube | disabled | Kubernetes | | nvidia-driver-installer | minikube | disabled | Google | | nvidia-gpu-device-plugin | minikube | disabled | 3rd party (Nvidia) | | olm | minikube | disabled | 3rd party (Operator Framework) | | pod-security-policy | minikube | disabled | 3rd party (unknown) | | portainer | minikube | disabled | 3rd party (Portainer.io) | | registry | minikube | disabled | Google | | registry-aliases | minikube | disabled | 3rd party (unknown) | | registry-creds | minikube | disabled | 3rd party (UPMC Enterprises) | | storage-provisioner | minikube | enabled ? | Google | | storage-provisioner-gluster | minikube | disabled | 3rd party (Gluster) | | volumesnapshots | minikube | disabled | Kubernetes | |-----------------------------|----------|--------------|--------------------------------|
Next, list all the container images running in the cluster with the following command:
kubectl get pods --all-namespaces
You should see the following output:
NAMESPACE NAME READY STATUS RESTARTS AGE kube-system coredns-565d847f94-9ttdq 1/1 Running 0 2m47s kube-system etcd-minikube 1/1 Running 0 3m kube-system kube-apiserver-minikube 1/1 Running 0 3m1s kube-system kube-controller-manager-minikube 1/1 Running 0 3m kube-system kube-proxy-mr8sn 1/1 Running 0 2m47s kube-system kube-scheduler-minikube 1/1 Running 0 3m kube-system storage-provisioner 1/1 Running 1 (2m16s ago) 2m59s
Now, run the following command to get the URL of the Kubernetes dashboard:
minikube dashboard --url
You should see the following output:
???? 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 ... http://127.0.0.1:45627/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/
At this point, the Minikube dashboard is installed and running on localhost on port 45627. However, you can access it only from the local machine. If you want to access it from an external machine, run the following command.
kubectl proxy --address='0.0.0.0' --disable-filter=true
Now, open your web browser and type the URL http://your-server-ip:8001/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/. You will be redirected to the Kubernetes dashboard as shown in the following page:
Congratulations! you have successfully installed Minikube on Debian 11. You can now easily manage your Kubernetes cluster through your web browser. Feel free to ask me if you have any questions.