$#@! I learned today: kubectl vsphere login and verbosity

So apologies for not posting recently. I took a week off (in the form of a staycation with my wife) and finished recording lecture for an update to a Tanzu Kubernetes Grid course. And while I was creating demos for those recordings, I decided to poke more at the various CLI (command-line interface) commands for kubectl.

So let’s start with the first command you’re likely to use after creating a Supervisor cluster on vSphere and after you’ve installed both the Tanzu plug-in and kubectl vSphere CLI plug-in.

Basically, the command allows me to use a vCenter account to authenticate and connect to the Supervisor. Now, this made me wonder how long the authentication remains. Searching through documentation, blogs and Google didn’t turn up anything. So, I figured check the command.

Screenshot showing the command kubectl vsphere --help and the output.

What caught my eye was the –request-timeout string, which is also lacking in info. But while searching for that info I ran into another flag that I figured out would be helpful: -v=10. This flag sets the verbosity level for the kubectl command (default is usally 2) and generates more info when running kubectl commands. This can be particularly helpful when troubleshooting why a command isn’t working. The verbosity will allow you to see the command while it’s being parsed by kubectl.

kubectl vsphere login with flags -v and –request-timeout (click image for larger picture)

So with the verbosity level set to 10, I am able to see my request to have the login valid for 6 hours. You can use either XXXm (in minutes) or XXXh (in hours). Of course, why would you do this? It would be helpful when creating a script using a service account and don’t want the authentication to remain too long after authentication.

And there is a maximum for this: 999999h. That’s about 114 years, give or take a month or so. More than long enough if needed (I know that sometimes we need a “forever” setting — I think this qualifies as long enough). I’m still trying to find out what the default time is but until then, hopefully these two little tidbits can help with any kubectl activities you may do.



Leave a Reply

Discover more from The Virtual Buddha: Learning How to Navigate the World

Subscribe now to keep reading and get access to the full archive.

Continue reading