-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
Fix the custom injection on OpenShift #47898
Fix the custom injection on OpenShift #47898
Conversation
@@ -49,6 +49,9 @@ spec: | |||
securityContext: | |||
allowPrivilegeEscalation: true | |||
readOnlyRootFilesystem: false | |||
# These should not be removed or ignored, should be honored | |||
runAsUser: 1234 | |||
runAsGroup: 1234 |
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.
Not sure why should we remove user's setting
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.
Indeed, this particular change in the test file was to guarantee we are not changing user values. This PR only changes it in a specific case: OpenShift.
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.
LGTM
Thanks for adding the details and release note.
Adding /hold for a day - in case others want to review. Just realized this PR is only out for < 1 day. |
// This is likely a scenario in OpenShift when the istio-proxy container with image: auto is parsed, if SecurityContext.RunAsUser | ||
// does not exist, OpenShift automatically assigns a value which is based on an annotation in the namespace. Regardless if the user | ||
// provided that value or if it was assigned by OpenShift, the correct value is the one in the template, as set by the `.ProxyUID` field. | ||
if original.SecurityContext != nil && template.SecurityContext != nil && template.SecurityContext.RunAsUser != nil && |
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.
image: auto
and securityContext
are unrelated. A user can override the proxy container AND set image: some-explicit-proxy-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.
that's right.
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.
@howardjohn fixed.
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.
LGTM now although the function name is maybeconfusing
Use of custom injection (i.e., providing a custom `istio-proxy` container) is broken on OpenShift. This is because OpenShift sets the `RunAs` field to be the a pseudo-random value that varies by namespace. We rely on the `RunAs` field to be a well-known value, and it's calculated upon injection. We should stick with that value. `iptables` rules were created based on that value. Even if the user provides another value (i.e., it's not set by OpenShift, but b the user), that's wrong. We should ignore what's in the original pod and use the calculated one, for these two fields only.
fdeffa6
to
bd3ca95
Compare
// This is likely a scenario in OpenShift when the istio-proxy container with image: auto is parsed, if SecurityContext.RunAsUser | ||
// does not exist, OpenShift automatically assigns a value which is based on an annotation in the namespace. Regardless if the user | ||
// provided that value or if it was assigned by OpenShift, the correct value is the one in the template, as set by the `.ProxyUID` field. | ||
if original.SecurityContext != nil && template.SecurityContext != nil && template.SecurityContext.RunAsUser != nil && |
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.
LGTM now although the function name is maybeconfusing
In response to a cherrypick label: new pull request created: #47914 |
Use of custom injection (i.e., providing a custom
istio-proxy
container) is broken on OpenShift.This is because OpenShift sets the
RunAs
field to be the a pseudo-random value that varies by namespace. We rely on theRunAs
field to be a well-known value, and it's calculated upon injection. We should stick with that value.iptables
rules were created based on that value.Even if the user provides another value (i.e., it's not set by OpenShift, but b the user), that's wrong. We should ignore what's in the original pod and use the calculated one, for these two fields only.