2022-05-30

Minikube

What is Minikube

Minikube is an open-source tool that allows developers to run a single-node Kubernetes cluster locally on their machine. Minikube provides a simplified way for developers to learn Kubernetes, develop and test applications, and experiment with new features in an isolated environment without the need for extensive hardware resources.

Minikube runs a single-node cluster inside a virtual machine (VM) on your personal computer. This VM contains all the necessary Kubernetes components such as the API server, the scheduler, etcd, and more. Additionally, Minikube supports various Kubernetes features like DNS, NodePorts, ConfigMaps, and Secrets.

One of the advantages of Minikube is its ease of use. With a few simple commands, you can set up and start a Kubernetes cluster, deploy applications, and manage resources. It also integrates seamlessly with common Kubernetes tools like kubectl for managing resources and Helm for deploying complex applications.

Another noteworthy feature is Minikube’s ability to emulate a production-like environment on your local machine. Through the use of add-ons and configurations, you can mimic production setups and constraints, which is particularly useful for testing and validating applications before they are deployed in real-world scenarios.

Installing Minikube

If you are using MacOS, you can install Minikube by running the following commands:

bash
$ brew install minikube
$ brew install kubectl

If you are using another OS, refer to the following official documentation for installation:

https://minikube.sigs.k8s.io/docs/start/

Basic Commands to Interact with Minikube

Once Minikube is installed, you can start interacting with it using various commands:

minikube start

Initialize a virtual machine and set up a single-node Kubernetes cluster inside it.

bash
$ minikube start

πŸ˜„  minikube v1.30.1 on Darwin 13.0 (arm64)
✨  Automatically selected the docker driver
πŸ“Œ  Using Docker Desktop driver with root privileges
πŸ‘  Starting control plane node minikube in cluster minikube
🚜  Pulling base image ...
πŸ’Ύ  Downloading Kubernetes v1.26.3 preload ...
    > preloaded-images-k8s-v18-v1...:  330.52 MiB / 330.52 MiB  100.00% 3.50 Mi
    > gcr.io/k8s-minikube/kicbase...:  336.39 MiB / 336.39 MiB  100.00% 2.23 Mi
πŸ”₯  Creating docker container (CPUs=2, Memory=2200MB) ...

🧯  Docker is nearly out of disk space, which may cause deployments to fail! (87% of capacity). You can pass '--force' to skip this check.
πŸ’‘  Suggestion:

    Try one or more of the following to free up space on the device:

    1. Run "docker system prune" to remove unused Docker data (optionally with "-a")
    2. Increase the storage allocated to Docker for Desktop by clicking on:
    Docker icon > Preferences > Resources > Disk Image Size
    3. Run "minikube ssh -- docker system prune" if using the Docker container runtime
🍿  Related issue: https://github.com/kubernetes/minikube/issues/9024

🐳  Preparing Kubernetes v1.26.3 on Docker 23.0.2 ...
    β–ͺ Generating certificates and keys ...
    β–ͺ Booting up control plane ...
    β–ͺ Configuring RBAC rules ...
πŸ”—  Configuring bridge CNI (Container Networking Interface) ...
    β–ͺ Using image gcr.io/k8s-minikube/storage-provisioner:v5
πŸ”Ž  Verifying Kubernetes components...
🌟  Enabled addons: storage-provisioner, default-storageclass
πŸ„  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

minikube status

Show the status of the minikube machine and its Kubernetes and kubeconfig statuses.

bash
$ minikube

minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured

minikube dashboard

This command opens up the Kubernetes dashboard in your default web browser, allowing you to interact with your cluster graphically.

bash
$ minikube dashboard

πŸ”Œ  Enabling dashboard ...
    β–ͺ Using image docker.io/kubernetesui/dashboard:v2.7.0
    β–ͺ Using image docker.io/kubernetesui/metrics-scraper:v1.0.8
πŸ’‘  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 ...

πŸŽ‰  Opening http://127.0.0.1:51471/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/ in your default browser...

Minikube dashboard

minikube addons list

List all the available add-ons that you can enable or disable in your cluster.

bash
$ minikube addons list

|-----------------------------|----------|--------------|--------------------------------|
|         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 | enabled βœ…   | 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             |
|                             |          |              | [info@inaccel.com])            |
| 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                     |
|-----------------------------|----------|--------------|--------------------------------|

kubectl cluster-info

Retrieve information about the cluster.

bash
$ kubectl cluster-info

Kubernetes control plane is running at https://127.0.0.1:49938
CoreDNS is running at https://127.0.0.1:49938/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

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

kubectl get componentstatus

Check the status of the cluster.

bash
$ kubectl get componentstatus

NAME                 STATUS    MESSAGE                         ERROR
controller-manager   Healthy   ok
etcd-0               Healthy   {"health":"true","reason":""}
scheduler            Healthy   ok

kubectl get nodes

Displays a list of cluster nodes.

bash
$ kubectl get nodes

NAME       STATUS   ROLES           AGE   VERSION
minikube   Ready    control-plane   13m   v1.26.3

minikube stop

This command stops the running Minikube VM but maintains its state to resume later.

bash
$ minikube stop

βœ‹  Stopping node "minikube"  ...
πŸ›‘  Powering off "minikube" via SSH ...
πŸ›‘  1 node stopped.

minikube delete

Completely delete the Minikube VM and all associated state.

bash
$ minikube delete

πŸ”₯  Deleting "minikube" in docker ...
πŸ”₯  Deleting container "minikube" ...
πŸ”₯  Removing /Users/ryuseikakujo/.minikube/machines/minikube ...
πŸ’€  Removed all traces of the "minikube" cluster.

References

https://minikube.sigs.k8s.io/docs/start/
https://kubernetes.io/docs/reference/kubectl/

Ryusei Kakujo

researchgatelinkedingithub

Focusing on data science for mobility

Bench Press 100kg!