Step-by-Step on Ubuntu + Minikube
Step 1️⃣ — Start Minikube
$ minikube start –driver=docker
Step 2️⃣ — Create Deployment YAML
Save this as deployment.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: dotnet-deployment
spec:
replicas: 3
selector:
matchLabels:
app: dotnet-app
template:
metadata:
labels:
app: dotnet-app
spec:
containers:
– name: dotnet-container
image: mcr.microsoft.com/dotnet/samples:aspnetapp
ports:
– containerPort: 80
Step 3️⃣ — Apply the Deployment
$ kubectl apply -f deployment.yaml
Check it:
$ kubectl get deployments
$ kubectl get pods
You should see 3 running Pods automatically created by the Deployment (through a ReplicaSet).
🔁 Rolling Update Demonstration
Now suppose you want to update your .NET app version (for example, change the image).
Step 4️⃣ — Update the Deployment
Edit the YAML or use kubectl edit deployment dotnet-deployment.
Change:
image: mcr.microsoft.com/dotnet/samples:aspnetapp
to
image: mcr.microsoft.com/dotnet/samples:aspnetapp:7.0
Then apply the changes:
$ kubectl apply -f deployment.yaml
Kubernetes will create new Pods with the new version and gradually terminate old ones — this is the rolling update.
You can monitor this with:
$ kubectl rollout status deployment/dotnet-deployment
⏪ Rollback Demonstration
If something goes wrong after your update (say, Pods crash):
Step 5️⃣ — Rollback to previous version
$ kubectl rollout undo deployment/dotnet-deployment
Then check rollout status again:
$ kubectl rollout status deployment/dotnet-deployment
✅ This brings your app back to the previous working version.
📈 Scaling Your Deployment
To scale your app (increase or decrease replicas):
$ kubectl scale deployment dotnet-deployment –replicas=5
Now you’ll have 5 running Pods.
Check:
$ kubectl get pods
🌐 Exposing the Deployment (Optional but useful)
To access the app from your browser:
$ kubectl expose deployment dotnet-deployment –type=NodePort –port=80
$ minikube service dotnet-deployment
This command opens your .NET app in the browser.
Later, you can delete deployment by
$ kubectl delete deployment –all
$ kubectl delete svc –all
$ kubectl delete ingress –all
$ kubectl delete pods –all
