Prompt and use cases
When a private image is already on a node, should Kubernetes still verify imagePullSecrets? How would you choose a policy and roll it out safely? This backend prompt tests container-runtime behavior, credential lifecycles, and tenant isolation. Assume IfNotPresent, potentially shared nodes, a registry that supports short-lived credentials, and a requirement to avoid turning a security change into a fleet-wide outage.
What interviewers assess
- Whether you separate “the bytes are on this node” from “this workload is authorized to use them.”
- Whether you explain how kubelet records successful pulls and credentials, and why preloaded images need a separate treatment.
- Whether you compare
NeverVerify,NeverVerifyPreloadedImages, an allowlist, andAlwaysVerifyby risk and cost. - Whether you handle rotation, node reboot, missing cache records, registry failure, and rollback.
Questions to clarify before answering
Start with the threat model: are nodes multi-tenant, do images contain sensitive code, and can an attacker create a Pod? Ask whether images are pulled by kubelet or preloaded before the node starts, and whether credentials come from a Pod Secret, node identity, or service-account token. Clarify whether rotation must revoke old access immediately, whether offline verification is acceptable, and how much repull traffic the registry can absorb. Finally, decide whether the goal is backward compatibility, stronger isolation, or a stricter policy for sensitive namespaces.
30-second answer framework
“I would separate image-cache hits from authorization. A multi-tenant node or sensitive image should not bypass imagePullSecrets just because bytes are present. I would enable pull records, start with the preloaded-image exception, then roll toward AlwaysVerify by node pool and namespace. Guardrails would include startup success, repull rate, registry latency, rotation effectiveness, and cross-tenant denial. The rollout needs cache-record migration, registry-outage behavior, and a feature-gate rollback.”
Step-by-step deep answer
- Separate the decisions: The cache answers whether bytes exist; credential verification answers whether this request may use them.
IfNotPresentis not an authorization policy. - Record successful relationships: Kubelet records credentials that successfully pulled an image. The same credentials can be checked locally; unknown or rotated credentials require a registry pull and authorization.
- Handle preloaded images: Images loaded outside kubelet have no pull record.
NeverVerifyPreloadedImagespreserves compatibility,NeverVerifyAllowListedImagesnarrows the exception, andAlwaysVerifychecks all images. - Design rotation: A prior successful credential record does not prove a new credential works. Rotation should cause a repull or explicit invalidation, with registry throttling and startup latency monitored.
- Manage upgrade risk: On first enablement, existing images may be treated as preloaded. Remove cache entries that should no longer be trusted and account for kubelet restarts and cache-file migration.
- Stage and roll back: Enable by node pool, workload label, or low-risk namespace; watch denial and registry load. Keep
NeverVerifyor the feature gate as a fast rollback path.
High-quality sample answer
I would verify, but the policy depends on the threat model. A cache hit proves only that the node has image bytes; it does not prove that the current Pod may use a private image. On a multi-tenant node, bypassing verification lets workloads with different credentials reuse a cached image. Kubernetes’ design lets kubelet record the relationship between an image and credentials that successfully pulled it: the same credentials can be checked locally, while unknown or rotated credentials require registry access. Preloaded images lack those records, so I would begin with NeverVerifyPreloadedImages for compatibility and move sensitive node pools toward AlwaysVerify; if exceptions are necessary, use an explicit preloaded-image allowlist rather than disabling the control globally. Before enabling it, clean caches that should no longer be trusted and rehearse kubelet restarts, record migration, registry throttling, and credential rotation. During a canary, compare Pod startup success, repull rate, registry P95 latency, authorization denials, and cross-tenant reuse attempts. If a registry outage causes broad cold-start failures, roll back the gate or policy while retaining alerts and audit records. This puts security boundaries, compatibility, and capacity risk in one release decision.
Common mistakes
- Treating an image digest as proof that every namespace is authorized to use the image.
- Saying “enable
AlwaysVerify” without discussing preloaded images, node reboot, or registry failure. - Treating credential rotation as a Secret update while ignoring old success records and repull behavior.
- Flipping the policy fleet-wide without node-pool canaries, registry capacity, and a rollback switch.
- Calling
NeverVerifyPreloadedImagesa security guarantee without verifying preload provenance and the allowlist.
Follow-up questions and responses
Why can the same credential be checked without another registry request?
A successful pull proves that the registry accepted that credential for the image, so kubelet can validate the known relationship locally. A changed credential, missing record, or strict policy requires a new pull or registry check.
What if the cache record disappears after a node reboot?
Persist records in the kubelet directory and migrate them by version. If a record is unreadable, take the stricter path and repull rather than silently making the cached image available to anyone.
Should a cached image be allowed when the registry is temporarily unavailable?
Low-risk environments may have a narrowly defined, observable, time-limited degradation. Sensitive workloads should not bypass authorization. Record which requests were allowed offline so an incident does not become permanent over-permission.
How do you prove rotation actually works?
Start the same private image with the old Secret, the new Secret, no Secret, and identities from different namespaces. Check kubelet events, registry access, cache records, and Pod outcomes. Verify old credentials fail, new credentials succeed, and throttling triggers the planned rollback behavior.