Granting a non-root user the access of kubectl in kubernetes

3/5/2019

I can access the kubectl with root user. I want to restrict the access of kubectl to non-root users so that they can perform all the kubectl operations. How should I achieve the same?

-- MrunalTheCoder
kubectl
kubernetes
linux
sudo
ubuntu

1 Answer

3/5/2019

kubectl client it's distributed as a binary file so depending on your host you might give exec access to all users by doing chmod +x /usr/local/bin/kubectl

or you can add a custom rule to your /etc/sudoers by using visudo

your_user ALL = NOPASSWD: /usr/local/bin/kubectl

your user will be able to run kubectl like this

sudo kubectl ...
-- Hernan Garcia
Source: StackOverflow