Skip to content

Commit 5faa255

Browse files
author
zhuzhenghao
committed
[zh-cn] Resync install-kubectl-macos.md
1 parent 555a2ae commit 5faa255

File tree

1 file changed

+62
-36
lines changed

1 file changed

+62
-36
lines changed

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

Lines changed: 62 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ weight: 10
55
card:
66
name: tasks
77
weight: 20
8-
title: 在 macOS 系统上安装 kubectl
8+
title: 在 macOS 系统上安装 kubectl
99
---
1010
<!--
1111
reviewers:
@@ -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,31 +30,40 @@ kubectl 版本和集群之间的差异必须在一个小版本号之内。
3030
v{{< skew currentVersionAddMinor 0 >}} 和 v{{< skew currentVersionAddMinor 1 >}} 版本的控制面通信。
3131
用最新兼容版本的 kubectl 有助于避免不可预见的问题。
3232

33-
<!--
33+
<!--
3434
## Install kubectl on macOS
3535
-->
3636
## 在 macOS 系统上安装 kubectl {#install-kubectl-on-macos}
3737

38-
<!--
38+
<!--
3939
The following methods exist for installing kubectl on macOS:
4040
-->
4141
在 macOS 系统上安装 kubectl 有如下方法:
4242

4343
<!--
44-
- [Install kubectl binary with curl on macOS](#install-kubectl-binary-with-curl-on-macos)
45-
- [Install with Homebrew on macOS](#install-with-homebrew-on-macos)
46-
- [Install with Macports on macOS](#install-with-macports-on-macos)
44+
- [Install kubectl on macOS](#install-kubectl-on-macos)
45+
- [Install kubectl binary with curl on macOS](#install-kubectl-binary-with-curl-on-macos)
46+
- [Install with Homebrew on macOS](#install-with-homebrew-on-macos)
47+
- [Install with Macports on macOS](#install-with-macports-on-macos)
48+
- [Verify kubectl configuration](#verify-kubectl-configuration)
49+
- [Optional kubectl configurations and plugins](#optional-kubectl-configurations-and-plugins)
50+
- [Enable shell autocompletion](#enable-shell-autocompletion)
51+
- [Install `kubectl convert` plugin](#install-kubectl-convert-plugin)
4752
-->
48-
- [用 curl 在 macOS 系统上安装 kubectl](#install-kubectl-binary-with-curl-on-macos)
49-
- [用 Homebrew 在 macOS 系统上安装](#install-with-homebrew-on-macos)
50-
- [用 Macports 在 macOS 上安装](#install-with-macports-on-macos)
51-
53+
- [在 macOS 系统上安装 kubectl](#install-kubectl-on-macos)
54+
- [用 curl 在 macOS 系统上安装 kubectl](#install-kubectl-binary-with-curl-on-macos)
55+
- [用 Homebrew 在 macOS 系统上安装](#install-with-homebrew-on-macos)
56+
- [用 Macports 在 macOS 系统上安装](#install-with-macports-on-macos)
57+
- [验证 kubectl 配置](#verify-kubectl-configuration)
58+
- [可选的 kubectl 配置和插件](#optional-kubectl-configurations-and-plugins)
59+
- [启用 shell 自动补全功能](#enable-shell-autocompletion)
60+
- [安装 `kubectl convert` 插件](#install-kubectl-convert-plugin)
5261
<!--
5362
### Install kubectl binary with curl on macOS
5463
-->
5564
### 用 curl 在 macOS 系统上安装 kubectl {#install-kubectl-binary-with-curl-on-macos}
5665

57-
<!--
66+
<!--
5867
1. Download the latest release:
5968
-->
6069
1. 下载最新的发行版:
@@ -69,7 +78,7 @@ The following methods exist for installing kubectl on macOS:
6978
{{< /tabs >}}
7079

7180
{{< note >}}
72-
<!--
81+
<!--
7382
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.
7483
7584
For example, to download version {{< param "fullversion" >}} on Intel macOS, type:
@@ -91,7 +100,7 @@ The following methods exist for installing kubectl on macOS:
91100
```
92101
{{< /note >}}
93102

94-
<!--
103+
<!--
95104
1. Validate the binary (optional)
96105
97106
Download the kubectl checksum file:
@@ -109,7 +118,7 @@ The following methods exist for installing kubectl on macOS:
109118
{{< /tab >}}
110119
{{< /tabs >}}
111120

112-
<!--
121+
<!--
113122
Validate the kubectl binary against the checksum file:
114123
-->
115124
根据校验和文件,验证 kubectl:
@@ -126,7 +135,7 @@ The following methods exist for installing kubectl on macOS:
126135
kubectl: OK
127136
```
128137

129-
<!--
138+
<!--
130139
If the check fails, `shasum` exits with nonzero status and prints output similar to:
131140
-->
132141
验证失败时,`shasum` 将以非零值退出,并打印如下输出:
@@ -137,13 +146,13 @@ The following methods exist for installing kubectl on macOS:
137146
```
138147

139148
{{< note >}}
140-
<!--
149+
<!--
141150
Download the same version of the binary and checksum.
142151
-->
143152
下载的 kubectl 与校验和文件版本要相同。
144153
{{< /note >}}
145154

146-
<!--
155+
<!--
147156
1. Make the kubectl binary executable.
148157
-->
149158
3. 将 kubectl 置为可执行文件:
@@ -152,7 +161,7 @@ The following methods exist for installing kubectl on macOS:
152161
chmod +x ./kubectl
153162
```
154163

155-
<!--
164+
<!--
156165
1. Move the kubectl binary to a file location on your system `PATH`.
157166
-->
158167
4. 将可执行文件 kubectl 移动到系统可寻址路径 `PATH` 内的一个位置:
@@ -169,7 +178,7 @@ The following methods exist for installing kubectl on macOS:
169178
确保 `/usr/local/bin` 在你的 PATH 环境变量中。
170179
{{< /note >}}
171180

172-
<!--
181+
<!--
173182
1. Test to ensure the version you installed is up-to-date:
174183
-->
175184
5. 测试一下,确保你安装的是最新的版本:
@@ -187,33 +196,42 @@ The following methods exist for installing kubectl on macOS:
187196
kubectl version --client --output=yaml
188197
```
189198

199+
<!--
200+
1. After installing the plugin, clean up the installation files:
201+
-->
202+
1. 安装插件后,清理安装文件:
203+
204+
```bash
205+
rm kubectl kubectl.sha256
206+
```
190207
<!--
191208
### Install with Homebrew on macOS
192209
-->
193210
### 用 Homebrew 在 macOS 系统上安装 {#install-with-homebrew-on-macos}
194211

195-
<!--
212+
<!--
196213
If you are on macOS and using [Homebrew](https://brew.sh/) package manager, you can install kubectl with Homebrew.
197214
-->
198215
如果你是 macOS 系统,且用的是 [Homebrew](https://brew.sh/) 包管理工具,
199216
则可以用 Homebrew 安装 kubectl。
200217

201-
<!--
218+
<!--
202219
1. Run the installation command:
203220
-->
204221
1. 运行安装命令:
205222

206223
```bash
207-
brew install kubectl
224+
brew install kubectl
208225
```
209226

227+
<!-- or -->
210228
211229

212230
```bash
213231
brew install kubernetes-cli
214232
```
215233

216-
<!--
234+
<!--
217235
1. Test to ensure the version you installed is up-to-date:
218236
-->
219237
2. 测试一下,确保你安装的是最新的版本:
@@ -222,17 +240,17 @@ If you are on macOS and using [Homebrew](https://brew.sh/) package manager, you
222240
kubectl version --client
223241
```
224242

225-
<!--
243+
<!--
226244
### Install with Macports on macOS
227245
-->
228-
### 用 Macports 在 macOS 上安装 {#install-with-macports-on-macos}
246+
### 用 Macports 在 macOS 系统上安装 {#install-with-macports-on-macos}
229247

230-
<!--
248+
<!--
231249
If you are on macOS and using [Macports](https://macports.org/) package manager, you can install kubectl with Macports.
232250
-->
233-
如果你用的是 macOS,且用 [Macports](https://macports.org/) 包管理工具,则你可以用 Macports 安装kubectl
251+
如果你用的是 macOS,且用 [Macports](https://macports.org/) 包管理工具,则你可以用 Macports 安装 kubectl
234252

235-
<!--
253+
<!--
236254
1. Run the installation command:
237255
-->
238256
1. 运行安装命令:
@@ -242,7 +260,7 @@ If you are on macOS and using [Macports](https://macports.org/) package manager,
242260
sudo port install kubectl
243261
```
244262

245-
<!--
263+
<!--
246264
1. Test to ensure the version you installed is up-to-date:
247265
-->
248266
2. 测试一下,确保你安装的是最新的版本:
@@ -251,14 +269,14 @@ If you are on macOS and using [Macports](https://macports.org/) package manager,
251269
kubectl version --client
252270
```
253271

254-
<!--
272+
<!--
255273
## Verify kubectl configuration
256274
-->
257275
## 验证 kubectl 配置 {#verify-kubectl-configuration}
258276

259277
{{< include "included/verify-kubectl.md" >}}
260278

261-
<!--
279+
<!--
262280
## Optional kubectl configurations and plugins
263281
264282
### Enable shell autocompletion
@@ -267,7 +285,7 @@ If you are on macOS and using [Macports](https://macports.org/) package manager,
267285

268286
### 启用 shell 自动补全功能 {#enable-shell-autocompletion}
269287

270-
<!--
288+
<!--
271289
kubectl provides autocompletion support for Bash, Zsh, Fish, and PowerShell which can save you a lot of typing.
272290
273291
Below are the procedures to set up autocompletion for Bash, Fish, and Zsh.
@@ -309,7 +327,7 @@ kubectl 为 Bash、Zsh、Fish 和 PowerShell 提供自动补全功能,可以
309327
Download the kubectl-convert checksum file:
310328
-->
311329
2. 验证该可执行文件(可选步骤)
312-
330+
313331
下载 kubectl-convert 校验和文件:
314332

315333
{{< tabs name="download_convert_checksum_macos" >}}
@@ -329,7 +347,7 @@ kubectl 为 Bash、Zsh、Fish 和 PowerShell 提供自动补全功能,可以
329347
```bash
330348
echo "$(cat kubectl-convert.sha256) kubectl-convert" | shasum -a 256 --check
331349
```
332-
350+
333351
<!--
334352
If valid, the output is:
335353
-->
@@ -396,7 +414,15 @@ kubectl 为 Bash、Zsh、Fish 和 PowerShell 提供自动补全功能,可以
396414
-->
397415
如果你没有看到任何错误就代表插件安装成功了。
398416

417+
<!--
418+
1. After installing the plugin, clean up the installation files:
419+
-->
420+
1. 安装插件后,清理安装文件:
421+
422+
```bash
423+
rm kubectl kubectl.sha256
424+
```
425+
399426
## {{% heading "whatsnext" %}}
400427

401428
{{< include "included/kubectl-whats-next.md" >}}
402-

0 commit comments

Comments
 (0)