kubernetes bash completion

Wouldn’t it be great when we are using kubernetes and just tab to get a list of possible subcommands?

We have the extended facility to automatically tab and get the kubectl command suggestions, This feature is inbuilt into the kubectl and kubeadmin, All we need to just extract the script and enable it to the .bash_profile and source it. Lets do it as show below

[vamshi@workstation ~]$ kubectl completion bash > ~/.kube/k8s_bash_completion.sh
[vamshi@workstation ~]$ echo -e "\n#kubectl shell completion\nsource '$HOME/.kube/k8s_bash_completion.sh'\n" >> $HOME/.bash_profile
[vamshi@workstation ~]$ source $HOME/.bash_profile

Once you have successfully sourced the .bash_profie file.. type kubectl commands and keep tabbing all the way to get the suitable suggestions.

What is kubectl bash completion?

The kubectl completion script for Bash can be generated with the command kubectl completion bash . … However, the completion script depends on bash-completion, which means that you have to install this software first (you can test if you have bash-completion already installed by running type _init_completion ).

How do I create a completion in bash?

How to add bash auto completion in Ubuntu Linux

  1. Open the terminal application.
  2. Refresh package database on Ubuntu by running: sudo apt update.
  3. Install bash-completion package on Ubuntu by running: sudo apt install bash-completion.
  4. Log out and log in to verify that bash auto completion in Ubuntu Linux working properly.

What is kubectl auto completion?

Shell command-line completion allows you to quickly build your command without having to type every character. … The Kubernetes documentation provides great instructions on how to set it up for your development environment.

How do you use kubectl autocomplete?

To use shell autocompletion with kubectl simply press tab while writing out a command. For example we can type g and then press tab to autocomplete to get .

What is difference between Docker and Kubernetes?

A fundamental difference between Kubernetes and Docker is that Kubernetes is meant to run across a cluster while Docker runs on a single node. … Kubernetes pods—scheduling units that can contain one or more containers in the Kubernetes ecosystem—are distributed among nodes to provide high availability.

Is zsh better than bash?

It has many features like Bash but some features of Zsh make it better and improved than Bash, such as spelling correction, cd automation, better theme, and plugin support, etc. Linux users don’t need to install the Bash shell because it is installed by default with Linux distribution.

How does bash completion work?

The programmable completion feature in Bash permits typing a partial command, then pressing the [Tab] key to auto-complete the command sequence. [1] If multiple completions are possible, then [Tab] lists them all. Let’s see how it works. Tab completion also works for variables and path names.

How do I know if bash completion is installed?

If the autocomplete results contain directories only (no files), then Bash Completion is installed. If the autocomplete results include files, then Bash Completion is not installed.

What is complete command?

complete is a bash command used to perform the auto-complete action when the user hit the TAB key in a terminal. Calling just complete will list all the functions registered for auto-completion of commands or services options.

What is the difference between Minikube and Kubernetes?

Kubernetes is an open source orchestration system for Docker containers. … On the other hand, minikube is detailed as “Local Kubernetes engine”. It implements a local Kubernetes cluster on macOS, Linux, and Windows.

How do I know if kubectl is installed?

Install the kubectl Command Line

  1. Check that kubectl is correctly installed and configured by running the kubectl cluster-info command: kubectl cluster-info. …
  2. You can also verify the cluster by checking the nodes. …
  3. To get complete information on each node, run the following: kubectl describe node.

Leave a Comment