Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to logon as non-root user in Kubernetes pod/container

I am trying to log into a kubernetes pod using the kubectl exec command. I am successful but it logs me in as the root user. I have created some other users too as part of the system build.

Command being used is "kubectl exec -it /bin/bash". I guess this means that run /bin/bash on the pod which results into a shell entry into the container.

Can someone please guide me on the following -

  1. How to logon using a non-root user?
  2. Is there a way to disable root user login?
  3. How can I bind our organization's ldap into the container?

Please let me know if more information is needed from my end to answer this?

Thanks,

Anurag

like image 485
Anurag Avatar asked Oct 24 '25 07:10

Anurag


1 Answers

I think its because the container user is root, that is why when you kubectl exec into it, the default user is root. If you run your container or pod with non root then kubectl exec will not be root.

like image 156
Bal Chua Avatar answered Oct 25 '25 22:10

Bal Chua



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!