In my local cluster when I do sudo -i all kubectl commands not working. In exam . . .

Balaji K:
In my local cluster when I do sudo -i all kubectl commands not working. In exam if I do sudo -i is that an issue ?. Btw is it ok to work without sudo -i ?

Hello, @Balaji K
After execute sudo -i command, Are you able to see the .kube directory?

I believe you know about config file. When you execute the kubectl command, look up that file in your user’s working directory ($HOME/.kube/config). If it’s configured correctly for that user then you can access k8s cluster otherwise it will give you a warning.
If you’re getting a chance to become a root then become it. Otherwise you can perform as a student user as well in the exam.
Note - If you face some kind of permission issues then switch into root user but don’t panic at that moment.

Please watch this demo video:
Similar exam environment for CKAD as well.

Balaji K:
Thanks I see she using the sudo command and let me try doing sudo -i and see if kubectl works and if not will switch back to normal mode and use sudo where its required

Mayur Sharma:
@Balaji K I am not a regular user of unix, but knows a little that sudo is a power user that can execute special commands.
IN our CKAD exam perspective, can you please explain me why would you need sudo access for CKAD exam? for which scenario you are talking about. Thanks in advance!

Balaji K:
@Mayur Sharma In CKAD exam there are some request to copy to a certain location either you have to use sudo before executing the command to get root permission else you get into the root via sudo -i and work…

Mayur Sharma:
@Balaji K: Thanks for the reference, I would be very happy, if you could provide your views on following. I have a exam coming tomorrow.

So, if I understood you correctly. You mean there would be some directories where my user won’t have access to.

For e.g. to copy some data (via sudo) at /var/app/data directory, should I run following command,
sudo cp source /var/app/data
sudo -i cp <source> /var/app/data

Also, can you please confirm how to get sudo before executing command and where would I get password?
And, how does sudo -i work?

Mayur Sharma:
@Balaji K May be I am not fully aware of sudo and internal functioning, you also mentioned,
“sudo -i already has KUBECONFIG set so kubectl does work and needn’t do anything” – what does this mean, can you give some light on it?

Thanks in advance!

Balaji K:
sudo -i if it doesn’t have KUBECONFIG set your kubectl commands will not work. But they have made sure that its set so you needn’t worry just do sudo -i its more than sufficient.

Mayur Sharma:
cool, thanks @Balaji K!