Prerequisites
- Google Cloud SDK with
gcloudandkubectlinstalled - A Google Cloud project with billing enabled
- Enable the Kubernetes Engine API
1. Configure and Create the Cluster
First, set your Compute Engine zone and create a single-node GKE cluster namedgke-deep-dive.
Cluster provisioning can take a few minutes. You can monitor progress in the Google Cloud Console under Kubernetes Engine > Clusters.
2. Deploy a Simple Nginx Application
Create a Deployment manifestgke-deep-dive-app.yaml with two replicas of Nginx:
| RESOURCE TYPE | COMMAND | DESCRIPTION |
|---|---|---|
| Deployment | kubectl apply -f gke-deep-dive-app.yaml | Create or update the deployment |
| Pods | kubectl get pods | List running pods and their status |
3. Perform Rolling Updates
GKE supports in-place rolling updates, ensuring that at least one replica remains available while others are replaced.| Action | Command | Description |
|---|---|---|
| Update image | kubectl set image deployment/nginx-deployment nginx=nginx:1.9.1 | Change the container image to 1.9.1 |
| Monitor rollout | kubectl rollout status deployment/nginx-deployment | Wait until the rollout completes |
3.1 Update to Nginx 1.9.1
3.2 Update to Nginx 1.21.0
Perform another image update to observe an in-progress rollout:4. Rollback a Deployment
If a rollout introduces an issue, you can revert to a previous revision.4.1 Rollback to the Previous Revision
4.2 Rollback to a Specific Revision
-
View rollout history:
-
Roll back to revision 1 (original version):
Rolling back to a previous revision may disrupt your application. Always test in a staging environment before rolling back in production.