This repository demonstrates a complete hands-on implementation of core Kubernetes concepts including deployment, scaling, load balancing, and observability using Minikube.
- Understand Kubernetes architecture and components
- Deploy containerized applications using Pods and Deployments
- Implement auto-healing and scaling
- Perform rolling updates and rollback
- Expose applications using Services
- Demonstrate load balancing across multiple pods
- Monitor traffic distribution using K9s
- Kubernetes
- Minikube
- Docker
- kubectl
- K9s
- YAML
kubernetes-practice/
│
├── pod/
│ └── nginx-pod.yaml
│
├── deployment/
│ └── nginx-deployment.yaml
│
├── service-nodeport/
│ └── nginx-service.yaml
│
├── load-balancing/
│ ├── nginx-lb-test.yaml
│ └── nginx-lb-test-service.yaml
│
├── observability/
│ └── notes.md
│
└── README.md
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
spec:
containers:
- name: nginx-container
image: nginx
ports:
- containerPort: 80kubectl apply -f nginx-pod.yaml
kubectl get podskubectl port-forward pod/nginx-pod 8080:80
curl localhost:8080apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx-container
image: nginx
ports:
- containerPort: 80kubectl apply -f nginx-deployment.yaml
kubectl get deployments
kubectl get podskubectl delete pod <pod-name>Kubernetes automatically recreates the deleted pod.
kubectl scale deployment nginx-deployment --replicas=5
kubectl get podskubectl set image deployment/nginx-deployment nginx-container=nginx:1.25kubectl get pods -wkubectl rollout undo deployment nginx-deploymentapiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
type: NodePort
selector:
app: nginx
ports:
- port: 80
targetPort: 80
nodePort: 30007kubectl apply -f nginx-service.yaml
kubectl get services
minikube ipcurl <minikube-ip>:30007apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-lb-test
spec:
replicas: 3
selector:
matchLabels:
app: nginx-lb-test
template:
metadata:
labels:
app: nginx-lb-test
spec:
containers:
- name: nginx
image: nginx
command: ["/bin/sh", "-c"]
args:
- echo "Hello from $(hostname)" > /usr/share/nginx/html/index.html && nginx -g 'daemon off;'
ports:
- containerPort: 80apiVersion: v1
kind: Service
metadata:
name: nginx-lb-test-service
spec:
type: NodePort
selector:
app: nginx-lb-test
ports:
- port: 80
targetPort: 80
nodePort: 30008for i in {1..10}; do curl <minikube-ip>:30008; doneHello from nginx-lb-test-abc123
Hello from nginx-lb-test-def456
Hello from nginx-lb-test-xyz789
This confirms traffic is distributed across multiple pods.
k9s- Select Pod
- Press
l
for i in {1..20}; do curl <minikube-ip>:30008; doneLogs will show requests hitting different pods.
- Kubernetes ensures high availability using ReplicaSets
- Deployments provide auto-healing and scaling
- Rolling updates ensure zero downtime
- Services provide internal load balancing
- NodePort exposes applications externally
- Observability tools help in debugging and monitoring
| Issue | Fix |
|---|---|
| Pod not accessible | Use port-forward |
| Connection refused | Restart Minikube |
| Wrong logs | Check correct pod labels |
| Download issues | Use browser instead of curl |
| File not found | Verify filename before extraction |
- Implement Ingress Controller
- Use ConfigMaps and Secrets
- Deploy on AWS EKS / GCP GKE
- Implement CI/CD pipeline
Bhoopendra Singh Bhadauria