Deploying a Demo Pod on Kubernetes using Minikube

Kubernetes is a powerful container orchestration platform that simplifies deploying, scaling, and managing containerized applications.
In this blog, we will walk through deploying a simple pod on Kubernetes using Minikube.
Prerequisites
Before we get started, ensure you have the following installed on your system:
Minikube (Installation Guide - https://kubernetes-setup-localsystem.hashnode.dev/)
Kubectl (Installation Guide - https://kubernetes-setup-localsystem.hashnode.dev/)
Docker (optional but recommended for running containers locally)
Step 1: Start Minikube
Once Minikube is installed, start the Minikube cluster using the following command:
minikube start
This command initializes a local Kubernetes cluster. To verify that Minikube is running, execute:
minikube status
Step 2: Create a Sample Pod Manifest
A Pod in Kubernetes is the smallest deployable unit that encapsulates one or more containers. Let’s create a simple pod configuration file named nginx.yaml
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
This manifest defines a pod named nginx running an Nginx container.
Step 3: Deploy the Pod
To deploy the pod, use the kubectl apply
command:
kubectl apply -f nginx.yaml
Verify the pod is running with:
kubectl get pods
You should see an output similar to:
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 10s
Step 4: Access the Nginx Pod
Since this is a standalone pod, we need to expose it for external access. Use kubectl port-forward
to access the container locally:
kubectl port-forward pod/nginx 8080:80
Now, open your browser and go to http://localhost:8080
. You should see the Nginx welcome page.
Step 5: Cleanup
To delete the pod and free up resources, use:
kubectl delete pod nginx
To stop the Minikube cluster:
minikube stop
Conclusion
In this tutorial, we set up Minikube, deployed a sample Nginx pod, and accessed it using port forwarding. Minikube is an excellent tool for local Kubernetes development and testing before deploying to a production cluster.
Stay tuned for more Kubernetes tutorials!
Subscribe to my newsletter
Read articles from Shivani Vaikar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
