Getting started with Kubernetes (Part- 2 ): Hands-on with Minikube

Humayun Rashid
2 min readJan 15, 2021

This is the part 2 of my previous post. You can find part one here.

Basic controls

See minikube in action!

Start a cluster by running:

minikube start

Access the Kubernetes Dashboard running within the minikube cluster:

minikube dashboard

Once started, you can interact with your cluster using kubectl, just like any other Kubernetes cluster. For instance, starting a server:

kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.4

Exposing a service as a NodePort

kubectl expose deployment hello-minikube --type=NodePort --port=8080

minikube makes it easy to open this exposed endpoint in your browser:

minikube service hello-minikube

Upgrade your cluster:

minikube start --kubernetes-version=latest

Start a second local cluster (note: This will not work if minikube is using the bare-metal/none driver):

minikube start -p cluster2

Stop your local cluster:

minikube stop

Delete your local cluster:

minikube delete

Delete all local clusters and profiles

minikube delete --all

Deploy a Hello-World App with Minikube

From a terminal with administrator access (but not logged in as root), run:

minikube start

The output will be something like this:

$ minikube start
╰─ minikube start
😄 minikube v1.4.0 on Darwin 10.14.6
💡 Tip: Use 'minikube start -p <name>' to create a new cluster, or 'minikube delete' to delete this one.
🔄 Starting existing virtualbox VM for "minikube" ...
⌛ Waiting for the host to be provisioned ...
🐳 Preparing Kubernetes v1.16.0 on Docker 18.09.9 ...
🔄 Relaunching Kubernetes using kubeadm ...
⌛ Waiting for: apiserver proxy etcd scheduler controller dns
🏄 Done! kubectl is now configured to use "minikube"

RUn following command to deploy a hello-minikube image:

kubectl create deployment hello-node --image=gcr.io/hello-minikube-zero-install/hello-node

View the Deployment:

kubectl get deployments
  1. Output:
NAME         READY   UP-TO-DATE   AVAILABLE   AGE
hello-node 1/1 1 1 1m

Get the pods using the following command:

kubectl get pods

Output:

NAME                          READY     STATUS    RESTARTS   AGE
hello-node-5f76cf6ccf-br9b5 1/1 Running 0 1m

Expose the Pod to the public internet using the kubectl expose command:

kubectl expose deployment hello-node --type=LoadBalancer --port=8080

View the Service you just created:

kubectl get services

Output:

NAME         TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
hello-node LoadBalancer 10.108.144.78 <pending> 8080:30369/TCP 21s
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 23m

--

--