GKE Control Plane & Data Plane

One-line summary: Deep dive into GKE's control plane architecture, node management, pod networking, and how Kubernetes components work together.

Prerequisites: VPC, Load Balancing & DNS, Basic Kubernetes concepts (pods, nodes, services).


Mental Model

GKE Architecture

flowchart TB User[User/API] --> CP[Control Plane
GKE Managed] CP --> ETCD[etcd
State Store] CP --> API[API Server] CP --> Scheduler[Scheduler] CP --> CM[Controller Manager] CP --> DP[Data Plane
Node Pools] DP --> Kubelet[Kubelet] DP --> KubeProxy[Kube-proxy] DP --> CNI[CNI Plugin
Networking] DP --> Pod1[Pod 1] DP --> Pod2[Pod 2] DP --> Pod3[Pod 3] style CP fill:#99ccff style DP fill:#ffcc99 style ETCD fill:#99ff99

Key insight: GKE separates control plane (managed by Google) from data plane (your nodes). Understanding both is critical for troubleshooting and optimization.

Control Plane vs Data Plane

Control Plane: Manages cluster state, schedules pods, handles API requests. - Managed by Google: High availability, automatic updates - Components: API server, etcd, scheduler, controller manager

Data Plane: Runs your workloads (pods). - Managed by you: Node pools, scaling, updates - Components: Kubelet, kube-proxy, CNI plugin


Internals & Architecture

Control Plane Deep Dive

API Server

API Server: Central component that validates and processes all API requests.

Functions: - Authentication: Verify identity (service accounts, OAuth) - Authorization: Check permissions (RBAC, ABAC) - Admission control: Validate and mutate requests (validating/mutating webhooks) - State management: Read/write to etcd

Request Flow:

Client → API Server → Authentication → Authorization → Admission Control → etcd

Performance: - QPS: Handles thousands of requests per second - Latency: P95 < 10ms for most operations - Scaling: Automatically scales with cluster size

etcd

etcd: Distributed key-value store for cluster state.

Data stored: - Pods: Pod specifications and status - Services: Service definitions - ConfigMaps: Configuration data - Secrets: Encrypted secrets - Nodes: Node information

Consistency: Strong consistency (linearizable reads)

Backup: Automatic backups every 6 hours (GKE managed)

Performance: - Write latency: P95 < 50ms - Read latency: P95 < 10ms - Throughput: Thousands of operations per second

Scheduler

Scheduler: Assigns pods to nodes based on constraints and resources.

Scheduling process: 1. Filter: Filter nodes that meet pod requirements (resources, node selectors, taints/tolerations) 2. Score: Score filtered nodes (resource availability, affinity, anti-affinity) 3. Bind: Assign pod to highest-scoring node

Scheduling policies: - Resource requests: CPU, memory requirements - Node selectors: Prefer specific node types - Affinity/anti-affinity: Co-locate or separate pods - Taints/tolerations: Restrict pod placement

Performance: - Scheduling latency: P95 < 100ms - Throughput: Hundreds of pods per second

Controller Manager

Controller Manager: Runs controllers that maintain desired state.

Controllers: - Replication Controller: Maintains pod replicas - Deployment Controller: Manages deployments - StatefulSet Controller: Manages stateful applications - Node Controller: Monitors node health - Service Controller: Manages load balancers

Reconciliation loop: Continuously checks desired vs actual state, makes changes.

Data Plane Deep Dive

Node Pools

Node Pool: Group of nodes with same configuration.

Configuration: - Machine type: CPU, memory, disk - OS image: Container-Optimized OS, Ubuntu - Scaling: Auto-scaling, manual scaling - Upgrades: Automatic or manual node upgrades

Node Pool Types: - Standard: General-purpose workloads - Spot/Preemptible: Cost-effective, can be preempted - GPU: GPU-enabled nodes - High-memory: Memory-optimized nodes

Kubelet

Kubelet: Agent running on each node, manages pods.

Functions: - Pod lifecycle: Create, start, stop, delete pods - Health checks: Liveness, readiness probes - Volume mounting: Mount volumes to pods - Container runtime: Interface with container runtime (containerd)

Communication: - API Server: Reports node status, receives pod assignments - Container runtime: Manages containers - CNI: Configures pod networking

Kube-proxy

Kube-proxy: Network proxy for service routing.

Modes: - iptables: Uses iptables rules (default, high performance) - IPVS: Uses IPVS (better for large clusters) - Userspace: Userspace proxy (legacy)

Functions: - Service routing: Routes service traffic to pods - Load balancing: Distributes traffic across pod endpoints - Session affinity: Maintains client-pod affinity

How it works: 1. Service created → kube-proxy watches API server 2. Endpoints discovered → kube-proxy creates iptables rules 3. Traffic arrives → iptables routes to pod IP

CNI (Container Network Interface)

CNI: Plugin that configures pod networking.

GKE CNI: Google's VPC-native networking.

Features: - VPC-native: Pods get IPs from VPC subnet - Network policies: Firewall rules for pod-to-pod communication - Service mesh: Integration with Istio/Anthos Service Mesh

Networking model: - Pod IP: Each pod gets IP from VPC subnet - Service IP: Virtual IP for service (cluster IP) - Load balancer: External IP for external access

Pod Networking

Pod Network Architecture

graph LR Pod[Pod] --> Veth[Virtual Ethernet Pair] Veth --> Bridge[Linux Bridge] Bridge --> VPC[VPC Network] Pod --> Service[Service IP] Service --> KubeProxy[Kube-proxy] KubeProxy --> Pod style Pod fill:#99ccff style Service fill:#ffcc99 style VPC fill:#99ff99

Pod networking flow: 1. Pod creation: CNI assigns IP from VPC subnet 2. Intra-pod: Pods on same node communicate via bridge 3. Inter-pod: Pods on different nodes communicate via VPC routing 4. Service access: Traffic goes through kube-proxy to pod IP

Service Types

ClusterIP: Internal service (default). - Use case: Internal communication - Access: Only within cluster

NodePort: Exposes service on node IP. - Use case: External access via node IP - Port: 30000-32767

LoadBalancer: External load balancer. - Use case: External access via load balancer IP - GCP: Creates GCP load balancer

ExternalName: Maps to external DNS name. - Use case: External services - Access: Via DNS name

Workload Identity

Workload Identity: Allows pods to use GCP service accounts.

Architecture:

Kubernetes Service Account (KSA) → Workload Identity → Google Service Account (GSA)

Process: 1. Annotation: Pod annotated with KSA 2. Mapping: Workload Identity maps KSA to GSA 3. Token: Pod receives GCP access token 4. Access: Pod accesses GCP resources as GSA

Benefits: - No keys: No need to store service account keys - Security: Automatic key rotation - Audit: Better audit trail


Failure Modes & Blast Radius

Control Plane Failures

Scenario 1: API Server Failure

Scenario 2: etcd Failure

Scenario 3: Scheduler Failure

Data Plane Failures

Scenario 1: Node Failure

Scenario 2: Kubelet Failure

Scenario 3: Network Partition

Pod Failures

Scenario 1: Pod Crash Loop

Scenario 2: Resource Exhaustion

Overload Scenarios

10× Normal Load

100× Normal Load


Observability Contract

Metrics to Track

Control Plane Metrics

Data Plane Metrics

Pod Metrics

Service Metrics

Logs

Control Plane Logs: - API server audit logs - etcd logs - Scheduler logs - Controller manager logs

Data Plane Logs: - Kubelet logs - Kube-proxy logs - Container logs (application logs)

Cluster Logs: - Node events - Pod events - Service events

Traces

Distributed Tracing: - End-to-end request traces - Pod-to-pod communication - Service mesh traces (if using Istio)

Alerts

Critical alerts: - Control plane unavailable - Node failure - Pod crash loop - Service unavailable

Warning alerts: - High API server latency - Node resource exhaustion - Pod resource exhaustion - Service latency increase


Change Safety

Control Plane Changes

GKE Managed: Control plane updates are managed by Google. - Process: Automatic updates during maintenance windows - Risk: Low (Google manages updates) - Rollback: Automatic rollback on failure

Node Pool Changes

Adding Nodes

Updating Nodes

Changing Machine Types

Pod Changes

Deploying New Version

Changing Resource Limits

Network Changes

Changing Service Type

Updating Network Policies


Security Boundaries

Cluster Security

Node Security

Pod Security


Tradeoffs

Control Plane: Managed vs Self-Managed

GKE Managed: - Pros: High availability, automatic updates, no maintenance - Cons: Less control, Google-managed

Self-Managed: - Pros: Full control, customizable - Cons: Maintenance overhead, need to manage HA

Node Pool: Standard vs Spot

Standard Nodes: - Pros: Reliable, not preempted - Cons: Higher cost

Spot/Preemptible Nodes: - Pros: Lower cost (up to 80% discount) - Cons: Can be preempted, less reliable

Networking: VPC-Native vs Routes-Based

VPC-Native: - Pros: Better performance, simpler networking - Cons: Requires VPC subnet IPs

Routes-Based: - Pros: Works with existing networking - Cons: More complex, performance overhead


Operational Considerations

Capacity Planning

Control Plane: - Limits: - 5,000 nodes per cluster - 150,000 pods per cluster - 5,000 services per cluster

Data Plane: - Node sizing: Right-size nodes for workloads - Pod density: Balance pod density vs resource availability - Scaling: Plan for auto-scaling headroom

Monitoring & Debugging

Monitor: - Control plane health - Node health and resources - Pod health and resources - Service availability and latency

Debug issues: 1. Check control plane: API server, etcd health 2. Check nodes: Node status, resources 3. Check pods: Pod status, logs, events 4. Check services: Service endpoints, connectivity 5. Check networking: Network policies, VPC routes

Incident Response

Common incidents: - Pod failures - Node failures - Service unavailable - Network connectivity issues

Response: 1. Check cluster health 2. Check node health 3. Check pod status and logs 4. Check service endpoints 5. Check network connectivity 6. Scale if needed 7. Rollback if deployment issue


What Staff Engineers Ask in Reviews

Design Questions

Scale Questions

Security Questions

Operational Questions


Further Reading

Comprehensive Guide: Further Reading: GKE Internals

Quick Links: - GKE Documentation - Kubernetes Documentation - "Kubernetes: Up and Running" (Hightower et al.) - Workload Identity - VPC-Native Networking - Back to GCP Core Building Blocks


Exercises

  1. Design node pools: Design node pools for a multi-tier application (web, app, database). What machine types? How many nodes?

  2. Pod scheduling: You have pods that need to run on specific nodes. How do you ensure they're scheduled correctly?

  3. Debug pod failure: A pod is crashing. How do you debug this? What logs do you check?

Answer Key: View Answers