gcloud CLI. We’ll cover cluster creation with autoscaling, verifying configurations, and updating existing pools.
Overview
Autoscaling in GKE lets your cluster grow or shrink node capacity automatically based on workload. Configuring autoscaling properly helps you optimize cost and performance.Prerequisites
- A Google Cloud project with billing enabled
- Cloud SDK (gcloud) installed and authenticated
- IAM permissions:
Kubernetes Engine Admin,Compute Admin
| Resource | Purpose | Reference |
|---|---|---|
| gcloud CLI | Manage GKE clusters | https://cloud.google.com/sdk |
| GKE Autoscaling | Automatic scaling of node pools | https://cloud.google.com/kubernetes-engine/docs/concepts/cluster-autoscaler |
| IAM Roles | Permissions to create and modify resources | https://cloud.google.com/iam/docs/understanding-roles |
1. Set the Default Compute Zone
Configure a default zone so you don’t need to specify--zone every time:
You can override this with
--zone or set a default region:2. Create a Cluster with Autoscaling
Use the following command to creategke-deep-dive-auto with autoscaling enabled (1–2 nodes):
| Flag | Description |
|---|---|
--enable-autoscaling | Enables cluster autoscaling |
--num-nodes=1 | Initial node count |
--min-nodes=1, --max-nodes=2 | Defines the autoscaling range |
--disk-type=pd-standard | Boot disk type |
--disk-size=10 | Boot disk size in GB |
Cluster creation can take several minutes. Monitor progress in the Cloud Console or via:
3. Verify Cluster Autoscaling
Once ready, describe just the autoscaling block:4. Compare with a Cluster Without Autoscaling
If you omit--enable-autoscaling when creating a cluster, the autoscaling section is not present:
autoscaling: block will appear in the output.
5. Add a New Node Pool with Autoscaling
You can attach a new node pool to an existing cluster and enable autoscaling:6. Enable Autoscaling on an Existing Node Pool
To update an existing node pool (e.g.,default-pool) and enable autoscaling: