@@ -32,34 +32,73 @@ Using the latest version of kubectl helps avoid unforeseen issues.
32
32
33
33
1 . Download the latest release with the command:
34
34
35
- ```
36
- curl -LO "https://storage.googleapis.com/kubernetes- release/release/ $(curl -s https://storage.googleapis.com/kubernetes-release /release/stable.txt)/bin/linux/amd64/kubectl"
37
- ```
35
+ ``` bash
36
+ curl -LO " https://dl.k8s.io/ release/$( curl -L - s https://dl.k8s.io /release/stable.txt) /bin/linux/amd64/kubectl"
37
+ ```
38
38
39
- To download a specific version, replace the `$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)` portion of the command with the specific version.
39
+ {{< note >}}
40
+ To download a specific version, replace the ` $(curl -L -s https://dl.k8s.io/release/stable.txt) ` portion of the command with the specific version.
40
41
41
- For example, to download version {{< param "fullversion" >}} on Linux, type:
42
-
43
- ```
44
- curl -LO https://storage.googleapis.com/kubernetes-release/release/{{< param "fullversion" >}}/bin/linux/amd64/kubectl
45
- ```
42
+ For example, to download version {{< param "fullversion" >}} on Linux, type:
46
43
47
- 2. Make the kubectl binary executable.
44
+ ``` bash
45
+ curl -LO https://dl.k8s.io/release/{{< param " fullversion" > }}/bin/linux/amd64/kubectl
46
+ ```
47
+ {{< /note >}}
48
48
49
- ```
50
- chmod +x ./kubectl
51
- ```
49
+ 1 . Validate the binary (optional)
52
50
53
- 3. Move the binary in to your PATH.
51
+ Download the kubectl checksum file:
54
52
55
- ```
56
- sudo mv ./kubectl /usr/local/bin/kubectl
57
- ```
58
- 4. Test to ensure the version you installed is up-to-date:
53
+ ``` bash
54
+ curl -LO " https://dl.k8s.io/$( curl -L -s https://dl.k8s.io/release/stable.txt) /bin/linux/amd64/kubectl.sha256"
55
+ ```
59
56
60
- ```
61
- kubectl version --client
62
- ```
57
+ Validate the kubectl binary against the checksum file:
58
+
59
+ ``` bash
60
+ echo " $( < kubectl.sha256) kubectl" | sha256sum --check
61
+ ```
62
+
63
+ If valid, the output is:
64
+
65
+ ``` bash
66
+ kubectl: OK
67
+ ```
68
+
69
+ If the check fails, ` sha256 ` exits with nonzero status and prints output similar to:
70
+
71
+ ``` bash
72
+ kubectl: FAILED
73
+ sha256sum: WARNING: 1 computed checksum did NOT match
74
+ ```
75
+
76
+ {{< note >}}
77
+ Download the same version of the binary and checksum.
78
+ {{< /note >}}
79
+
80
+ 1 . Install kubectl
81
+
82
+ ``` bash
83
+ sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
84
+ ```
85
+
86
+ {{< note >}}
87
+ If you do not have root access on the target system, you can still install kubectl to the ` ~/.local/bin ` directory:
88
+
89
+ ``` bash
90
+ mkdir -p ~ /.local/bin/kubectl
91
+ mv ./kubectl ~ /.local/bin/kubectl
92
+ # and then add ~/.local/bin/kubectl to $PATH
93
+ ```
94
+
95
+ {{< /note >}}
96
+
97
+ 1 . Test to ensure the version you installed is up-to-date:
98
+
99
+ ``` bash
100
+ kubectl version --client
101
+ ```
63
102
64
103
### Install using native package management
65
104
@@ -120,30 +159,65 @@ kubectl version --client
120
159
1 . Download the latest release:
121
160
122
161
``` bash
123
- curl -LO " https://storage.googleapis.com/kubernetes- release/release/ $( curl -s https://storage.googleapis.com/kubernetes-release /release/stable.txt) /bin/darwin/amd64/kubectl"
162
+ curl -LO " https://dl.k8s.io/ release/$( curl -L - s https://dl.k8s.io /release/stable.txt) /bin/darwin/amd64/kubectl"
124
163
```
125
164
126
- To download a specific version, replace the ` $(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt) ` portion of the command with the specific version.
165
+ {{< note >}}
166
+ To download a specific version, replace the ` $(curl -L -s https://dl.k8s.io/release/stable.txt) ` portion of the command with the specific version.
127
167
128
168
For example, to download version {{< param "fullversion" >}} on macOS, type:
129
169
130
170
``` bash
131
- curl -LO https://storage.googleapis.com/kubernetes-release/release/{{< param " fullversion" > }}/bin/darwin/amd64/kubectl
171
+ curl -LO https://dl.k8s.io/release/{{< param " fullversion" > }}/bin/darwin/amd64/kubectl
172
+ ```
173
+
174
+ {{< /note >}}
175
+
176
+ 1 . Validate the binary (optional)
177
+
178
+ Download the kubectl checksum file:
179
+
180
+ ``` bash
181
+ curl -LO " https://dl.k8s.io/$( curl -L -s https://dl.k8s.io/release/stable.txt) /bin/darwin/amd64/kubectl.sha256"
132
182
```
133
183
134
- Make the kubectl binary executable.
184
+ Validate the kubectl binary against the checksum file:
185
+
186
+ ``` bash
187
+ echo " $( < kubectl.sha256) kubectl" | shasum -a 256 --check
188
+ ```
189
+
190
+ If valid, the output is:
191
+
192
+ ``` bash
193
+ kubectl: OK
194
+ ```
195
+
196
+ If the check fails, ` shasum ` exits with nonzero status and prints output similar to:
197
+
198
+ ``` bash
199
+ kubectl: FAILED
200
+ shasum: WARNING: 1 computed checksum did NOT match
201
+ ```
202
+
203
+ {{< note >}}
204
+ Download the same version of the binary and checksum.
205
+ {{< /note >}}
206
+
207
+ 1 . Make the kubectl binary executable.
135
208
136
209
``` bash
137
210
chmod +x ./kubectl
138
211
```
139
212
140
- 3 . Move the binary in to your PATH.
213
+ 1 . Move the kubectl binary to a file location on your system ` PATH ` .
141
214
142
215
``` bash
143
- sudo mv ./kubectl /usr/local/bin/kubectl
216
+ sudo mv ./kubectl /usr/local/bin/kubectl && \
217
+ sudo chown root: /usr/local/bin/kubectl
144
218
```
145
219
146
- 4 . Test to ensure the version you installed is up-to-date:
220
+ 1 . Test to ensure the version you installed is up-to-date:
147
221
148
222
``` bash
149
223
kubectl version --client
@@ -165,7 +239,7 @@ If you are on macOS and using [Homebrew](https://brew.sh/) package manager, you
165
239
brew install kubernetes-cli
166
240
```
167
241
168
- 2 . Test to ensure the version you installed is up-to-date:
242
+ 1 . Test to ensure the version you installed is up-to-date:
169
243
170
244
``` bash
171
245
kubectl version --client
@@ -182,7 +256,7 @@ If you are on macOS and using [Macports](https://macports.org/) package manager,
182
256
sudo port install kubectl
183
257
```
184
258
185
- 2 . Test to ensure the version you installed is up-to-date:
259
+ 1 . Test to ensure the version you installed is up-to-date:
186
260
187
261
``` bash
188
262
kubectl version --client
@@ -192,47 +266,72 @@ If you are on macOS and using [Macports](https://macports.org/) package manager,
192
266
193
267
### Install kubectl binary with curl on Windows
194
268
195
- 1 . Download the latest release {{< param "fullversion" >}} from [ this link ] (https://storage.googleapis.com/kubernetes-release /release/{{ < param "fullversion" >}}/bin/windows/amd64/kubectl.exe).
269
+ 1 . Download the [ latest release {{< param "fullversion" >}}] (https://dl.k8s.io /release/{{ < param "fullversion" >}}/bin/windows/amd64/kubectl.exe).
196
270
197
271
Or if you have ` curl ` installed, use this command:
198
272
199
- ``` bash
200
- curl -LO https://storage.googleapis.com/kubernetes-release /release/{{< param " fullversion" > }}/bin/windows/amd64/kubectl.exe
273
+ ``` powershell
274
+ curl -LO https://dl.k8s.io /release/{{< param "fullversion" >}}/bin/windows/amd64/kubectl.exe
201
275
```
202
276
203
- To find out the latest stable version (for example, for scripting), take a look at [ https://storage.googleapis.com/kubernetes-release/release/stable.txt ] ( https://storage.googleapis.com/kubernetes-release/release/stable.txt ) .
277
+ {{< note >}}
278
+ To find out the latest stable version (for example, for scripting), take a look at [ https://dl.k8s.io/release/stable.txt ] ( https://dl.k8s.io/release/stable.txt ) .
279
+ {{< /note >}}
204
280
205
- 2 . Add the binary in to your PATH.
281
+ 1 . Validate the binary (optional)
206
282
207
- 3 . Test to ensure the version of ` kubectl ` is the same as downloaded :
283
+ Download the kubectl checksum file :
208
284
209
- ``` bash
285
+ ``` powershell
286
+ curl -LO https://dl.k8s.io/{{< param "fullversion" >}}/bin/windows/amd64/kubectl.exe.sha256
287
+ ```
288
+
289
+ Validate the kubectl binary against the checksum file:
290
+
291
+ - Using Command Prompt to manually compare ` CertUtil ` 's output to the checksum file downloaded:
292
+
293
+ ``` cmd
294
+ CertUtil -hashfile kubectl.exe SHA256
295
+ type kubectl.exe.sha256
296
+ ```
297
+
298
+ - Using PowerShell to automate the verification using the `-eq` operator to get a `True` or `False` result:
299
+
300
+ ```powershell
301
+ $($(CertUtil -hashfile .\kubectl.exe SHA256)[1] -replace " ", "") -eq $(type .\kubectl.exe.sha256)
302
+ ```
303
+
304
+ 1. Add the binary in to your `PATH`.
305
+
306
+ 1. Test to ensure the version of `kubectl` is the same as downloaded:
307
+
308
+ ```cmd
210
309
kubectl version --client
211
310
```
212
311
213
312
{{< note >}}
214
- [ Docker Desktop for Windows] ( https://docs.docker.com/docker-for-windows/#kubernetes ) adds its own version of ` kubectl ` to PATH.
215
- If you have installed Docker Desktop before, you may need to place your PATH entry before the one added by the Docker Desktop installer or remove the Docker Desktop's ` kubectl ` .
313
+ [ Docker Desktop for Windows] ( https://docs.docker.com/docker-for-windows/#kubernetes ) adds its own version of ` kubectl ` to ` PATH ` .
314
+ If you have installed Docker Desktop before, you may need to place your ` PATH ` entry before the one added by the Docker Desktop installer or remove the Docker Desktop's ` kubectl ` .
216
315
{{< /note >}}
217
316
218
- ### Install with Powershell from PSGallery
317
+ ### Install with PowerShell from PSGallery
219
318
220
- If you are on Windows and using [ Powershell Gallery] ( https://www.powershellgallery.com/ ) package manager, you can install and update kubectl with Powershell .
319
+ If you are on Windows and using the [ PowerShell Gallery] ( https://www.powershellgallery.com/ ) package manager, you can install and update kubectl with PowerShell .
221
320
222
321
1 . Run the installation commands (making sure to specify a ` DownloadLocation ` ):
223
322
224
323
``` powershell
225
324
Install-Script -Name 'install-kubectl' -Scope CurrentUser -Force
226
325
install-kubectl.ps1 [-DownloadLocation <path>]
227
- ```
326
+ ```
228
327
229
328
{{< note >}}
230
- If you do not specify a `DownloadLocation`, `kubectl` will be installed in the user's temp Directory.
329
+ If you do not specify a ` DownloadLocation ` , ` kubectl ` will be installed in the user's ` temp ` Directory.
231
330
{{< /note >}}
232
331
233
332
The installer creates ` $HOME/.kube ` and instructs it to create a config file.
234
333
235
- 2 . Test to ensure the version you installed is up-to-date:
334
+ 1 . Test to ensure the version you installed is up-to-date:
236
335
237
336
``` powershell
238
337
kubectl version --client
@@ -260,32 +359,32 @@ Updating the installation is performed by rerunning the two commands listed in s
260
359
{{< /tabs >}}
261
360
262
361
263
- 2 . Test to ensure the version you installed is up-to-date:
362
+ 1 . Test to ensure the version you installed is up-to-date:
264
363
265
364
``` powershell
266
365
kubectl version --client
267
366
```
268
367
269
- 3 . Navigate to your home directory:
368
+ 1 . Navigate to your home directory:
270
369
271
370
``` powershell
272
371
# If you're using cmd.exe, run: cd %USERPROFILE%
273
372
cd ~
274
373
```
275
374
276
- 4 . Create the ` .kube ` directory:
375
+ 1 . Create the ` .kube ` directory:
277
376
278
377
``` powershell
279
378
mkdir .kube
280
379
```
281
380
282
- 5 . Change to the ` .kube ` directory you just created:
381
+ 1 . Change to the ` .kube ` directory you just created:
283
382
284
383
``` powershell
285
384
cd .kube
286
385
```
287
386
288
- 6 . Configure kubectl to use a remote Kubernetes cluster:
387
+ 1 . Configure kubectl to use a remote Kubernetes cluster:
289
388
290
389
``` powershell
291
390
New-Item config -type file
@@ -301,13 +400,13 @@ You can install kubectl as part of the Google Cloud SDK.
301
400
302
401
1 . Install the [ Google Cloud SDK] ( https://cloud.google.com/sdk/ ) .
303
402
304
- 2 . Run the ` kubectl ` installation command:
403
+ 1 . Run the ` kubectl ` installation command:
305
404
306
405
``` shell
307
406
gcloud components install kubectl
308
407
```
309
408
310
- 3 . Test to ensure the version you installed is up-to-date:
409
+ 1 . Test to ensure the version you installed is up-to-date:
311
410
312
411
``` shell
313
412
kubectl version --client
@@ -385,11 +484,13 @@ You now need to ensure that the kubectl completion script gets sourced in all yo
385
484
``` bash
386
485
echo ' source <(kubectl completion bash)' >> ~/.bashrc
387
486
```
487
+
388
488
- Add the completion script to the ` /etc/bash_completion.d ` directory:
389
489
390
490
``` bash
391
491
kubectl completion bash > /etc/bash_completion.d/kubectl
392
492
```
493
+
393
494
If you have an alias for kubectl, you can extend shell completion to work with that alias:
394
495
395
496
``` bash
@@ -470,7 +571,6 @@ You now have to ensure that the kubectl completion script gets sourced in all yo
470
571
471
572
``` bash
472
573
echo ' source <(kubectl completion bash)' >> ~/.bash_profile
473
-
474
574
```
475
575
476
576
- Add the completion script to the ` /usr/local/etc/bash_completion.d` directory:
0 commit comments