To deploy an application on a Kubernetes cluster, manage pods, scale deployments, expose services, and verify outputs using kubectl commands.
Commands: k3d cluster list kubectl get nodes
The Kubernetes cluster was already created and verified to be in Ready state.
kubectl create deployment web –image=nginx
kubectl get pods
The deployment automatically created pods which were observed in Running state.
kubectl scale deployment web –replicas=3
kubectl get pods
The deployment was successfully scaled to three replicas, demonstrating horizontal scaling capability.
kubectl expose deployment web –port=80 –type=NodePort
kubectl get svc
A NodePort service was created, enabling external communication to the application.
kubectl port-forward service/web 8080:80
The application was accessed through: http://localhost:8080
The NGINX welcome page was successfully displayed.
kubectl describe deployment web
kubectl get pods
kubectl logs
kubectl get all
These commands were used to inspect deployment configuration, logs, and cluster resources.
Deployment already exists: kubectl create deployment web –image=nginx Error: deployment already exists
Service already exists: kubectl expose deployment web –type=NodePort Fix: kubectl delete svc web
Incorrect command: kubectl nodes (invalid) kubectl get nodes (correct)
Incorrect scaling command: kubectl scale deployment web –image=nginx (invalid) kubectl scale deployment web –replicas=3 (correct)
The application was successfully deployed, scaled, and exposed using Kubernetes. The output was verified through browser access.
This practical demonstrated deployment creation, pod management, scaling, service exposure, and debugging in Kubernetes.