Installing and using minikube

Command Summary`

CommandDescription
minikube startStart minikube
minikube dashboardStart the Kubernetes Dashboard
minikube addons enable metrics-serverEnable Metrics Services (Required for some dashboard features)
minikube stopStop minikube
minikube deleteDelete minikube - when error occur restarting
minikube tunnelConnect to LoadBalancer services
kubectl get deploymentsGet the kubernetes deployments
kubectl get podsGet the kubernetes pods
kubectl get eventsView the cluster events
kubectl logs hello-node-55fdcd95bf-sqxd7View the logs from a Service
kubectl expose deployment hello-node –type=LoadBalancer –port=8080Expose the service outside the Virtual Network
kubectl create deployment hello-node –image=registry.k8s.io/e2e-test-images/agnhost:2.39 – /agnhost netexec –http-port=8080Create the e2e-test-image
kubectl get servicesGet the running services
minikube service hello-nodeConnect to the URL of a Service

What is minikube?

Minikube is a tool that allows you to run a local Kubernetes cluster on your machine. It’s commonly used for development and testing purposes, providing a way to explore and develop applications for Kubernetes without needing a full-scale cloud or production environment. This a cost of effective solution for local proof of concepts and development.

Getting Started with Minikube

First thing first lets getting the minikube cli tool install, in a previous guide I talke about how we can install asdf for managing binaries and program language versions. If you want to get started with asdf please see the following link: Installing and using asdf

After a little bit of reaserch I found out that there is a asdf plugin for minikube which I’m going to leverage for this guide. In the past I would have used homebrew but I’m trying out asdf more as it seem to be a little more flexible than homebrew for my needs.

Commands - Install the minikube plugin

Firstly we will search for the minikube plugin in asdf

❯ asdf plugin list all | grep minikube
minikube                     *https://github.com/alvarobp/asdf-minikube.git

Next add the minikube plugin for asdf and check its installed locally

❯ asdf plugin add minikube
❯ asdf plugin list
golang
kubectl
minikube

Now that the plugin is installed let’s check what versions are available to us

❯ asdf list all minikube
1.21.0-beta.0
1.21.0
... output truncated for breivity
1.33.0
1.33.1

In this case, I’ll in the latest version of minikube

❯ asdf install minikube 1.33.1
####################################################################### 100.0%

Let’s setting the binary to use globally

❯ asdf global minikube 1.33.1

Let’s ensure that minikube binary that we’ve installed is working correctly

❯ minikube version
minikube version: v1.33.1
commit: 5883c09216182566a63dff4c326a6fc9ed2982ff

Commands - Start the minikube server

Now that the minikube binary is installed we start the minkube cluster, note minikube requires that docker is installed as this is a fundamental requirement

❯ minikube start
😄  minikube v1.33.1 on Darwin 14.6.1
✨  Automatically selected the docker driver
📌  Using Docker Desktop driver with root privileges
👍  Starting "minikube" primary control-plane node in "minikube" cluster
🚜  Pulling base image v0.0.44 ...
💾  Downloading Kubernetes v1.30.0 preload ...
    > preloaded-images-k8s-v18-v1...:  342.90 MiB / 342.90 MiB  100.00% 9.54 Mi
    > gcr.io/k8s-minikube/kicbase...:  481.58 MiB / 481.58 MiB  100.00% 11.21 M
🔥  Creating docker container (CPUs=2, Memory=7790MB) ...
🐳  Preparing Kubernetes v1.30.0 on Docker 26.1.1 ...
    ▪ Generating certificates and keys ...
    ▪ Booting up control plane ...
    ▪ Configuring RBAC rules ...
🔗  Configuring bridge CNI (Container Networking Interface) ...
🔎  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
❯ 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
💡  After the addon is enabled, please run "minikube tunnel" and your ingress resources would be available at "127.0.0.1"
    ▪ Using image registry.k8s.io/ingress-nginx/controller:v1.10.1
    ▪ Using image registry.k8s.io/ingress-nginx/kube-webhook-certgen:v1.4.1
    ▪ Using image registry.k8s.io/ingress-nginx/kube-webhook-certgen:v1.4.1
🔎  Verifying ingress addon...
🌟  The 'ingress' addon is enabled

At this point it looks like minikube is up and running but let’s deploy a simple hello world service or in

Create a demo service

Lets create a demo service to test with

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    env: sandbox
spec:
  replicas: 1
  selector:
    matchLabels:
      env: sandbox
  template:
    metadata:
      labels:
        env: sandbox
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80
❯ kubectl get ns
NAME              STATUS   AGE
default           Active   4h59m
kube-node-lease   Active   4h59m
kube-public       Active   4h59m
kube-system       Active   4h59m
❯ kubectl get pods
NAME                                READY   STATUS    RESTARTS   AGE
nginx-deployment-7f76d8fdfb-jb596   1/1     Running   0          4h36m
nginx-deployment-7f76d8fdfb-kt6r5   1/1     Running   0          4h36m
nginx-deployment-7f76d8fdfb-vs6qc   1/1     Running   0          4h36m