GKE Autopilot Resource Constraints

Overview

Google Kubernetes Engine (GKE) Autopilot enforces strict resource constraints via LimitRange policies to optimize cost and performance. Violations cause pod creation failures. Critical Rule: CPU and memory limit/request ratios must not exceed 4.0x.

CPU Ratio Constraint

The 4.0x Rule

Why: GKE Autopilot prevents resource waste and ensures predictable billing. A 4.0x ratio allows reasonable burst capacity while preventing excessive over-commitment.

Examples

Compliant Configurations

  • ✅ Example 1:
  • ✅ Example 2:
  • ✅ Example 3:

Non-Compliant Configurations

  • ❌ Example 1 - VIOLATION:
  • ❌ Example 2 - VIOLATION:

Common Services - Resource Sizing Guide

otel-collector

Recommended: 250m request / 1000m limit (4.0x ratio)
  • Handles telemetry data collection
  • Needs burst capacity for traffic spikes

qdrant (Vector Database)

Recommended: 250m request / 1000m limit (4.0x ratio)
  • Performs vector similarity search
  • CPU-intensive during query processing

postgres (Database)

Recommended: 500m request / 2000m limit (4.0x ratio)
  • Primary data store
  • Higher baseline due to query processing

redis-session (Cache)

Recommended: 125m request / 500m limit (4.0x ratio)
  • Session storage and caching
  • Lower resource requirements

mcp-server-langgraph (Application)

Recommended:
  • Dev: 125m request / 500m limit (4.0x ratio)
  • Production: 500m request / 2000m limit (4.0x ratio)

Fixing Ratio Violations

Step 1: Calculate Current Ratio

Step 2: Choose Fix Strategy

Option A: Increase Request (Recommended)
  • Preserves burst capacity
  • Ensures adequate baseline resources
  • Better for production workloads
Option B: Decrease Limit
  • Reduces burst capacity
  • Lower resource costs
  • Better for cost-sensitive environments

Step 3: Create Overlay Patch

Create deployments/overlays/{environment}/{service}-patch.yaml:

Step 4: Update Kustomization

Add patch to deployments/overlays/{environment}/kustomization.yaml:

Step 5: Validate

Validation Tools

Pre-deployment Validation

Pre-commit Hook

The repository includes automatic validation via pre-commit hooks:

Unit Tests

Test coverage ensures validator correctness:

Environment Variable Conflicts

Issue: value + valueFrom

Kubernetes strategic merge can create conflicts when overlays override base configurations:

Solution: Explicit null

Set valueFrom: null to remove base definition:

Common Pitfalls

1. Wrong Resource Type in Patch

  • ❌ Using kind: Deployment for a StatefulSet:
  • ✅ Correct:

2. Forgetting Kustomization Update

After creating a patch file, you MUST update kustomization.yaml:

3. Memory Ratio Violations

The 4.0x ratio also applies to memory:
Fix:

Quick Reference Calculator

Additional Resources

Troubleshooting

Pod Creation Failed

Solution: Review pod resources and adjust according to this guide.

Kustomize Build Error

Solution: redis-session is a StatefulSet, not Deployment. Update patch file.

Pre-commit Hook Failures

Solution: Fix the violation before committing. The hook prevents bad configs from reaching CI/CD.
Last Updated: 2025-11-12 Maintained By: Infrastructure Team Contact: #infrastructure-support