1KUBERNETES(1)(kubernetes)                            KUBERNETES(1)(kubernetes)
2
3
4
5Eric Paris Jan 2015
6
7

NAME

9       kubectl  completion  -  Output  shell completion code for the specified
10       shell (bash, zsh, fish, or powershell)
11
12
13

SYNOPSIS

15       kubectl completion [OPTIONS]
16
17
18

DESCRIPTION

20       Output shell completion code for the specified shell (bash, zsh,  fish,
21       or powershell). The shell code must be evaluated to provide interactive
22       completion of kubectl commands.  This can be done by sourcing  it  from
23       the .bash_profile.
24
25
26       Detailed instructions on how to do this are available here:
27
28
29              for macOS:
30              https://kubernetes.io/docs/tasks/tools/install-kubectl-macos/#enable-shell-autocompletion
31
32              for linux:
33              https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/#enable-shell-autocompletion
34
35              for windows:
36              https://kubernetes.io/docs/tasks/tools/install-kubectl-windows/#enable-shell-autocompletion
37
38
39
40       Note  for zsh users: [1] zsh completions are only supported in versions
41       of zsh >= 5.2.
42
43
44

OPTIONS INHERITED FROM PARENT COMMANDS

46       --as=""      Username to impersonate for the operation. User could be a
47       regular user or a service account in a namespace.
48
49
50       --as-group=[]       Group  to  impersonate for the operation, this flag
51       can be repeated to specify multiple groups.
52
53
54       --as-uid=""      UID to impersonate for the operation.
55
56
57       --azure-container-registry-config=""      Path to the  file  containing
58       Azure container registry configuration information.
59
60
61       --cache-dir="/builddir/.kube/cache"      Default cache directory
62
63
64       --certificate-authority=""      Path to a cert file for the certificate
65       authority
66
67
68       --client-certificate=""      Path to a client certificate file for TLS
69
70
71       --client-key=""      Path to a client key file for TLS
72
73
74       --cluster=""      The name of the kubeconfig cluster to use
75
76
77       --context=""      The name of the kubeconfig context to use
78
79
80       --insecure-skip-tls-verify=false      If true, the server's certificate
81       will not be checked for validity. This will make your HTTPS connections
82       insecure
83
84
85       --kubeconfig=""      Path to the kubeconfig file to  use  for  CLI  re‐
86       quests.
87
88
89       --match-server-version=false        Require  server  version  to  match
90       client version
91
92
93       -n, --namespace=""      If present, the namespace scope  for  this  CLI
94       request
95
96
97       --password=""      Password for basic authentication to the API server
98
99
100       --profile="none"         Name   of   profile   to   capture.   One   of
101       (none|cpu|heap|goroutine|threadcreate|block|mutex)
102
103
104       --profile-output="profile.pprof"      Name of the  file  to  write  the
105       profile to
106
107
108       --request-timeout="0"       The length of time to wait before giving up
109       on a single server request. Non-zero values  should  contain  a  corre‐
110       sponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't time‐
111       out requests.
112
113
114       -s, --server=""      The address and port of the Kubernetes API server
115
116
117       --tls-server-name=""      Server name to  use  for  server  certificate
118       validation.  If  it  is  not provided, the hostname used to contact the
119       server is used
120
121
122       --token=""      Bearer token for authentication to the API server
123
124
125       --user=""      The name of the kubeconfig user to use
126
127
128       --username=""      Username for basic authentication to the API server
129
130
131       --version=false      Print version information and quit
132
133
134       --warnings-as-errors=false      Treat warnings received from the server
135       as errors and exit with a non-zero exit code
136
137
138

EXAMPLE

140                # Installing bash completion on macOS using homebrew
141                ## If running Bash 3.2 included with macOS
142                brew install bash-completion
143                ## or, if running Bash 4.1+
144                brew install bash-completion@2
145                ## If kubectl is installed via homebrew, this should start working immediately
146                ## If you've installed via other means, you may need add the completion to your completion directory
147                kubectl completion bash > $(brew --prefix)/etc/bash_completion.d/kubectl
148
149
150                # Installing bash completion on Linux
151                ## If bash-completion is not installed on Linux, install the 'bash-completion' package
152                ## via your distribution's package manager.
153                ## Load the kubectl completion code for bash into the current shell
154                source <(kubectl completion bash)
155                ## Write bash completion code to a file and source it from .bash_profile
156                kubectl completion bash > ~/.kube/completion.bash.inc
157                printf "
158                # Kubectl shell completion
159                source '$HOME/.kube/completion.bash.inc'
160                " >> $HOME/.bash_profile
161                source $HOME/.bash_profile
162
163                # Load the kubectl completion code for zsh[1] into the current shell
164                source <(kubectl completion zsh)
165                # Set the kubectl completion code for zsh[1] to autoload on startup
166                kubectl completion zsh > "${fpath[1]}/_kubectl"
167
168
169                # Load the kubectl completion code for fish[2] into the current shell
170                kubectl completion fish | source
171                # To load completions for each session, execute once:
172                kubectl completion fish > ~/.config/fish/completions/kubectl.fish
173
174                # Load the kubectl completion code for powershell into the current shell
175                kubectl completion powershell | Out-String | Invoke-Expression
176                # Set kubectl completion code for powershell to run on startup
177                ## Save completion code to a script and execute in the profile
178                kubectl completion powershell > $HOME\.kube\completion.ps1
179                Add-Content $PROFILE "$HOME\.kube\completion.ps1"
180                ## Execute completion code in the profile
181                Add-Content $PROFILE "if (Get-Command kubectl -ErrorAction SilentlyContinue) {
182                kubectl completion powershell | Out-String | Invoke-Expression
183                }"
184                ## Add completion code directly to the $PROFILE script
185                kubectl completion powershell >> $PROFILE
186
187
188
189

SEE ALSO

191       kubectl(1),
192
193
194

HISTORY

196       January  2015,  Originally compiled by Eric Paris (eparis at redhat dot
197       com) based on the kubernetes source material, but hopefully  they  have
198       been automatically generated since!
199
200
201
202Manuals                              User            KUBERNETES(1)(kubernetes)
Impressum