File size: 1,375 Bytes
034ba67 | 1 2 3 4 5 | {"type": "session", "harness": "opencode", "id": "sys-0026", "name": "Kubernetes Deployment Controller Deep Dive"}
{"type": "message", "message": {"role": "system", "content": "You are an expert software engineer."}}
{"type": "message", "message": {"role": "user", "content": "Walk through the Kubernetes Deployment controller internals"}}
{"type": "message", "message": {"role": "assistant", "content": "DeploymentController manages rolling updates and rollbacks.\n\nConstructor:\n- Watches Deployments, ReplicaSets, Pods\n- Uses workqueue.NewTypedRateLimitingQueue\n- Registers event handlers that enqueue Deployment keys\n\nsyncDeployment flow:\n1. Get Deployment from lister (deep-copy to avoid cache mutation)\n2. Validate selector\n3. getReplicaSetsForDeployment: find matching RSs via ControllerRefManager\n4. Route to strategy: rollback, scaling, Recreate, or RollingUpdate\n\nRollingUpdate strategy:\n- maxSurge: how many extra pods above desired\n- maxUnavailable: how many pods can be unavailable\n- Creates new RS, scales up, scales down old RS\n- Uses rollingUpdateStrategy to control pace\n\nExpectations pattern:\n- Before creating/deleting pods: ExpectCreations/ExpectDeletions\n- Watches observe actual creates and decrement expectations\n- Controller only syncs when expectations satisfied or timeout (5min)\n- Prevents acting on stale informer data"}}
|