Welcome again to the Kubernetes Mastery Collection! On this fifth half, we’ll delve into superior deployment methods that may make it easier to handle your functions extra successfully and keep excessive availability.
Earlier than we start, guarantee you have got your Kubernetes cluster up and working. In case you’ve been following together with the sequence, your KinD cluster ought to already be arrange.
Rolling Updates and Blue-Inexperienced Deployments
1. Carry out a Rolling Replace
# Replace a Deployment with a brand new picture
kubectl set picture deployment/<deployment-name> <container-name>=<new-image>
2. Monitor the Rolling Replace Progress
# Monitor the rolling replace progress
kubectl rollout standing deployment/<deployment-name>
3. Rollback to a Earlier Model
# Rollback a deployment to a earlier revision
kubectl rollout undo deployment/<deployment-name>
4. Carry out a Blue-Inexperienced Deployment
# Create a brand new model (inexperienced) of your software
kubectl apply -f new-version.yaml
# Change visitors to the brand new model
kubectl apply -f blue-green-service.yaml
Canary Deployments
5. Carry out a Canary Deployment
# Deploy a brand new model of your software as a canary
kubectl apply -f canary-deployment.yaml
6. Progressively Enhance Canary Visitors
# Progressively enhance visitors to the canary deployment
kubectl apply -f canary-traffic-split.yaml
7. Monitor Canary Metrics
# Monitor metrics and consumer suggestions to resolve whether or not to advertise the canary
Horizontal Pod Autoscaling
8. Allow Horizontal Pod Autoscaling
# Allow autoscaling for a Deployment
kubectl autoscale deployment/<deployment-name> --min=<min-replicas> --max=<max-replicas> --cpu-percent=<cpu-percent>
9. View Autoscaler Standing
# View the standing of the Horizontal Pod Autoscaler
kubectl get hpa
Cleanup
10. Clear Up Sources
# Clear up sources created for superior deployments
kubectl delete deployment/<deployment-name>
kubectl delete svc/<service-name>
kubectl delete hpa/<hpa-name>
These superior deployment methods let you handle software updates, check new variations with minimal threat, and robotically alter useful resource allocation to fulfill demand.
Keep tuned for the following half in our Kubernetes Mastery Collection:
Half 6 – Managing Configurations with Helm