-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Handle incompatible automount token setting In service account YAML #5549
Conversation
I think this may complicate our tests... If I'm understanding correctly, the service account token volume mount is added by Kubernetes at pod creation time (by a kubernetes system mutating webhook?). However, this doesn't happen in our unit tests because the pods aren't actually being created in a Kubernetes cluster. Making all of our injection tests take this into account seems challenging. To help me evaluate this trade-off, it would be helpful for me to know how serious of an issue this is to begin with. What are the consequences if we don't fix it? In practice, how much better is it to skip injecting pods which use non-automount service accounts versus injecting them and having them not work? A different approach would be to allow these pods to be injected, but to be able to identify this situation after the fact with |
Yes. The service account token volume is added by the service account admission controller before an object is persisted, hence this cannot be validated at the cli injection phase. I agree that this will complicate the tests, for the reasons mentioned.
I am not totally sure about the seriousness of the issue. But when a pod has no service account volume mounted, it may cause the pods to go into a crashloop since they won't be able to fetch an identity. So I think when a user tries to inject a workload without service account volume mounted, maybe we should show some sort of error? I think that Do you propose that I move forward with this approach? |
Yeah, I think that's my preference. |
@adleong, where do you think does this check fit (category-wise)? Should introduce a new category for this check (maybe something like |
I think it's a data-plane check since it checks the health of an injected workload rather than checking the health of the control plane itself. Therefore, I think it belongs in the data plane checks category. |
e3f481b
to
4226ad8
Compare
To be honest, I would prefer not to introduce a special case here, and let this failure be handled like the other ones: hostnetwork enabled, existing sidecar, udp ports enabled, automountServiceAccountToken disabled. The latter would have to be expanded so the injector doesn't just check the pod's automountServiceAccountToken but also the associated ServiceAccount's. Note these failures are surfaced not only as log entries in the injector, but also as events in the pod's workload owner. |
Hmm, the only problem with handling this failure like all the other failures, is testing. As @adleong mentioned, this may complicate testing. Since we are checking the service account mount in the containers, which is added by the service account admission controller; it will be a bit challenging to test this as we are not actually creating a k8s clusters while performing the unit tests. |
Rather than checking for the service account mount in the container, is it instead possible to just check the |
About the tests, |
Alright, so first I'll revert back to the earlier approach, and expand the serviceaccount check in |
50fb4fc
to
50d4a4b
Compare
@alpeb do you think we need to update |
Yeah, the |
Signed-off-by: Jimil Desai <jimildesai42@gmail.com>
Signed-off-by: Jimil Desai <jimildesai42@gmail.com>
Signed-off-by: Jimil Desai <jimildesai42@gmail.com>
Signed-off-by: Jimil Desai <jimildesai42@gmail.com>
Signed-off-by: Jimil Desai <jimildesai42@gmail.com>
Signed-off-by: Jimil Desai <jimildesai42@gmail.com>
50d4a4b
to
1f2106a
Compare
So just to summarize I've added the following changes,
|
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.
Excellent! And thanks for the extra test 😉
Sorry to ping, but @adleong, can you take a look? 😅 |
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.
Thanks for the ping, @jimil749, and thanks for your hard work and flexibility on this!
…inkerd#5549) Fixes linkerd#4651 This PR adds a check in the proxy injector webhook. This checks if the concerned container has serviceaccount volume mounted. In case, the volume is not mounted, which essentially means that automountServiceAccountToken field in the service account used by the injected workload is set to false, we don't inject the sidecar proxy. Signed-off-by: Jimil Desai <jimildesai42@gmail.com> Signed-off-by: Jijeesh <jijeesh.ka@gmail.com>
…inkerd#5549) Fixes linkerd#4651 This PR adds a check in the proxy injector webhook. This checks if the concerned container has serviceaccount volume mounted. In case, the volume is not mounted, which essentially means that automountServiceAccountToken field in the service account used by the injected workload is set to false, we don't inject the sidecar proxy. Signed-off-by: Jimil Desai <jimildesai42@gmail.com> Signed-off-by: Jijeesh <jijeesh.ka@gmail.com>
Potential fix for #4651
This PR added a check in the proxy injector webhook stage. This checks if the concerned container has
serviceaccount
volume mounted. In case, the volume is not mounted, which essentially means thatautomountServiceAccountToken
field in the service account used by the injected workload is set tofalse
, we don't inject the sidecar proxy.But there is a caveat here. Since I am performing the check at the webhook stage (unlike the other checks, which also take place at the cli stage), there is no error shown to the user when the injection fails.
I am not a 100% how to output the error to the users.
If we look at the logs of the proxy-injector, it skips the injection where
automountServiceAccountToken
is set to false.Signed-off-by: Jimil Desai jimildesai42@gmail.com