Add pinned image selectors to exclude images from kubelet GC - #571
Merged
athongsamai merged 1 commit intoSep 8, 2026
Merged
athongsamai merged 1 commit into
athongsamai merged 1 commit into
Conversation
The kubelet omits images the runtime reports as pinned from its
eviction list, but cri-dockerd only ever pinned the pod sandbox image.
Any other image that cannot simply be re-pulled -- a platform image
side-loaded onto an air-gapped node, for example -- is deleted once the
node crosses its image GC threshold.
Add two flags that let an operator pin additional images:
--pinned-images image references: a full "repo:tag" or
"repo@digest", a bare repository (pinning every
tag of it), or a prefix ending in '*'
--pinned-image-labels label selectors in "key" or "key=value" form,
pinning a whole set of images without
enumerating it
Matching lives in a new pinnedImageMatcher (core/pinned.go), which
NewDockerService builds once and ListImages/ImageStatus consult through
dockerService.isImagePinned. The sandbox image stays pinned
unconditionally, and a nil or empty matcher matches nothing, so the
default configuration behaves exactly as before. Reference parsing
treats a registry port as part of the repository rather than a tag.
ImageStatus now reads labels from the image inspect config so
label selectors apply to it as well as to ListImages.
chenyaooo
self-requested a review
September 4, 2026 14:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #
Why does this need?
The
kubeletomits images the runtime reports as pinned from its eviction list, butcri-dockerdonly ever pinned the pod sandbox image. Any other image that cannot simply be re-pulled -- a platform image side-loaded onto an air-gapped node, for example -- is deleted once the node crosses its image GC threshold.Proposed Changes
Add two flags that let an operator pin additional images:
--pinned-images: image references: a full "repo:tag" or "repo@digest", a bare repository (pinning every tag of it), or a prefix ending in '*'--pinned-image-labels: label selectors in "key" or "key=value" form, pinning a whole set of images without enumerating itMatching lives in a new
pinnedImageMatcher(core/pinned.go), whichNewDockerServicebuilds once andListImages/ImageStatusconsult throughdockerService.isImagePinned. The sandbox image stays pinned unconditionally, and a nil or empty matcher matches nothing, so the default configuration behaves exactly as before. Reference parsing treats a registry port as part of the repository rather than a tag.ImageStatusnow reads labels from the image inspect config so label selectors apply to it as well as toListImages.