← 返回 ibm 的题目列表Kubernetes Controller for Pod Balance
类型:qbank
Implement a Kubernetes-controller-style loop from a provided base class so pod counts remain balanced, then discuss controller semantics and API-server failure handling.
Requirements
A Kubernetes base class is provided.
Implement a controller that keeps the number of pods from becoming too high or too low.
The controller should behave like a separate reconciliation process: observe current state, compare against desired state, and issue create/delete or balancing actions.
Follow-ups:
Explain what a Kubernetes controller does.
Explain what happens if an API server is down.
Notes
The expected framing is reconciliation: continuously drive actual pod state toward desired pod state.
For API-server failure, wrap API interactions with error handling and retry/backoff rather than assuming every request succeeds.
The exact base-class methods and balancing constraints were image-based, so the implementable details are thinner than the verbal controller concept.
Preparation
Sketch a reconcile loop before coding: read observed pod state, compute desired delta, issue idempotent create/delete actions, and requeue on transient errors.
Prepare the API-server-down answer around failure isolation: cached local state may be stale, writes cannot be committed, and the controller should retry with backoff rather than inventing state.