惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Full Disclosure
V
Vulnerabilities – Threatpost
Attack and Defense Labs
Attack and Defense Labs
N
News and Events Feed by Topic
SecWiki News
SecWiki News
S
Security @ Cisco Blogs
Schneier on Security
Schneier on Security
B
Blog
TaoSecurity Blog
TaoSecurity Blog
The Last Watchdog
The Last Watchdog
H
Hacker News: Front Page
Hacker News - Newest:
Hacker News - Newest: "LLM"
博客园_首页
D
Docker
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Y
Y Combinator Blog
W
WeLiveSecurity
N
News and Events Feed by Topic
F
Fortinet All Blogs
PCI Perspectives
PCI Perspectives
WordPress大学
WordPress大学
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Recent Announcements
Recent Announcements
Forbes - Security
Forbes - Security
T
Tailwind CSS Blog
Hacker News: Ask HN
Hacker News: Ask HN
爱范儿
爱范儿
腾讯CDC
Last Week in AI
Last Week in AI
月光博客
月光博客
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed
Help Net Security
Help Net Security
V
V2EX
C
Cyber Attacks, Cyber Crime and Cyber Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
H
Heimdal Security Blog
L
LINUX DO - 最新话题
GbyAI
GbyAI
The Hacker News
The Hacker News
罗磊的独立博客
S
SegmentFault 最新的问题
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 【当耐特】
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
V2EX - 技术
V2EX - 技术
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
O
OpenAI News
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Surviving N4 stockouts in GKE
Vincent · 2026-06-13 · via DEV Community

The problem I ran into

I was bringing up the startup infrastructure for a solution standardized on the N4 machine series. N4 is a great general-purpose default for us, so the design assumed N4 capacity would be there when we asked for it.

It wasn't. In several of our target regions I simply could not get N4 nodes when I needed them. New nodes wouldn't come up during scale-up events, and worse, I couldn't even create the initial infrastructure in some zones. The cluster autoscaler kept logging the now-familiar Compute Engine signal:

ZONE_RESOURCE_POOL_EXHAUSTED
The zone 'projects/PROJECT_ID/zones/ZONE' does not have enough resources
available to fulfill the request. Try a different zone, or try again later.

This is not a quota problem and not a config problem. It's a capacity problem: GCP didn't have the N4 hardware free in that zone at that moment. A few things made this clear to me as I dug in.

Google's own resource-availability troubleshooting page is explicit that these errors happen when you request resources in a zone that can't currently accommodate them, that they're unrelated to your quota, and that they only apply to new resource requests — existing VMs keep running fine. Their recommended mitigations are to retry in another zone, retry in another region, retry later, or change the hardware configuration you're asking for. (Troubleshooting resource availability errors)

The GKE ComputeClass troubleshooting docs say the same thing from the cluster's point of view: when GKE can't provision nodes for a priority rule — for example because of ZONE_RESOURCE_POOL_EXHAUSTED or QUOTA_EXCEEDED from Compute Engine — the autoscaler immediately moves on to the next rule, with no waiting period (the exception being TPUs and Flex Start). (Troubleshoot custom ComputeClass issues)

And I'm clearly not alone. The lack of capacity for specific machine families in specific zones is a long-running, well-documented reality on GCP. You can find it discussed in places like the GCE discussion group thread on resources not being available to fulfill the request, the ZONE_RESOURCE_POOL_EXHAUSTED thread, and the Google developer-forum report of not being able to provision anything on GKE across multiple European zones. Even Google's custom compute class launch blog quotes Delivery Hero saying the thing I wanted to be able to say: that with fallback rules they stopped having to worry about instance availability at all.

So I stopped trying to force N4 and instead made my infrastructure resilient to N4 being temporarily unavailable.

The fix: a dedicated cluster with a cluster-wide default ComputeClass

My solution doesn't bolt a ComputeClass onto an existing shared cluster, and it deliberately does not attach the class to individual workloads with per-Pod selectors. Instead, I provision a specific, dedicated GKE cluster for the whole solution, and I make a single custom ComputeClass the cluster-level default. Every Pod that lands on that cluster inherits the N4→C4 behavior automatically, whether or not it asks for it. The workload manifests stay completely clean — no nodeSelector, no per-namespace labels, nothing for app teams to remember.

A ComputeClass is a Kubernetes Custom Resource (CRD, apiVersion: cloud.google.com/v1, kind: ComputeClass) that lets me declare an ordered list of node configurations — "priorities" — that GKE walks through when it needs to scale up. (About custom ComputeClasses)

Two features make this work:

  1. Fallback compute priorities. I list N4 first and C4 second. If GKE can't get N4, it doesn't leave my Pods Pending — it falls straight through to C4. C4 is the natural sibling to reach for: it's a current-generation Intel general-purpose series with a comparable shape to N4, so my workloads behave consistently on it.

  2. Active migration back to the preferred option. With activeMigration.optimizeRulePriority: true, once N4 capacity reappears in my location (capacity frees up, or my quota goes up), GKE creates a new N4 node, then cordons and drains the C4 node it had been using as a fallback. The fleet self-heals back to N4 without me touching anything. This N4→C4 example is, in fact, the exact scenario Google documents for active migration. (About custom ComputeClasses)

The reason the dedicated cluster + cluster-level default combination matters — and isn't just a stylistic choice — is covered in the next section. The short version: it's the only configuration where my N4 fail-back actually fires for the whole solution.

The default ComputeClass I deployed

To make a custom ComputeClass the cluster-wide default, you give it the reserved name default. GKE then uses its priority rules as the autoscaling rules for any Pod that doesn't select a different class. (About GKE ComputeClasses)

apiVersion: cloud.google.com/v1
kind: ComputeClass
metadata:
  # The reserved name "default" makes this the cluster-wide default class.
  name: default
spec:
  priorities:
    # 1) Preferred: N4 on-demand
    - machineFamily: n4
      spot: false
    # 2) Fallback: C4 on-demand when N4 is exhausted
    - machineFamily: c4
      spot: false

  # When N4 capacity returns, replace C4 nodes with N4 nodes over time.
  # This is what makes the C4 fallback temporary by design.
  activeMigration:
    optimizeRulePriority: true

  # Let GKE create the node pools for me.
  nodePoolAutoCreation:
    enabled: true

  # Be explicit: if NEITHER N4 nor C4 can be provisioned, keep Pods
  # Pending rather than silently scaling up some default machine type.
  whenUnsatisfiable: DoNotScaleUp

I set whenUnsatisfiable explicitly. The default behavior changed at GKE 1.33: in older versions an unsatisfiable rule meant "scale up anyway" with the cluster's default machine type, which for me would have meant surprise E2 nodes instead of a clear Pending signal. Setting it explicitly means an upgrade won't silently change how the cluster behaves. (About custom ComputeClasses) I use DoNotScaleUp where I'd rather alert on Pending Pods; if you'd rather keep running on anything, use ScaleUpAnyway.

Because this is the cluster default, workloads need no changes at all — there are no nodeSelector blocks and no namespace labels to apply. One caution that informed the dedicated-cluster decision: GKE recommends you use either ComputeClasses or individual node selectors, but not both, since mixing them causes unexpected scheduling. A dedicated cluster where the default class governs everything avoids that conflict entirely. (About GKE ComputeClasses)

The default ComputeClass challenge in versions

This is the part that drove the whole design, and where I lost the most time, so I'm being emphatic about it.

Custom ComputeClasses themselves are old enough now (supported since GKE 1.30.3-gke.1451000) that it's easy to assume "defaults" came with them. They didn't. Setting a ComputeClass as a default is a much newer capability, and the two kinds of default have different version floors — and, critically, different behavior. (Apply ComputeClasses to Pods by default)

  • Cluster-level default (the class named default): requires GKE 1.33.1-gke.1744000 or later.
  • Namespace-level default (a cloud.google.com/default-compute-class label on the namespace), applied to only non-DaemonSet Pods: requires GKE 1.33.1-gke.1788000 or later.

The behavioral difference is the trap, and it's the reason a dedicated cluster with a cluster-level default is the right shape for my solution rather than a namespace label on a shared cluster:

  • With a cluster-level default, activeMigration.optimizeRulePriority does fire — if lower-priority C4 nodes exist and GKE can now create N4 nodes, it migrates. That's exactly my N4 fail-back.
  • With a namespace-level default, active migration is not triggered at all, because GKE only injects the ComputeClass selector into newly created Pods. Existing Pods are never re-created with the selector, so they never migrate back to N4. (About GKE ComputeClasses)

In other words, if I'd taken the easy path of labeling a namespace on an existing cluster, my Pods would have fallen back to C4 during a stockout and stayed on C4 forever, even after N4 came back. The fail-back — the whole point — would silently not work. The cluster-level default is the only configuration that gives me both the automatic inheritance and the migration back to N4, and that pushed me to stand up a cluster dedicated to this solution where naming a class default is safe and intentional.

Stacking the requirements, the binding version floor for my solution is the combination of:

  • cluster-level default ComputeClass → 1.33.1-gke.1744000, and
  • ComputeClass-driven node-pool auto-creation without cluster-level node auto-provisioning → 1.33.3-gke.1136000 on the Rapid release channel.

So I target ≥ 1.33.3-gke.1136000 on Rapid, which clears both. Below the default-CC floor entirely (anything before 1.33.1-gke.1744000), you simply cannot set a cluster-wide default — you'd be forced back into per-workload selectors or namespace labels, and the latter breaks the fail-back as described above.

Version requirements I treat as mandatory

Capability I depend on Minimum GKE version
Custom ComputeClasses at all (the base feature) 1.30.3-gke.1451000
Cluster-level default ComputeClass (class named default) 1.33.1-gke.1744000
Namespace-level default for non-DaemonSet Pods (I deliberately avoid this) 1.33.1-gke.1788000
Node-pool auto-creation from the ComputeClass without cluster-level NAP 1.33.3-gke.1136000, Rapid channel
Exact custom machine types in priorities + Kubernetes labels set by the class 1.33.2-gke.1111000
nodePoolConfig.imageType in a ComputeClass 1.32.4-gke.1198000

(Sources: default ComputeClasses, node-attributes ComputeClass how-to, node pool auto-creation, GKE release notes.)

One more trap on top of the version floors: nodePoolAutoCreation.enabled: true is not enough on its own on older clusters. Before 1.33.3-gke.1136000, you also have to enable cluster-level node auto-provisioning (NAP), or GKE won't create the node pools for your class and Pods just sit Pending — which looks exactly like the stockout you were trying to solve. At/after that version on Rapid you can let the ComputeClass drive auto-creation directly. (About custom ComputeClasses)

On the tooling side, the versions I standardized on:

  • Terraform CLI ≥ 1.5 (I run 1.15.x).
  • hashicorp/google provider 7.x — I pin ~> 7.36. (The 7.0 line has been GA since 2025; 7.36 was current when I wrote this.)
  • hashicorp/kubernetes provider ≥ 2.30 to apply the ComputeClass CRD through Terraform.
  • If you use the community terraform-google-modules/terraform-google-kubernetes-engine module with its enable_default_compute_class plumbing, it requires the google provider ≥ 7.10.

Terraform

I provision the dedicated cluster and its default ComputeClass as code. Three pieces: providers (pinned), the dedicated cluster (with the version floor and autoscaling/NAP settings), and the default ComputeClass manifest.

Providers and version pinning

terraform {
  required_version = ">= 1.5"

  required_providers {
    google = {
      source  = "hashicorp/google"
      version = "~> 7.36"
    }
    kubernetes = {
      source  = "hashicorp/kubernetes"
      version = "~> 2.30"
    }
  }
}

provider "google" {
  project = var.project_id
  region  = var.region
}

The dedicated cluster — pin the version, turn on autoscaling / NAP

# A cluster built specifically and exclusively for this solution.
resource "google_container_cluster" "solution" {
  name     = "n4-solution-euw3"
  location = var.region

  # Rapid channel keeps us on a version new enough for both the
  # cluster-level default ComputeClass AND ComputeClass-driven
  # node-pool auto-creation without cluster-level NAP.
  release_channel {
    channel = "RAPID"
  }

  # Insist on a control-plane version that supports the cluster-level
  # default ComputeClass and auto-creation. This is the binding floor.
  min_master_version = "1.33.3-gke.1136000"

  remove_default_node_pool = true
  initial_node_count       = 1

  # Cluster-level node auto-provisioning. REQUIRED if your control plane is
  # older than 1.33.3-gke.1136000; optional (but harmless) at/after it.
  cluster_autoscaling {
    enabled = true

    resource_limits {
      resource_type = "cpu"
      minimum       = 4
      maximum       = 512
    }
    resource_limits {
      resource_type = "memory"
      minimum       = 16
      maximum       = 2048
    }

    auto_provisioning_defaults {
      management {
        auto_repair  = true
        auto_upgrade = true
      }
    }
  }
}

# A small autoscaling system pool so the Standard cluster satisfies the
# "at least one node pool has autoscaling enabled" requirement.
resource "google_container_node_pool" "system" {
  name     = "system"
  cluster  = google_container_cluster.solution.id
  location = var.region

  autoscaling {
    min_node_count = 1
    max_node_count = 3
  }

  node_config {
    machine_type = "e2-standard-4"
    oauth_scopes = ["https://www.googleapis.com/auth/cloud-platform"]
  }
}

The cluster-level default ComputeClass as a Terraform-managed manifest

data "google_client_config" "default" {}

provider "kubernetes" {
  host                   = "https://${google_container_cluster.solution.endpoint}"
  cluster_ca_certificate = base64decode(
    google_container_cluster.solution.master_auth[0].cluster_ca_certificate
  )
  token = data.google_client_config.default.access_token
}

resource "kubernetes_manifest" "default_compute_class" {
  manifest = {
    apiVersion = "cloud.google.com/v1"
    kind       = "ComputeClass"
    metadata = {
      # "default" => cluster-wide default. Requires GKE 1.33.1-gke.1744000+.
      name = "default"
    }
    spec = {
      priorities = [
        { machineFamily = "n4", spot = false },
        { machineFamily = "c4", spot = false },
      ]
      # Fires for a CLUSTER-level default; would NOT fire for a namespace default.
      activeMigration = {
        optimizeRulePriority = true
      }
      nodePoolAutoCreation = {
        enabled = true
      }
      whenUnsatisfiable = "DoNotScaleUp"
    }
  }

  depends_on = [google_container_cluster.solution]
}

Gotcha worth knowing: kubernetes_manifest validates against the cluster's API at plan time, so the ComputeClass CRD must already exist on the control plane when you plan. On a brand-new cluster that means a two-phase apply (cluster first, then the manifest), or driving the kubectl apply from a null_resource/local-exec against the rendered YAML. On GKE the CRD ships with the control plane, so once the cluster exists, the manifest applies cleanly.

Because this is the cluster default, there are no workload-side Terraform or manifest changes. Anything scheduled on this dedicated cluster inherits N4→C4→N4 automatically.

What I'd tell my past self

The N4 stockouts were never going to be "fixed" by retrying harder — capacity in a given zone isn't something I control. What I could control was whether a missing N4 node meant a stalled rollout or a transparent fall-through to C4. Building a dedicated cluster with a cluster-level default ComputeClass gave me a declarative, GitOps-friendly way to express "prefer N4, accept C4, return to N4" for the entire solution at once — no per-workload wiring, and no risk of mixing class selection with node selectors.

Three things genuinely mattered in practice: set whenUnsatisfiable explicitly so an upgrade never changes my failure mode behind my back; use a cluster-level default, not a namespace label, because only the cluster-level default actually triggers the active migration back to N4; and pin the GKE version to at least 1.33.3-gke.1136000 on Rapid, because the default-ComputeClass and auto-creation features I'm relying on simply don't exist on older clusters. Get those right and the stockouts stop being incidents and become a non-event.