1KUBERNETES(1)(kubernetes) KUBERNETES(1)(kubernetes)
2
3
4
5Eric Paris Jan 2015
6
7
9 kubectl completion - Output shell completion code for the specified
10 shell (bash, zsh, fish, or powershell)
11
12
13
15 kubectl completion [OPTIONS]
16
17
18
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-
31 shell-autocompletion
32
33
34 for linux:
35 https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/#enable-
36 shell-autocompletion
37
38
39 for windows:
40 https://kubernetes.io/docs/tasks/tools/install-kubectl-windows/#en‐
41 able-shell-autocompletion
42
43
44 Note for zsh users: [1] zsh completions are only supported in versions
45 of zsh >= 5.2.
46
47
48
50 --as="" Username to impersonate for the operation. User could be a
51 regular user or a service account in a namespace.
52
53
54 --as-group=[] Group to impersonate for the operation, this flag
55 can be repeated to specify multiple groups.
56
57
58 --as-uid="" UID to impersonate for the operation.
59
60
61 --azure-container-registry-config="" Path to the file containing
62 Azure container registry configuration information.
63
64
65 --cache-dir="/builddir/.kube/cache" Default cache directory
66
67
68 --certificate-authority="" Path to a cert file for the certificate
69 authority
70
71
72 --client-certificate="" Path to a client certificate file for TLS
73
74
75 --client-key="" Path to a client key file for TLS
76
77
78 --cluster="" The name of the kubeconfig cluster to use
79
80
81 --context="" The name of the kubeconfig context to use
82
83
84 --disable-compression=false If true, opt-out of response compres‐
85 sion for all requests to the server
86
87
88 --insecure-skip-tls-verify=false If true, the server's certificate
89 will not be checked for validity. This will make your HTTPS connections
90 insecure
91
92
93 --kubeconfig="" Path to the kubeconfig file to use for CLI re‐
94 quests.
95
96
97 --match-server-version=false Require server version to match
98 client version
99
100
101 -n, --namespace="" If present, the namespace scope for this CLI
102 request
103
104
105 --password="" Password for basic authentication to the API server
106
107
108 --profile="none" Name of profile to capture. One of
109 (none|cpu|heap|goroutine|threadcreate|block|mutex)
110
111
112 --profile-output="profile.pprof" Name of the file to write the
113 profile to
114
115
116 --request-timeout="0" The length of time to wait before giving up
117 on a single server request. Non-zero values should contain a corre‐
118 sponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't time‐
119 out requests.
120
121
122 -s, --server="" The address and port of the Kubernetes API server
123
124
125 --tls-server-name="" Server name to use for server certificate
126 validation. If it is not provided, the hostname used to contact the
127 server is used
128
129
130 --token="" Bearer token for authentication to the API server
131
132
133 --user="" The name of the kubeconfig user to use
134
135
136 --username="" Username for basic authentication to the API server
137
138
139 --version=false Print version information and quit
140
141
142 --warnings-as-errors=false Treat warnings received from the server
143 as errors and exit with a non-zero exit code
144
145
146
148 # Installing bash completion on macOS using homebrew
149 ## If running Bash 3.2 included with macOS
150 brew install bash-completion
151 ## or, if running Bash 4.1+
152 brew install bash-completion@2
153 ## If kubectl is installed via homebrew, this should start working immediately
154 ## If you've installed via other means, you may need add the completion to your completion directory
155 kubectl completion bash > $(brew --prefix)/etc/bash_completion.d/kubectl
156
157
158 # Installing bash completion on Linux
159 ## If bash-completion is not installed on Linux, install the 'bash-completion' package
160 ## via your distribution's package manager.
161 ## Load the kubectl completion code for bash into the current shell
162 source <(kubectl completion bash)
163 ## Write bash completion code to a file and source it from .bash_profile
164 kubectl completion bash > ~/.kube/completion.bash.inc
165 printf "
166 # Kubectl shell completion
167 source '$HOME/.kube/completion.bash.inc'
168 " >> $HOME/.bash_profile
169 source $HOME/.bash_profile
170
171 # Load the kubectl completion code for zsh[1] into the current shell
172 source <(kubectl completion zsh)
173 # Set the kubectl completion code for zsh[1] to autoload on startup
174 kubectl completion zsh > "${fpath[1]}/_kubectl"
175
176
177 # Load the kubectl completion code for fish[2] into the current shell
178 kubectl completion fish | source
179 # To load completions for each session, execute once:
180 kubectl completion fish > ~/.config/fish/completions/kubectl.fish
181
182 # Load the kubectl completion code for powershell into the current shell
183 kubectl completion powershell | Out-String | Invoke-Expression
184 # Set kubectl completion code for powershell to run on startup
185 ## Save completion code to a script and execute in the profile
186 kubectl completion powershell > $HOME\.kube\completion.ps1
187 Add-Content $PROFILE "$HOME\.kube\completion.ps1"
188 ## Execute completion code in the profile
189 Add-Content $PROFILE "if (Get-Command kubectl -ErrorAction SilentlyContinue) {
190 kubectl completion powershell | Out-String | Invoke-Expression
191 }"
192 ## Add completion code directly to the $PROFILE script
193 kubectl completion powershell >> $PROFILE
194
195
196
197
199 kubectl(1),
200
201
202
204 January 2015, Originally compiled by Eric Paris (eparis at redhat dot
205 com) based on the kubernetes source material, but hopefully they have
206 been automatically generated since!
207
208
209
210Manuals User KUBERNETES(1)(kubernetes)