Introduction to kubectlkubectl is a command line tool for operating k8s clusters. It is installed on the master node of k8s. kubectl looks for a file named config in the $HOME/.kube directory. You can specify other kubeconfig files by setting the Kubeconfig environment variable or setting --kubeconfig. Kubectl can add, delete, modify and query various resources in the k8s cluster by interacting with the apiserver. Next, we will introduce the kubectl syntax, command line operations, and common examples. Details on the command, its arguments, and its subcommands can be found in the kubectl reference documentation. kubectl syntaxThe kubectl syntax format is as follows, which can be executed on the master node of the k8s cluster: kubectl [command] [TYPE] [NAME] [flags] 1 Introduction Automatic command completion is a very useful feature, especially when the command has a lot of parameters. Apparently, 2 View the currently used shell Check $ cat /etc/shells # List of acceptable shells for chpass(1). # Ftpd will not allow users to connect who are not using # one of these shells. /bin/bash /bin/csh /bin/dash /bin/ksh /bin/sh /bin/tcsh /bin/zsh Several ways to view the current # View environment variables$ echo $SHELL /bin/bash # Print process name $ echo $0 -bash # View the process $ ps PID TTY TIME CMD 66162 ttys005 0:00.68 -bash # Directly type a non-existent command, the error message will show $ pkslow -bash: pkslow: command not found 3 Add autocompletion for kubectl Use the command Check the $ bash -version GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin19) Copyright (C) 2007 Free Software Foundation, Inc. Install brew install bash-completion Copy kubectl completion bash to the completion directory: $ kubectl completion bash > $(brew --prefix)/etc/bash_completion.d/kubectl See the statements to add to $ brew info bash-completion ==> Caveats Add the following line to your ~/.bash_profile: [[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh" Bash completion has been installed to: /usr/local/etc/bash_completion.d Just add the above After completing the above steps, enable $ kubectl get se secrets serviceaccounts services 4 Add auto-completion for docker commandsWith the previous foundation, it is much simpler: $ cd /usr/local/etc/bash_completion.d $ ln -s /Applications/Docker.app/Contents/Resources/etc/docker.bash-completion $ ln -s /Applications/Docker.app/Contents/Resources/etc/docker-machine.bash-completion $ ln -s /Applications/Docker.app/Contents/Resources/etc/docker-compose.bash-completion Reopen a terminal and you can use it. 5 ConclusionFor complex commands, it is still necessary to add automatic command completion, which can improve efficiency and reduce errors. This is the end of this article about adding auto-completion commands for docker and kubectl on Mac. For more information about auto-completion commands for docker and kubectl, please search previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: How to query data from multiple unrelated tables and paging in Mysql
>>: How to Apply for Web Design Jobs
Select the category selection. After testing, IE ...
This article uses an example to describe how to r...
MySQL master-slave configuration and principle, f...
One demand Generally speaking, a company has mult...
This article uses examples to explain the concept...
1. Hot deployment: It means redeploying the entir...
1.html <div class="loginbody"> &l...
<br />Related articles: 9 practical tips for...
This article example shares the specific code of ...
Create an HTML page with an unordered list of at l...
The layout of text has some formatting requiremen...
Docker-compose deployment configuration jenkins 1...
When using MySQL 5.7, you will find that garbled ...
Copy code The code is as follows: <iframe id=&...
I have seen many relevant tutorials on the Intern...