Introduction to Managing Compute Resources and GKE Operations
Deploying a virtual machine or a Kubernetes cluster is only the beginning of the journey. The real work for an Associate Cloud Engineer lies in Managing Compute Resources and GKE Operations over their entire lifecycle. As your application grows and traffic patterns shift, you must be able to resize infrastructure, update software without downtime, and ensure that your data is backed up and recoverable.
Managing Compute Resources and GKE Operations focuses on the "Day 2" activities that keep a cloud environment healthy, performant, and cost-effective. This includes everything from simple VM machine-type adjustments to complex traffic-splitting strategies for serverless applications and automated node upgrades for GKE. Mastering these operational tasks is essential for anyone aiming to pass the ACE exam and manage production environments effectively.
白話文解釋(Plain English Explanation)
To help you understand the dynamic nature of Managing Compute Resources and GKE Operations, let's use these three analogies.
1. The Expanding Restaurant (Scaling and Resizing)
Imagine you own a popular bistro:
- Resizing a VM is like upgrading your oven to a larger model. You have to turn off the gas (Stop the VM), swap the appliance (Change machine type), and then start cooking again.
- Scaling GKE is like noticing the dining room is full and quickly opening up an annex next door with extra tables and waiters (Adding nodes to a pool).
- Traffic Splitting is like introducing a new menu item by letting 10% of your loyal customers try it first to see if they like it before offering it to everyone.
Managing Compute Resources and GKE Operations ensures that your "restaurant" can handle any number of customers while maintaining high-quality service.
2. The Fleet of Merchant Ships (Maintenance and Backups)
Think of your cloud resources as a fleet of ships at sea:
- Live Migration is like repairing a ship's engine while it's still sailing. The crew works so seamlessly that the passengers don't even notice the change.
- Snapshots and Images are like having detailed blueprints and daily photos of every ship. If a storm sinks one, you can use the blueprints and photos to build an identical replacement instantly.
In Managing Compute Resources and GKE Operations, these "blueprints" and "seamless repairs" are what provide the high availability that modern businesses demand.
3. Highway Maintenance (Rolling Updates)
Consider a busy highway that needs repaving:
- A Rolling Update is like closing one lane at a time for repairs while keeping the other lanes open for traffic.
- A Rollback is like realizing the new pavement is slippery and quickly reopening the old, safe lane while you figure out what went wrong.
Managing Compute Resources and GKE Operations involves coordinating these movements so that the "traffic" (your users) never has to stop moving.
Managing Compute Engine Lifecycle
The lifecycle of a VM involves more than just "Start" and "Stop."
Resizing VM Instances: Step-by-Step
If you find that your VM is running out of memory or CPU, you can "Rightsize" it. However, in Managing Compute Resources and GKE Operations, there is a hard rule: you must STOP the instance before changing its machine type.
Managing Snapshots and Snapshot Schedules
Snapshots are incremental backups of your Persistent Disks. For effective Managing Compute Resources and GKE Operations, you should use "Snapshot Schedules" to automate this process, ensuring you always have a point to recover from without manual effort.
Custom Images and Image Families for Maintenance
If you have a perfectly configured environment, turn it into a Custom Image. By grouping these images into an "Image Family," you can ensure that new VMs always use the latest version of your gold-standard configuration.
To change the machine type of a Compute Engine VM, the instance must be in a 'TERMINATED' (stopped) state. You cannot perform a vertical resize on a running VM. Source ↗
Scaling GKE Infrastructure
GKE offers multiple layers of scaling within the Managing Compute Resources and GKE Operations domain.
Horizontal Scaling: Adding Nodes to Node Pools
Horizontal scaling involves increasing the number of nodes in your node pool. This is the most common way to handle increased traffic in a Kubernetes environment.
Vertical Scaling: Upgrading Node Machine Types
Since you cannot change a node's machine type while it is part of a cluster, the standard procedure for Managing Compute Resources and GKE Operations is to create a NEW node pool with the desired machine type, migrate the workloads, and then delete the old pool.
Resizing Node Pools via CLI
You can quickly adjust the capacity of your cluster using the gcloud container clusters resize command.
Managing GKE Workload Operations
Rolling Updates and Rollbacks
When you update a Deployment in GKE, Kubernetes performs a "Rolling Update" by default. It replaces old Pods with new ones one by one. If the new version is buggy, you can use kubectl rollout undo to instantly return to the previous state.
Handling CrashLoopBackOff and Pending Pods
These are the most common operational issues in GKE. "Pending" usually means you've run out of node capacity, while "CrashLoopBackOff" indicates a problem within your container's code or configuration.
Node Taints, Tolerations, and Affinity
These advanced features of Managing Compute Resources and GKE Operations allow you to control exactly which Pods run on which nodes, ensuring that sensitive or high-resource workloads are placed correctly.
A Rolling Update is a deployment strategy that replaces old instances of an application with new ones without downtime by updating them one by one. Source ↗
Serverless Operations: Traffic Splitting and Revisions
Serverless platforms like Cloud Run and App Engine excel at traffic management.
Blue-Green and Canary Deployments
- Blue-Green: You have two identical environments. You switch 100% of traffic from the old (Blue) to the new (Green) once it's verified.
- Canary: You route a small percentage (e.g., 5%) of traffic to the new version to test it with real users before a full rollout.
Managing Cloud Run Revisions and Tags
Every deployment in Cloud Run creates an immutable Revision. You can assign a "Tag" to a specific revision to give it a unique URL for internal testing within the Managing Compute Resources and GKE Operations workflow.
Traffic Splitting Strategies
You can split traffic based on:
- Random: A flat percentage.
- Cookie: Ensures a single user stays on the same version (Sticky Sessions).
- IP Address: Similar to cookie-based, but for non-browser clients.
Resource Maintenance and Reliability
Live Migration: The Magic of No-Downtime Maintenance
Google Cloud can move your running VM to a different host if the current host needs physical maintenance. This is a core part of the "Managed" experience in Managing Compute Resources and GKE Operations.
Availability Policies for Maintenance Events
You can configure whether a VM should be "Live Migrated" or "Terminated" during a maintenance event.
GKE Node Auto-Upgrades and Surge Upgrades
GKE can automatically keep your nodes updated with the latest Kubernetes security patches. "Surge Upgrades" allow GKE to create extra nodes during the upgrade process so your cluster doesn't lose capacity.
Always enable Node Auto-Upgrade and Node Auto-Repair in GKE to reduce the operational burden of cluster maintenance. Source ↗
Backup and Disaster Recovery Strategies
Regional vs. Multi-Regional Snapshots
By default, snapshots are stored in the same region as the disk. For better Managing Compute Resources and GKE Operations, consider multi-regional snapshots to protect against a full regional failure.
Recreating Resources from Images and Templates
Use your Instance Templates to quickly recreate an entire web tier in a new region if the primary region goes offline.
Optimizing Compute Performance and Cost
Rightsizing Recommendations
The Google Cloud Recommender analyzes your Managing Compute Resources and GKE Operations and tells you if a VM is over-provisioned (wasting money) or under-provisioned (losing performance).
Using Spot VMs for Non-Critical Workloads
Integrate Spot VMs into your GKE node pools or MIGs for batch processing to save up to 91% on your compute bill.
Managing Operations via gcloud and kubectl
gcloud compute instances add-tags my-vm --tags http-server: Updates firewall targets.gcloud container clusters resize my-cluster --num-nodes=10: Expands cluster capacity.kubectl rollout status deployment/my-app: Monitors the progress of an update.
Use 'kubectl rollout undo deployment/[NAME]' to quickly revert a GKE deployment to its previous healthy state. This is a vital command for Managing Compute Resources and GKE Operations. Source ↗
Security Operations for Compute
Updating OS Patches via Patch Management
Use VM Manager's "Patch Management" to automate the application of security updates across hundreds of VMs in your Managing Compute Resources and GKE Operations environment.
Auditing Compute Activity with Cloud Audit Logs
Regularly review "Admin Activity" and "Data Access" logs to see who modified a VM's configuration or accessed sensitive storage buckets.
Troubleshooting Common Operational Failures
VM Boot Failures and Serial Console Logs
If a VM won't start after a configuration change, use the Serial Console to see the Linux boot process or the Windows SAC logs.
GKE Node Not Ready States
Often caused by the node being "OOM" (Out of Memory) or having a full disk. Managing Compute Resources and GKE Operations involves monitoring these health signals constantly.
Common Exam Scenarios for ACE
Rolling Back a GKE Deployment
"You deployed v2 of your app, and users are reporting errors. What is the fastest way to restore service?" (Answer: kubectl rollout undo).
Resizing a Database VM
"Your Cloud SQL instance is hitting 100% CPU. How do you give it more power?" (Answer: Modify the instance's machine type in the console or via CLI, noting that it will restart).
Managing Traffic during a Seasonal Spike
"You expect a 10x traffic increase for Black Friday. How should you prepare your GKE cluster?" (Answer: Manually resize the node pool ahead of time or ensure Cluster Autoscaler is correctly configured with a high maximum).
FAQ
Q1: Can I resize a Persistent Disk while the VM is running? A1: Yes! You can increase the size of a Persistent Disk without any downtime. However, you must then tell the OS (Linux/Windows) to expand the filesystem to use the new space.
Persistent Disks can be grown online while the VM is running, but the disk can only be increased in size — never shrunk. After enlarging the PD, you must run an OS-level command (e.g., resize2fs on Linux ext4 or Disk Management on Windows) to extend the filesystem into the new space, otherwise the extra capacity is invisible to your workload.
Source ↗
Live Migration sounds universal, but VMs with attached GPUs or Local SSDs are excluded — during host maintenance they are TERMINATED and restarted, not seamlessly moved. Picking "Migrate" as the maintenance policy for a GPU training VM in an ACE scenario is a trap; the correct answer is to design for graceful restart (snapshots, Instance Templates, or MIG self-healing) instead. Source ↗
Q2: Does Live Migration work for VMs with GPUs? A2: No. Currently, VMs with attached GPUs or Local SSDs cannot be live-migrated and will be terminated and restarted during host maintenance.
Q3: What is the difference between a Snapshot and a Custom Image? A3: A Snapshot is a quick, incremental backup of a disk's state. A Custom Image is a "gold master" designed to be shared and used to create many new VMs.
Q4: Can I move a GKE cluster to a different region? A4: No. Clusters are regional or zonal and cannot be moved. You must create a new cluster and redeploy your workloads.
Q5: How many revisions does Cloud Run keep? A5: Cloud Run keeps up to 1000 revisions per service, though only those with traffic assigned are active.
Summary Checklist for ACE
- Know that you must STOP a VM to change its machine type.
- Understand how to perform and undo rollouts with
kubectl. - Be able to explain traffic splitting for canary and blue-green releases.
- Know how to use snapshot schedules for automated backups.
- Understand the role of the Recommender in rightsizing.
- Recognize that Live Migration is a default feature of GCE.