Container Orchestration with Kubernetes
- Sharon Rajendra Manmothe
- 10 hours ago
- 2 min read
🛠️ Step 1: Enable Kubernetes in Docker Desktop
Open Docker Desktop.
Go to Settings → Kubernetes.
Check “Enable Kubernetes”.
Click Apply & Restart.
Wait until Docker Desktop shows Kubernetes as running (green).
Test:
kubectl cluster-info
kubectl get nodes
You should see one node named docker-desktop.
Step 2: Build and Push Your Docker Image
Since Kubernetes needs the image, push it to Docker Hub:
# Build image (replace my-flask-app with your app name)
docker build -t my-flask-app:v1 .
# Tag with Docker Hub username
docker tag my-flask-app:v1 your-dockerhub-username/my-flask-app:v1
# Login and push
docker login
docker push your-dockerhub-username/my-flask-app:v1
Step 3: Create Deployment YAML
Create folder k8s-manifests/ → inside it create web-deployment.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-app-deployment
labels:
app: web-app
spec:
replicas: 2
selector:
matchLabels:
app: web-app
template:
metadata:
labels:
app: web-app
spec:
containers:
- name: web-app-container
image: your-dockerhub-username/my-flask-app:v1 # replace with your image
ports:
- containerPort: 5000 # replace with your app’s port
Step 4: Create Service YAML
So you can access your app from browser.Create web-service.yaml in same folder:
apiVersion: v1
kind: Service
metadata:
name: web-app-service
spec:
selector:
app: web-app
ports:
- protocol: TCP
port: 80
targetPort: 5000 # must match containerPort
type: LoadBalancer
Step 5: Apply Deployment & Service
Run:
kubectl apply -f k8s-manifests/web-deployment.yaml
kubectl apply -f k8s-manifests/web-service.yaml
Check:
kubectl get pods
kubectl get svc
You should see:
2 pods running from your deployment.
Service of type LoadBalancer with a cluster IP.
Step 6: Access the App
Since Docker Desktop doesn’t provide a real cloud load balancer, it maps the service to localhost.Check with:
kubectl port-forward svc/web-app-service 8080:80
Now open → http://localhost:8080 🎉
Step 7: Clean Up
kubectl delete -f k8s-manifests/web-deployment.yaml
kubectl delete -f k8s-manifests/web-service.yaml
Comments