Google Cloud Greedy Reservation Creator
Acquires Google Compute Engine VM capacity in constrained zones by greedily reserving instances one node at a time until a target node count is reached. This is especially useful for high-demand machine types (e.g., GPUs, specialized compute) where bulk reservation creation requests might fail due to stockouts (ZONE_RESOURCE_POOL_EXHAUSTED).
- Interactive Startup: Prompts for required parameters while automatically detecting default project and zone values from your active
gcloudconfiguration or existing environment variables. - Resource Naming Validation: Validates reservation names against Google Cloud resource naming rules prior to executing API calls.
- Local & Shared Reservation Support: Supports both single-project (
local) and multi-project (shared) reservations. - Greedy Acquisition Loop: Creates the reservation with 1 VM initially and continuously retries scaling up by 1 node at a time until the target node count is met.
Run interactively:
./greedy-reservations.shOr pre-populate defaults via environment variables:
PROJECT="my-project-id" \
ZONE="us-central1-b" \
MACHINE_TYPE="g4-standard-48" \
./greedy-reservations.shGoogle Cloud Greedy On-Demand VM Creator
Acquires standard on-demand Google Compute Engine VM instances in capacity-constrained zones by retrying instance creation one VM at a time until the target instance count is achieved.
- Instance Naming & Prefix Indexing: Prompts for a VM name prefix (
INSTANCE_PREFIX) and creates indexed instances (${PREFIX}-1,${PREFIX}-2, etc.). Automatically checks if an indexed instance already exists before attempting creation. - Dynamic Maintenance Policy Auto-Detection: Inspects the selected machine type prefix. Automatically applies
--maintenance-policy=TERMINATEfor GPU instance families (g2-,g4-,a2-,a3-) while defaulting to live migration (MIGRATE) for standard CPU instances. - OS Image & Boot Disk Customization: Prompts for Boot Image Family, Image Project, Boot Disk Size, and Disk Type (defaulting to Debian 12 / 50GB balanced disk).
- Network / Subnet Configuration: Optional subnet specification or fallback to the project's default VPC network.
- Transparent Error Reporting: Outputs exact
gclouderror messages directly to console before retrying, distinguishing fatal configuration or quota errors from capacity stockouts (ZONE_RESOURCE_POOL_EXHAUSTED).
Run interactively:
./greedy-ondemand.shOr pre-populate defaults via environment variables:
PROJECT="my-project-id" \
ZONE="us-central1-b" \
MACHINE_TYPE="g4-standard-48" \
TARGET_COUNT="2" \
./greedy-ondemand.sh