-
Notifications
You must be signed in to change notification settings - Fork 185
userinfo.email scope is needed to work with rbac #54
Comments
See: kubernetes-client/python-base#54 kubernetes-client/python-base#54 * The python client libs need to include userinfo.email when requesting scopes because otherwise RBAC might not work correctly because we won't be able to map the account/user correctly to role/cluster bindings for the email. * ksonnet doesn't have the fixes to the go client lib so for now we just update our docs to work around it by including a cluster role binding for the numeric id. * Update the debug worker to use the image in kubeflow-ci.
See: kubernetes-client/python-base#54 kubernetes-client/python-base#54 * The python client libs need to include userinfo.email when requesting scopes because otherwise RBAC might not work correctly because we won't be able to map the account/user correctly to role/cluster bindings for the email. * ksonnet doesn't have the fixes to the go client lib so for now we just update our docs to work around it by including a cluster role binding for the numeric id. * Update the debug worker to use the image in kubeflow-ci.
I believe we are experiencing the exact issue that you are describing when using the Kubernetes Python client. We are finding that when the Python client refreshes the access token in Using a
And a GCP service account (not a user service account, but a server service account) with the format:
I found that if I used
Where the
Using the command
So the token generated by the Python client is technically valid, however it isn't signed by an email and therefore can't be used by the Kubernetes API server to authenticate using RBAC. I've written a workaround where I wrap the call to def _refresh_credentials():
credentials, project_id = google.auth.default(scopes=[
'https://www.googleapis.com/auth/cloud-platform',
'https://www.googleapis.com/auth/userinfo.email'
])
request = google.auth.transport.requests.Request()
credentials.refresh(request)
return credentials I can put up a PR if there's interest, from my experience identifying this as the issue when you're seeing authentication issue can be really obscure. I've also seen a couple other issues of people complaining that the refresh token isn't refreshing so this could potentially help others as well. |
I figure I'll just open a PR to get things going if that's alright. |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
/close |
@axelsteingrimsson: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
KubeConfigLoader._refresh_credentials sets the scope to cloud-platform.
I think userinfo.email scope is needed as well.
See kubernetes/kubernetes#58141 for a similar issue with kubectl and a good explanation.
I think we need the userinfo.email scope because RBAC rules can be expressed in terms of the email of service accounts. But if the userinfo.email scope isn't included that APIServer ends up using the numeric id of service accounts which won't work if RBAC rules are written in terms of
the emails.
I haven't confirmed for myself this is an issue (I'm working through a variety of issues with kubectl/kubeconfig/client libs) so I could be wrong.
The text was updated successfully, but these errors were encountered: