Validate regional Hyperdisk quota before Google Kubernetes Engine scale-out¶
Google Kubernetes Engine (GKE) custom ComputeClasses that use fourth-generation
(Gen 4) machine series, such as n4 and c4, provision Hyperdisk Balanced boot
disks and volumes, because these series support only Hyperdisk. The regional
Hyperdisk Balanced capacity quota varies by project and region. Observed
starting values range from 500 gigabytes (GB) to 80 tebibytes (TiB), or
81,920 GB, because quota GB use the binary unit of the disk sizeGb field, so
1 GB equals 1 gibibyte (GiB). When a scale-out exhausts this quota, node
provisioning times out and resembles a compute stockout.
This project provides an Agent Skill with a deterministic Python command-line interface (CLI) that sizes the worst-case Hyperdisk Balanced demand of a scale-out plan, compares it with live or offline quota, and prepares human-confirmed quota increase requests (QIRs). It also includes test scenarios and a Terraform testbed that runs no nodes.
Architecture¶
flowchart TB
subgraph Inputs ["Inputs"]
Plan["Scale-out plan, written by the operator or taken from a scenario"]
Manifests["ComputeClass, StorageClass, VolumeAttributesClass, StatefulSet, and PersistentVolumeClaim manifests"]
Quota["Live quota: regions describe, Cloud Quotas regional and zonal limits, and disks list usage, or an offline snapshot"]
end
subgraph Testbed ["Terraform testbed (terraform/)"]
Cluster["Zonal GKE Standard cluster without node pools"]
Scenarios["Scenario bundles and offline quota snapshot"]
end
subgraph Skill ["Agent Skill (.agents/skills/gke-hyperdisk-quota-preflight)"]
Discover["Step 1: read-only discovery"]
Run["Step 2: run hyperdisk_preflight.py"]
Present["Step 3: present the report and QIRs for approval"]
end
subgraph CLI ["Pre-flight CLI (hyperdisk_preflight.py)"]
Size["Worst-case demand sizing"]
Ceiling["Validator registry: check_regional_hyperdisk_80tib_ceiling"]
Writer["Report writer"]
end
subgraph Outputs ["Outputs"]
Reports["JSON and Markdown assessment reports"]
Script["Human-confirmed QIR script"]
Payload["Multi-project QIR CSV payload"]
Snapshot["quota_snapshot.json from live runs"]
end
Cluster --> Discover
Discover --> Manifests
Scenarios --> Plan
Plan --> Run
Manifests --> Run
Run --> Size
Quota -->|"--live or --quota-snapshot-json"| Size
Size --> Ceiling
Ceiling --> Writer
Writer --> Reports
Writer --> Script
Writer --> Payload
Writer --> Snapshot
Reports --> Present
Script --> Present
Components¶
- Agent Skill (
.agents/skills/gke-hyperdisk-quota-preflight/): Guides an artificial intelligence (AI) coding agent through read-only discovery, worst-case demand calculation, and an assessment report with QIRs that an operator approves and submits. - Pre-flight CLI (
scripts/hyperdisk_preflight.pyin the skill): Reads Kubernetes manifests and a JavaScript Object Notation (JSON) or YAML scale-out plan, reads quota withgcloudor from an offline snapshot, and runs the validators inscripts/preflight/validators/. The built-in validator compares the projected capacity, input/output operations per second (IOPS), and throughput with the regional limits, warns when the demand of a region exceeds a zonal limit in one zone, and generates QIRs. Its report writer saves the reports, the QIR script, the comma-separated values (CSV) payload, and, in--livemode,quota_snapshot.jsonfor offline replay. -
Scenarios (
terraform/scenarios/): YAML bundles with a scale-out plan and its manifests, plus an offline quota snapshot that models an 80 TiB (81,920 GB) limit with 4,096 GB in use inus-central1, 61,440 GB in use inus-east4, and no usage ineurope-west4:Scenario Plan Expected verdict pass-small-scaleout.yaml3 Gen 4 nodes and 3 Hyperdisk-backed replicas PASS fail-80tib-breach.yaml300 Gen 4 nodes and 20 replicas with 1 TiB volumes FAIL with a QIR for 101,376 GB fail-multi-project-breach.yamlGen 4 scale-outs in three projects and regions FAIL with QIRs for 92,160 GB in us-east4and 108,544 GB ineurope-west4 -
Terraform testbed (
terraform/): A zonal GKE Standard cluster without node pools that gives the skill a real cluster and live quota to evaluate. It needs Terraform 1.5 or later, thehashicorp/googleprovider~> 8.0, and thehashicorp/randomprovider~> 3.6, which.terraform.lock.hcllocks at 8.12.0 and 3.9.1.
The CLI calculates worst-case demand as
targetNodes x largest Hyperdisk boot disk + replicas x volume size, and adds
the current usage and a safety headroom that defaults to 20 percent. Hyperdisk
Balanced High Availability volumes count twice their size against the capacity
quota. Only the IOPS and throughput above the free per-volume baseline count
against the performance quotas, including the Compute Engine default
performance of boot disks and volumes that don't set IOPS or throughput. The CLI
validates project IDs, regions, Kubernetes names, plan names, contact emails,
and numeric ranges, and shell-quotes every value that it writes to the
generated QIR script.
The CLI keeps one manifest inventory for every cluster in a plan, so a ComputeClass, StorageClass, or workload name must have the same definition in every cluster that uses it. Each Cloud Quotas preference ID combines the quota and the region, so a later plan for the same project and region updates the pending request of an earlier plan. Combine scale-outs that share a project and region into one plan.
Requirements¶
Grant only the roles for the tasks that you perform. The read-only pre-flight never needs the testbed roles.
Read-only pre-flight on existing clusters¶
- An account with the following Identity and Access Management (IAM) roles on
every project in the plan:
- Compute Viewer (
roles/compute.viewer) - Kubernetes Engine Viewer (
roles/container.viewer) - Cloud Quotas Viewer (
roles/cloudquotas.viewer)
- Compute Viewer (
-
The Cloud Quotas API enabled on every project in the plan, so that the CLI can read the limits that
gcloud compute regions describeomits. An account with theserviceusage.services.enablepermission, such as Service Usage Admin, enables it once:
Quota increase request submission¶
- Cloud Quotas Admin (
roles/cloudquotas.admin), the narrowest predefined role with thecloudquotas.quotas.updatepermission, on every project in the plan. Only the person who submits the QIRs needs it.
Optional Terraform testbed in a sandbox project¶
- A Google Cloud project with billing enabled.
- An account with the following IAM roles on the project. The Terraform
configuration enables the Cloud Quotas API and the other APIs that it needs:
- Kubernetes Engine Admin (
roles/container.admin) - Compute Network Admin (
roles/compute.networkAdmin) - Compute Viewer (
roles/compute.viewer) - Service Account Admin (
roles/iam.serviceAccountAdmin) - Service Account User (
roles/iam.serviceAccountUser) - Project IAM Admin (
roles/resourcemanager.projectIamAdmin) - Service Usage Admin (
roles/serviceusage.serviceUsageAdmin), which also grants the Cloud Quotas permissions to read quota and submit QIRs
- Kubernetes Engine Admin (
- Terraform 1.5 or later.
- A GKE release channel that offers version 1.36.4-gke.1469000 or later in
your zone. The testbed uses the
REGULARchannel by default.
Tools¶
- The Google Cloud CLI (
gcloud) with thegcloud quotas preferencescommands. kubectland thegke-gcloud-auth-plugin.- Python 3.11 or later.
- An AI coding agent CLI that supports the Agent Skills specification, such as Gemini CLI or Antigravity CLI.
Prepare the environment¶
-
Set your project and location environment variables and configure the
gcloudCLI: -
Clone the repository and change the working directory:
-
Create a Python virtual environment and install the hash-locked dependencies of the pre-flight CLI:
Run the scenarios offline¶
The offline quota snapshot lets you evaluate the scenarios without Google Cloud credentials:
-
Run the scenario that fits within the 80 TiB ceiling:
.venv/bin/python "${PREFLIGHT_CLI}" \ --plan terraform/scenarios/pass-small-scaleout.yaml \ --quota-snapshot-json terraform/scenarios/offline-quota-snapshot.json \ --output-dir preflight-output/pass-small-scaleoutThe CLI exits with code
0and reports a projected usage of 4,456 GB. -
Run the scenario that breaches the 80 TiB ceiling:
.venv/bin/python "${PREFLIGHT_CLI}" \ --plan terraform/scenarios/fail-80tib-breach.yaml \ --quota-snapshot-json terraform/scenarios/offline-quota-snapshot.json \ --output-dir preflight-output/fail-80tib-breachThe CLI exits with code
1. The raw demand of 80,480 GB fits under the 81,920 GB limit, but the 4,096 GB in use and the 20 percent headroom project 100,672 GB, so the CLI requests 101,376 GB. -
Run the scenario that scales out across three projects and regions:
.venv/bin/python "${PREFLIGHT_CLI}" \ --plan terraform/scenarios/fail-multi-project-breach.yaml \ --quota-snapshot-json terraform/scenarios/offline-quota-snapshot.json \ --output-dir preflight-output/fail-multi-project-breachThe CLI exits with code
1.bulk_qir_payload.csvhas one row forus-east4and one foreurope-west4. Theus-central1project fits under the ceiling.
The CLI exit code tells automation how to proceed:
0: no validator failed. WARN findings, such asHDB-ZONAL-PERFORMANCE-QUOTA, can still exist.1: at least one validator failed, so the plan needs a QIR or a smaller scale-out.2: invalid input or failed discovery, such as a malformed plan, a ComputeClass or workload that the manifests don't define, an oversized file, or agclouderror such asPERMISSION_DENIED. Fix the input or the missing permission and rerun. The CLI writes no outputs, so any files in the output directory come from an earlier run. Never treat exit code2as a pass.
In a pipeline, block the scale-out on any nonzero exit code.
Each output directory contains the following artifacts:
preflight_report.jsonandpreflight_report.md: assessment reports with quota checks, provisioned totals, demand per plan entry, findings, and sizing assumptions. Offline runs report the zonal check as INFO, because snapshots carry no zonal limits.request_quota_increases.sh: script that lists every QIR and submits nothing until an operator typessubmit.bulk_qir_payload.csv: CSV payload with one row per QIR across all projects.
Deploy the testbed with Terraform¶
The testbed runs no nodes and creates no Hyperdisk volumes, so the GKE cluster management fee is its main cost. For free tier credits, see GKE pricing.
-
Initialize and apply the Terraform configuration:
terraform -chdir=terraform init terraform -chdir=terraform apply \ -var="project_id=${PROJECT_ID}" \ -var="region=${REGION}" \ -var="zone=${ZONE}"A cluster without node pools needs GKE 1.36.4-gke.1469000 or later. If the
REGULARrelease channel doesn't offer that version in your zone, the plan stops with a precondition error. Rerun the command with-var="release_channel=RAPID". -
Optionally, verify that
kubectlreaches the control plane. Theget_credentials_commandTerraform output prints the sameget-credentialscommand:
Testbed security¶
The testbed hardens the cluster without adding nodes:
- The control plane has no IP-based endpoints.
kubectlconnects through the Domain Name System (DNS)-based endpoint, which authorizes every request with IAM. - Kubernetes clients authenticate with IAM through
gke-gcloud-auth-plugin, so the cluster issues no static client certificate, and legacy attribute-based access control (ABAC) stays disabled. - Nodes that a ComputeClass creates are private Shielded GKE nodes without the kubelet read-only port, and reach only Google APIs through Private Google Access.
- Reference the
node_service_account_emailoutput in ComputeClassnodePoolConfig.serviceAccountfields. This service account has only the Kubernetes Engine Default Node Service Account role. - Workload Identity Federation for GKE lets workloads call Google Cloud APIs with their Kubernetes service accounts instead of the node service account.
- GKE Dataplane V2 enforces NetworkPolicy objects, and the subnet records Virtual Private Cloud (VPC) Flow Logs, which incur logging charges only after a ComputeClass creates nodes.
Terraform stores its state in a local terraform.tfstate file. Keep this file
out of version control.
Run the pre-flight against live quota¶
-
Evaluate a scenario against the live quota of your project. The CLI uses read-only
gcloudcommands and creates no disks:.venv/bin/python "${PREFLIGHT_CLI}" \ --plan terraform/scenarios/fail-80tib-breach.yaml \ --live \ --project-id "${PROJECT_ID}" \ --region "${REGION}" \ --output-dir preflight-output/live-fail-80tib-breachThe CLI reads the regional quota with
gcloud compute regions describe. For metrics that the output omits, it reads the limit from the Cloud Quotas API and the usage from the Hyperdisk Balanced disk inventory. It reads the zonal limits from the Cloud Quotas API. The zonal check assumes that all the IOPS and throughput demand of the region lands in its busiest zone. The CLI saves the regional quota toquota_snapshot.jsonfor offline replay. -
Start your agent CLI from the
projects/gke-hyperdisk-quota-preflightdirectory so it discovers the skill under.agents/skills/, and give your agent the following prompt. Get the cluster name withterraform -chdir=terraform output -raw cluster_name:Use the gke-hyperdisk-quota-preflight skill to validate the scale-out plan in terraform/scenarios/fail-80tib-breach.yaml against the live Hyperdisk quota of project <PROJECT_ID> in region <REGION>. Include the inventory of cluster <CLUSTER_NAME> in zone <ZONE> in the assessment. The cluster exposes only its DNS-based control plane endpoint.The agent discovers the quota and the cluster inventory with read-only commands, runs the pre-flight CLI, and presents the assessment report and the QIRs for your approval.
Submit quota increase requests¶
The QIR script never submits a request without confirmation:
-
Review the requests without submitting them:
-
After the quota owner approves the requests, run the script in an interactive terminal and type
submitwhen prompted. To override the contact email of the plan, set theQIR_CONTACT_EMAILenvironment variable. The contact email must belong to a Google account with thecloudquotas.quotas.updatepermission on every project in the plan, not an unprivileged mailing alias. Otherwise, Cloud Quotas denies any request that needs follow-up information (gcloud quotas preferences update):The script runs
gcloud quotas preferences update --allow-missingonce for each request with a deterministic preference ID, so the first run creates each preference and later runs update it to the newly calculated value. To have the Cloud Quotas API validate the requests without submitting them, run the script with--validate-only. -
For estates with many projects, share
bulk_qir_payload.csvwith your quota approver or account team.
Clean up the environment¶
To remove the testbed and avoid ongoing charges, destroy the Terraform configuration:
terraform -chdir=terraform destroy \
-var="project_id=${PROJECT_ID}" \
-var="region=${REGION}" \
-var="zone=${ZONE}"
Terraform leaves the enabled Google Cloud APIs in place, and quota preferences that you submitted remain on the project.