Deploy a Simple Web Application on Kubernetes (minikube)

Step 1: Start Minikube

minikube start –driver=docker

This starts a single-node Kubernetes cluster running inside Docker.

  • The control plane and worker node run inside a Docker container.
  • Verify the cluster:

kubectl cluster-info

kubectl get nodes

  • See a single node with the role control-plane.

Step 2: Check Kubernetes Components

  • Control Plane Components:

kubectl get componentstatuses

Shows the health of:

  • etcd (key-value store)
  • scheduler
  • controller-manager
  • Node Info:

kubectl describe node <node-name>

Shows CPU, memory, Pods, and node conditions.

Step 3: Create a Namespace (Optional)

kubectl create namespace demo

kubectl config set-context – -current – -namespace=demo

(Namespaces isolate resources.)

Step 4: Deploy a Simple Web App (Nginx)

kubectl create deployment web-demo – -image=nginx

  • This creates a Deployment with a ReplicaSet.
  • Deployment manages Pods and ensures desired state.

Check Deployment:

kubectl get deployments

kubectl get pods

kubectl describe deployment web-demo

Step 5: Expose the Deployment as a Service

kubectl expose deployment web-demo –type=NodePort –port=80

  • This creates a Service to access the Pods.
  • NodePort exposes it on a port of the Minikube node.

Check Service:

kubectl get svc

kubectl describe svc web-demo

Step 6: Access the Application

minikube service web-demo

This opens the Nginx demo page in your default browser.

  • You can also check the NodePort and curl it:

curl $(minikube ip):<NodePort>

Step 7: Scale the Application

kubectl scale deployment web-demo –replicas=3

kubectl get pods -o wide

  • Shows 3 Pods running on the worker node, managed by the Deployment.

Step 8: View Logs

kubectl logs <pod-name>

  • Helps understand Pod behavior and debug issues.

Step 9: Delete the Application

kubectl delete service web-demo

kubectl delete deployment web-demo

kubectl get all

(Cleans up all resources.)

Step 10: Stop Minikube

minikube stop

  • Stops the cluster container but keeps data.
  • To remove completely:

minikube delete

Kubernetes Architecture Demonstrated

ComponentDemo Command / Action
Control Planekubectl cluster-info, kubectl get componentstatuses
Node (Worker)kubectl get nodes, kubectl describe node
Podkubectl get pods, kubectl describe pod
ReplicaSetManaged automatically by Deployment
Deploymentkubectl create deployment web-demo
Servicekubectl expose deployment web-demo –type=NodePort
Namespacekubectl create namespace demo
Scroll to Top