-
Notifications
You must be signed in to change notification settings - Fork 39.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure secret pulled images #94899
Ensure secret pulled images #94899
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ import ( | |
"encoding/json" | ||
"fmt" | ||
"hash/fnv" | ||
"strconv" | ||
"strings" | ||
|
||
"k8s.io/klog/v2" | ||
|
@@ -107,6 +108,14 @@ func HashContainer(container *v1.Container) uint64 { | |
return uint64(hash.Sum32()) | ||
} | ||
|
||
// HashAuth - returns a hash code for a CRI pull image auth | ||
func HashAuth(auth *runtimeapi.AuthConfig) string { | ||
mikebrow marked this conversation as resolved.
Show resolved
Hide resolved
|
||
hash := fnv.New64a() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fnv is a non-cryptographic hash algorithm... squinting at whether that matters here, but non-cryptographic + credentials + security make me squint There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we switch to sha256 so when we add persistence it is less of a worry. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could add a TODO if you like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think changing to sha256 would be ideal (or even making this configurable to future-proof this?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe opencontainers/go-digest |
||
authJSON, _ := json.Marshal(auth) | ||
hashutil.DeepHashObject(hash, authJSON) | ||
return strconv.FormatUint(hash.Sum64(), 16) | ||
} | ||
|
||
// envVarsToMap constructs a map of environment name to value from a slice | ||
// of env vars. | ||
func envVarsToMap(envs []EnvVar) map[string]string { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what this means and that I can't explain it to other people. I could read the code; I haven't, because I'm checking whether the docs part makes sense.
What effect does this feature gate have?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Described in more detail in the KEP. The sentence presumes the reader knows what kubelet is, container images, pods, image pull secrets (credentials), and authentication to registries using existing image pull policies and said credentials... and yes, that is a lot of assumptions. There are existing descriptions for the pull if not present, pull always policies, and warnings for using mitigations to force the pull always policy, because kubelet does not currently "ensure images pulled with pod imagePullSecrets are authenticated by other pods that do not have the same credentials" when pull always is not requested. We could adds links. This is a somewhat complex topic regarding currently known potential security vulnerabilities and subsequent performance issues with current mitigations.
Suggestions, to simplify the description are more than welcome.
Looks like we will not be merging in this release... Instead we will add in additional phase II suggested items, such as persistence of the ensure metadata, a gc sync process with container runtime image cache, (possibly) a solution for identifying which container images are loaded to be used as never pull images for the pod pull never container image policy, and a few other TODO items that were proposed for the next phase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overly simple explanation:
feature gate off (current behavior)
pod spec A has a private image that requires credentials (aka image pull secrets)
pod spec B uses the private image (This pod doesn't need credentials because the image is already cached)
feature gate on (desired behavior)
pod spec B also needs credentials to use the private image
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we switch to a revised comment that explains this clearly enough?
(I'm afraid I'm convinced that the current text falls some way short).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do