Skip to content

Commit 1461288

Browse files
authored
Merge pull request #35317 from yanrongshi/zh-cn]sync-install-kubectl-windows
[zh-cn]sync install-kubectl-windows.md
2 parents f7b21a5 + 11671df commit 1461288

File tree

1 file changed

+66
-60
lines changed

1 file changed

+66
-60
lines changed

content/zh-cn/docs/tasks/tools/install-kubectl-windows.md

Lines changed: 66 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ card:
77
weight: 20
88
title: Windows 安装 kubectl
99
---
10-
<!--
10+
<!--
1111
reviewers:
1212
- mikedanese
1313
title: Install and Set Up kubectl on Windows
@@ -21,7 +21,7 @@ card:
2121

2222
## {{% heading "prerequisites" %}}
2323

24-
<!--
24+
<!--
2525
You must use a kubectl version that is within one minor version difference of your cluster. For example, a v{{< skew currentVersion >}} client can communicate with v{{< skew currentVersionAddMinor -1 >}}, v{{< skew currentVersionAddMinor 0 >}}, and v{{< skew currentVersionAddMinor 1 >}} control planes.
2626
Using the latest compatible version of kubectl helps avoid unforeseen issues.
2727
-->
@@ -30,63 +30,68 @@ kubectl 版本和集群版本之间的差异必须在一个小版本号内。
3030
v{{< skew currentVersionAddMinor 0 >}} 和 v{{< skew currentVersionAddMinor 1 >}} 版本的控制面通信。
3131
用最新兼容版的 kubectl 有助于避免不可预见的问题。
3232

33-
<!--
33+
<!--
3434
## Install kubectl on Windows
35-
-->
36-
## 在 Windows 上安装 kubectl {#install-kubectl-on-windows}
3735
38-
<!--
3936
The following methods exist for installing kubectl on Windows:
4037
-->
41-
在 Windows 系统中安装 kubectl 有如下几种方法:
4238

39+
## 在 Windows 上安装 kubectl {#install-kubectl-on-windows}
40+
41+
在 Windows 系统中安装 kubectl 有如下几种方法:
42+
<!--
43+
- [Install kubectl binary with curl on Windows](#install-kubectl-binary-with-curl-on-windows)
44+
- [Install on Windows using Chocolatey or Scoop](#install-on-windows-using-chocolatey-or-scoop)
45+
-->
4346
- [用 curl 在 Windows 上安装 kubectl](#install-kubectl-binary-with-curl-on-windows)
4447
- [在 Windows 上用 Chocolatey 或 Scoop 安装](#install-on-windows-using-chocolatey-or-scoop)
4548

46-
<!--
49+
<!--
4750
### Install kubectl binary with curl on Windows
4851
-->
52+
4953
### 用 curl 在 Windows 上安装 kubectl {#install-kubectl-binary-with-curl-on-windows}
5054

51-
<!--
55+
<!--
5256
1. Download the [latest release {{< param "fullversion" >}}](https://dl.k8s.io/release/{{< param "fullversion" >}}/bin/windows/amd64/kubectl.exe).
53-
54-
Or if you have `curl` installed, use this command:
5557
-->
5658
1. 下载 [最新发行版 {{< param "fullversion" >}}](https://dl.k8s.io/release/{{< param "fullversion" >}}/bin/windows/amd64/kubectl.exe)。
5759

58-
如果你已安装了 `curl`,也可以使用此命令:
60+
<!--
61+
Or if you have `curl` installed, use this command:
62+
-->
63+
如果你已安装了 `curl`,也可以使用此命令:
5964

6065
```powershell
6166
curl -LO "https://dl.k8s.io/release/{{< param "fullversion" >}}/bin/windows/amd64/kubectl.exe"
6267
```
6368

64-
<!--
65-
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).
66-
-->
6769
{{< note >}}
70+
<!--
71+
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).
72+
-->
6873
要想找到最新稳定的版本(例如:为了编写脚本),可以看看这里 [https://dl.k8s.io/release/stable.txt](https://dl.k8s.io/release/stable.txt)
6974
{{< /note >}}
7075

71-
<!--
72-
1. Validate the binary (optional)
76+
<!--
77+
1. Validate the binary (optional)
7378
74-
Download the `kubectl` checksum file:
75-
-->
76-
1. 验证该可执行文件(可选步骤)
79+
Download the `kubectl` checksum file:
80+
-->
81+
2. 验证该可执行文件(可选步骤)
7782

7883
下载 `kubectl` 校验和文件:
7984

8085
```powershell
8186
curl -LO "https://dl.k8s.io/{{< param "fullversion" >}}/bin/windows/amd64/kubectl.exe.sha256"
8287
```
8388

84-
<!--
89+
<!--
8590
Validate the `kubectl` binary against the checksum file:
8691
-->
8792
基于校验和文件,验证 `kubectl` 的可执行文件:
8893

89-
<!--
94+
<!--
9095
- Using Command Prompt to manually compare `CertUtil`'s output to the checksum file downloaded:
9196
-->
9297
- 在命令行环境中,手工对比 `CertUtil` 命令的输出与校验和文件:
@@ -96,7 +101,7 @@ The following methods exist for installing kubectl on Windows:
96101
type kubectl.exe.sha256
97102
```
98103
99-
<!--
104+
<!--
100105
- Using PowerShell to automate the verification using the `-eq` operator to get a `True` or `False` result:
101106
-->
102107
- 用 PowerShell 自动验证,用运算符 `-eq` 来直接取得 `True` 或 `False` 的结果:
@@ -105,25 +110,25 @@ The following methods exist for installing kubectl on Windows:
105110
$($(CertUtil -hashfile .\kubectl.exe SHA256)[1] -replace " ", "") -eq $(type .\kubectl.exe.sha256)
106111
```
107112
108-
<!--
109-
1. Append or prepend the `kubectl` binary folder to your `PATH` environment variable.
113+
<!--
114+
1. Append or prepend the `kubectl` binary folder to your `PATH` environment variable.
110115
111-
1. Test to ensure the version of `kubectl` is the same as downloaded:
112-
Or use this for detailed view of version:
113-
-->
114-
1. 将 `kubectl` 二进制文件夹追加或插入到你的 `PATH` 环境变量中。
116+
1. Test to ensure the version of `kubectl` is the same as downloaded:
117+
-->
115118
116-
1. 测试一下,确保此 `kubectl` 的版本和期望版本一致:
119+
3. 将 `kubectl` 二进制文件夹追加或插入到你的 `PATH` 环境变量中。
120+
121+
4. 测试一下,确保此 `kubectl` 的版本和期望版本一致:
117122
118123
```cmd
119124
kubectl version --client
120125
```
121126
或者使用下面命令来查看版本的详细信息:
127+
122128
```cmd
123129
kubectl version --client --output=yaml
124130
```
125131

126-
127132
<!--
128133
[Docker Desktop for Windows](https://docs.docker.com/docker-for-windows/#kubernetes) adds its own version of `kubectl` to `PATH`.
129134
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`.
@@ -135,12 +140,12 @@ If you have installed Docker Desktop before, you may need to place your `PATH` e
135140
或者直接删掉 Docker Desktop 的 `kubectl`
136141
{{< /note >}}
137142

138-
<!--
143+
<!--
139144
### Install on Windows using Chocolatey or Scoop
140145
-->
141146
### 在 Windows 上用 Chocolatey 或 Scoop 安装 {#install-on-windows-using-chocolatey-or-scoop}
142147

143-
<!--
148+
<!--
144149
1. To install kubectl on Windows you can use either [Chocolatey](https://chocolatey.org) package manager or [Scoop](https://scoop.sh) command-line installer.
145150
-->
146151
1. 要在 Windows 上安装 kubectl,你可以使用包管理器 [Chocolatey](https://chocolatey.org)
@@ -159,49 +164,47 @@ If you have installed Docker Desktop before, you may need to place your `PATH` e
159164
{{% /tab %}}
160165
{{< /tabs >}}
161166

162-
<!--
163-
1. Test to ensure the version you installed is up-to-date:
164-
-->
167+
168+
<!--
169+
1. Test to ensure the version you installed is up-to-date:
170+
-->
165171
2. 测试一下,确保安装的是最新版本:
166172

167173
```powershell
168174
kubectl version --client
169175
```
170176

171-
<!--
172-
1. Navigate to your home directory:
173-
-->
177+
<!--
178+
1. Navigate to your home directory:
179+
-->
174180
3. 导航到你的 home 目录:
175181

176-
<!--
177-
# If you're using cmd.exe, run: cd %USERPROFILE%
178-
-->
179182
```powershell
180183
# 当你用 cmd.exe 时,则运行: cd %USERPROFILE%
181184
cd ~
182185
```
183186

184-
<!--
185-
1. Create the `.kube` directory:
186-
-->
187+
<!--
188+
1. Create the `.kube` directory:
189+
-->
187190
4. 创建目录 `.kube`
188191

189192
```powershell
190193
mkdir .kube
191194
```
192195

193-
<!--
194-
1. Change to the `.kube` directory you just created:
195-
-->
196+
<!--
197+
1. Change to the `.kube` directory you just created:
198+
-->
196199
5. 切换到新创建的目录 `.kube`
197200

198201
```powershell
199202
cd .kube
200203
```
201204

202-
<!--
203-
1. Configure kubectl to use a remote Kubernetes cluster:
204-
-->
205+
<!--
206+
1. Configure kubectl to use a remote Kubernetes cluster:
207+
-->
205208
6. 配置 kubectl,以接入远程的 Kubernetes 集群:
206209

207210
```powershell
@@ -260,11 +263,12 @@ kubectl 为 Bash、Zsh、Fish 和 PowerShell 提供自动补全功能,可以
260263

261264
<!--
262265
1. Validate the binary (optional)
263-
264-
Download the `kubectl-convert` checksum file:
265266
-->
266-
1. 验证该可执行文件(可选步骤)
267-
267+
2. 验证该可执行文件(可选步骤)
268+
269+
<!--
270+
Download the `kubectl-convert` checksum file:
271+
-->
268272
下载 `kubectl-convert` 校验和文件:
269273

270274
```powershell
@@ -273,11 +277,12 @@ kubectl 为 Bash、Zsh、Fish 和 PowerShell 提供自动补全功能,可以
273277

274278
<!--
275279
Validate the `kubectl-convert` binary against the checksum file:
280+
-->
281+
基于校验和验证 `kubectl-convert` 的可执行文件:
276282

283+
<!--
277284
- Using Command Prompt to manually compare `CertUtil`'s output to the checksum file downloaded:
278285
-->
279-
基于校验和,验证 `kubectl-convert` 的可执行文件:
280-
281286
- 用提示的命令对 `CertUtil` 的输出和下载的校验和文件进行手动比较。
282287

283288
```cmd
@@ -288,20 +293,21 @@ kubectl 为 Bash、Zsh、Fish 和 PowerShell 提供自动补全功能,可以
288293
<!--
289294
- Using PowerShell to automate the verification using the `-eq` operator to get a `True` or `False` result:
290295
-->
296+
291297
- 使用 PowerShell `-eq` 操作使验证自动化,获得 `True` 或者 `False` 的结果:
292298
293299
```powershell
294300
$($(CertUtil -hashfile .\kubectl-convert.exe SHA256)[1] -replace " ", "") -eq $(type .\kubectl-convert.exe.sha256)
295301
```
296302
297303
<!--
298-
1. Append or prepend the `kubectl-convert` binary folder to your `PATH` environment variable.
304+
1. Append or prepend the `kubectl-convert` binary folder to your `PATH` environment variable.
299305
300306
1. Verify plugin is successfully installed
301307
-->
302-
1. 将 `kubectl-convert` 二进制文件夹附加或添加到你的 `PATH` 环境变量中。
308+
3. 将 `kubectl-convert` 二进制文件夹附加或添加到你的 `PATH` 环境变量中。
303309
304-
1. 验证插件是否安装成功
310+
4. 验证插件是否安装成功
305311
306312
```shell
307313
kubectl convert --help

0 commit comments

Comments
 (0)