Skip to main content

Command Palette

Search for a command to run...

Minikube and Kubectl

Updated
2 min read
A

"I don’t fix bugs; I just deploy them faster" I am a DevOps engineer and cloud enthusiast who thrives on automating everything that can (and sometimes shouldn’t) be automated. From Docker containers to Kubernetes clusters, I enjoy making deployments smooth—until they aren’t, and then I learn something new the hard way. I love shipping code quickly—even if that means shipping the bugs along with it."

What is Minikube?

It is a tool that allows to run a single node Kubernetes cluster locally on your machine.

How to use it from your machine?

As I had windows machine, I installed WSL with Ubuntu-22.04.01 distro and installed minikube there.

# in your cmd; type
wsl --list --online

# install the prefered distro, in my case i have installed Ubuntu 22.04
wsl --install -d Ubuntu-22.04

# then can go inside wsl by simply by command "wsl" from CMD or, 
# can install the installed distro from Microsoft store.

Now I have Linux setup in my windows machine; Now can move towards installing minikube,

First, I need to install Docker in my WSL distro because I plan to use it with Minikube for running K8s.

sudo apt update
sudo apt install -y docker.io
sudo systemctl enable --now docker
sudo usermod -aG docker $USER # adding that user to docker group allows it to run docker command without sudo.

Installation of minikube.

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

Start minikube.

minikube start --driver=docker --memory=2048 --cpus=2
# can even be started without mentioning resources.

Stop minikube.

minikube stop

Enable dynamic storage provision in minikube.

minikube addons enable storage-provisioner

It allows minikube to automatically create PVs (like database) when it is requested in pods. Enabling this addon means you don’t have to manually create volumes — Minikube will handle it dynamically.

Kubectl

It is a command line tool to communicate with Kubernetes cluster.

Installation

curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/

It has a kubeconfig file according to which it behaves (~/.kube/config)

kubectl config view   # see current config
kubectl config current-context  # see which cluster you are connected to

Some more commands.

TaskCommand
See all Podskubectl get pods
See all Deploymentskubectl get deployments
See all Serviceskubectl get svc
Create resource from YAMLkubectl apply -f file.yaml
Delete resourcekubectl delete -f file.yaml
Describe resourcekubectl describe pod pod-name
View logs of a Podkubectl logs pod-name

Minikube made me easy to run a single-node Kubernetes cluster locally, allowing me to experiment and learn Kubernetes without needing a full cloud setup. By combining Minikube with Docker in a WSL Ubuntu environment, I could simulate a real Kubernetes cluster on Windows machine.