Skip to content
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

Clarify behaviour of kubernetes_users role field in docs #18495

Closed
strideynet opened this issue Nov 15, 2022 · 3 comments · Fixed by #38705
Closed

Clarify behaviour of kubernetes_users role field in docs #18495

strideynet opened this issue Nov 15, 2022 · 3 comments · Fixed by #38705

Comments

@strideynet
Copy link
Contributor

strideynet commented Nov 15, 2022

Applies To

https://goteleport.com/docs/kubernetes-access/getting-started/#kubernetes-authentication

Kubernetes docs in general.

Details

The behaviour of the allow.kubernetes_users role field is quite complex, and we don't do a good job of describing its behaviour anywhere in the documentation.

From my brief exploration:

  • When it is unset or empty, the username of the user is used for impersonation when making requests to the kube apiserver.
  • When it is set with one entry, that value is impersonated when making requests to the kube apiserver.
  • When it is set with multiple entries, the client MUST specify which value it wishes to impersonate. The value they wish to impersonate must be included within the kubernetes_user set. Specifying this is done with the --as when using kubectl. Failure of the client to specify a user it wishes to impersonate will lead to an error rather than a successful request.

Suggested fixes

Remove mention of kubernetes_users from Getting Started

As far as I can tell, this value in the getting started documentation not necessary. If nothing is configured here, then the user's username will be used for impersonation, which is a sane default.

I would go as far as to suggest that the current value we suggest users set is actually harmful. In my case:

➜  teleport-actions git:(strideynet/k8s-auth-helper) ✗ kubectl config view \        
-o jsonpath="{.contexts[?(@.name==\"$(kubectl config current-context)\")].context.user}"
root.tele.ottr.sh-docker-desktop%  

The docs would have me set the user to "root.tele.ottr.sh-docker-desktop" - which is certainly far less descriptive and useful than "noahstride".

Include an explicit section in the FAQs of Kubernetes Access on kubernetes_users

I think we need to not only capture the behaviour of this field, but also why it is useful and in what circumstances you should want to use it.

@strideynet
Copy link
Contributor Author

It appears this PR introduced this field and provides some additional context: #3404

@ptgott
Copy link
Contributor

ptgott commented May 22, 2023

Hi @strideynet, since this issue was opened, we added some more explanation of how the Kubernetes Service processes Teleport roles: https://goteleport.com/docs/kubernetes-access/controls/

Does this take care of this issue? Thanks!

@strideynet
Copy link
Contributor Author

strideynet commented May 24, 2023

@ptgott

https://goteleport.com/docs/kubernetes-access/controls/

This explanation is a significant improvement, it captures my understanding of the topic well.


I think my concerns re: https://goteleport.com/docs/kubernetes-access/getting-started/#kubernetes-authentication are still valid.

We instruct users to run the following command:

kubectl config view \
-o jsonpath="{.contexts[?(@.name==\"$(kubectl config current-context)\")].context.user}"

The output of this command returns the Teleport cluster name and the name of the Kubernetes cluster in Teleport concatenated:

noah.teleport.sh-example-cluster

We then instruct the user to insert this value into the spec.allow.kubernetes_users field of the Role they need to create.

This doesn't make any sense to me at all. It's causing all Kubernetes requests made by that user to be impersonated as noah.teleport.sh-example-cluster - which completes obscures which user is running an action in Kubernetes internal logs (as opposed to Teleport's logs).

Unless someone more familiar with this chimes in to correct me, I recommend dropping the kubectl config view... step from the docs and dropping the spec.allow.kubernetes_users from the example Role we instruct the user to create. If this field is not provided, then Teleport acts in a sane way by default and uses the Teleport user's username.

ptgott added a commit that referenced this issue Feb 27, 2024
Closes #18495

Edit the partial at `docs/pages/includes/kubernetes-access/rbac.mdx` so
it does not require enabling access to an awkwardly named Kubernetes
user based on the current context. Instead, have the user check whether
they can already access Kubernetes users/groups, and if not, assign
their Teleport user a role that can access a view-only group.
ptgott added a commit that referenced this issue Mar 5, 2024
Closes #18495

Edit the partial at `docs/pages/includes/kubernetes-access/rbac.mdx` so
it does not require enabling access to an awkwardly named Kubernetes
user based on the current context. Instead, have the user check whether
they can already access Kubernetes users/groups, and if not, assign
their Teleport user a role that can access a view-only group.
ptgott added a commit that referenced this issue Mar 6, 2024
Closes #18495

Edit the partial at `docs/pages/includes/kubernetes-access/rbac.mdx` so
it does not require enabling access to an awkwardly named Kubernetes
user based on the current context. Instead, have the user check whether
they can already access Kubernetes users/groups, and if not, assign
their Teleport user a role that can access a view-only group.
ptgott added a commit that referenced this issue Mar 14, 2024
Closes #18495

Edit the partial at `docs/pages/includes/kubernetes-access/rbac.mdx` so
it does not require enabling access to an awkwardly named Kubernetes
user based on the current context. Instead, have the user check whether
they can already access Kubernetes users/groups, and if not, assign
their Teleport user a role that can access a view-only group.
github-merge-queue bot pushed a commit that referenced this issue Mar 20, 2024
Closes #18495

Edit the partial at `docs/pages/includes/kubernetes-access/rbac.mdx` so
it does not require enabling access to an awkwardly named Kubernetes
user based on the current context. Instead, have the user check whether
they can already access Kubernetes users/groups, and if not, assign
their Teleport user a role that can access a view-only group.
ptgott added a commit that referenced this issue Mar 26, 2024
Closes #18495

Edit the partial at `docs/pages/includes/kubernetes-access/rbac.mdx` so
it does not require enabling access to an awkwardly named Kubernetes
user based on the current context. Instead, have the user check whether
they can already access Kubernetes users/groups, and if not, assign
their Teleport user a role that can access a view-only group.
github-merge-queue bot pushed a commit that referenced this issue Mar 26, 2024
Closes #18495

Edit the partial at `docs/pages/includes/kubernetes-access/rbac.mdx` so
it does not require enabling access to an awkwardly named Kubernetes
user based on the current context. Instead, have the user check whether
they can already access Kubernetes users/groups, and if not, assign
their Teleport user a role that can access a view-only group.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants