How to Enable Tab Completion for the Kubectl Command

Introduction

The shell is a bash group, but if it is bash, pressing a tab will complete the command. The kubectl command also completes in the shell, but the subcommands do not.

kubectl get pod is fine, but describe is a hassle. When I looked it up there, there was a function that complemented subcommands with tabs, so I tried it.

Let’s start

Setting environment variables

Edit file .bashrc and add the following line

source <(kubectl completion bash)

Reflect by dot execution.

root@vagrant:/home/vagrant# . .bashrc

Operation check

 by the author.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Maciej

Maciej

DevOps Consultant. I’m strongly focused on automation, security, and reliability.