Skip to content

Kubelet should enforce access to images after they've already been pulled to a node #18787

Description

@ncdc

Problem statement

Some images require pull secrets in order to be used by the Kubelet. Pull secrets are per namespace. Imagine the following scenario:

  1. If a pod in namespaceA has valid pull secrets for foo/bar:stable, when it is scheduled to a given node, the Kubelet uses the pull secrets to pull the image to the node
  2. If a pod in namespaceB also refers to foo/bar:stable but does not have valid pull secrets for it, if it happens to be scheduled to the same node as the pod in step 1, the Kubelet respects the image pull policy
  3. Because the image already exists on the node, if the pull policy is Never or IfNotPresent, the Kubelet runs the pod, even though namespaceB shouldn't be able to use that image.

Proposed solutions

Option 1 - Kubelet flag to ignore pull policy and always try to pull

Add a flag to the kubelet, --always-pull-images (or something similarly named) that, if true, would force the Kubelet to attempt to pull every image prior to running a pod, regardless of the image's pull policy.

Pros:

  • Easy to implement
  • Guarantees that a namespace is allowed to use an image

Cons:

  • Overrides user-specified intent in image pull policy
  • Requires remote registry to be online to check authorization
  • Introduces small amount of latency to pod startup time (because of the additional network requests to the registry)

Option 2 - Keep an in-memory cache of which namespaces are allowed to use which images

After an image has been successfully pulled, record the mapping from namespace to image in an in-memory cache in the Kubelet. Subsequent attempts by pods in the same namespace to use the same image would respect the image pull policy. Any attempts by pods in other namespaces to use this image would ignore the image pull policy and instead force a pull attempt.

Pros:

  • Doesn't override user-specified intent in image pull policy
  • No added latency to pod startup time

Cons:

  • Doesn't handle authorization revocation; if the credentials to pull an image have changed in the remote registry, there is no way to evict an entry from the cache, possibly allowing access to an image that would otherwise fail with option 1. This could be mitigated if the entries in the cache have a TTL.

Suggested path forward

Looking for feedback from the community on this one. I'd like to implement option 1 in the short term, with the default being false (so image pull policy is respected) to keep the status quo. If we can come to an agreement on option 2, I'd like to move to that eventually.

@kubernetes/goog-node @kubernetes/rh-cluster-infra @kubernetes/sig-node

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.kind/featureCategorizes issue or PR as related to a new feature.lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.priority/backlogHigher priority than priority/awaiting-more-evidence.sig/authCategorizes an issue or PR as relevant to SIG Auth.sig/nodeCategorizes an issue or PR as relevant to SIG Node.

    Type

    No type

    Projects

    • Status
      Closed / Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions