Skip to content

Commit 756c16a

Browse files
authored
Merge pull request #26071 from yuandongx/patch-25
[zh] "tools/install-kubectl": some are incorrect and some is outdate.
2 parents fb73c84 + 024e3c0 commit 756c16a

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

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

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -260,16 +260,16 @@ If you are on macOS and using [Homebrew](https://brew.sh/) package manager, you
260260
-->
261261
2. 测试以确保你安装的版本是最新的:
262262

263-
```
263+
```bash
264264
kubectl version --client
265265
```
266266

267267
<!--
268-
## Install with Macports on macOS
268+
### Install with Macports on macOS
269269

270270
If you are on macOS and using [Macports](https://macports.org/) package manager, you can install kubectl with Macports.
271271
-->
272-
## 在 macOS 上用 Macports 安装 kubectl
272+
### 在 macOS 上用 Macports 安装 kubectl
273273

274274
如果你使用的是 macOS 系统并使用 [Macports](https://macports.org/) 包管理器,你可以通过 Macports 安装 kubectl。
275275

@@ -288,7 +288,7 @@ If you are on macOS and using [Macports](https://macports.org/) package manager,
288288
-->
289289
2. 测试以确保你安装的版本是最新的:
290290

291-
```
291+
```bash
292292
kubectl version --client
293293
```
294294

@@ -361,8 +361,8 @@ If you are on Windows and using [Powershell Gallery](https://www.powershellgalle
361361
-->
362362
1. 运行安装命令(确保指定 `DownloadLocation`):
363363
364-
```
365-
Install-Script -Name install-kubectl -Scope CurrentUser -Force
364+
```powershell
365+
Install-Script -Name 'install-kubectl' -Scope CurrentUser -Force
366366
install-kubectl.ps1 [-DownloadLocation <path>]
367367
```
368368
@@ -376,14 +376,14 @@ If you are on Windows and using [Powershell Gallery](https://www.powershellgalle
376376
<!--
377377
The installer creates `$HOME/.kube` and instructs it to create a config file
378378
-->
379-
安装程序创建 `$ HOME/.kube` 目录,并指示它创建配置文件
379+
安装程序创建 `$HOME/.kube` 目录,并指示它创建配置文件
380380

381381
<!--
382-
2. Test to ensure the version you installed is sufficiently up-to-date:
382+
2. Test to ensure the version you installed is up-to-date:
383383
-->
384384
2. 测试以确保你安装的版本是最新的:
385385

386-
```
386+
```powershell
387387
kubectl version --client
388388
```
389389

@@ -444,12 +444,12 @@ Updating the installation is performed by rerunning the two commands listed in s
444444
-->
445445
4. 创建 `.kube` 目录:
446446

447-
```powerhsell
447+
```powershell
448448
mkdir .kube
449449
```
450450

451451
<!--
452-
5. Change to the .kube directory you just created:
452+
5. Change to the `.kube` directory you just created:
453453
-->
454454
5. 进入到刚刚创建的 `.kube` 目录:
455455

@@ -485,21 +485,23 @@ kubectl 可以作为 Google Cloud SDK 的一部分进行安装。
485485

486486
<!--
487487
1. Install the [Google Cloud SDK](https://cloud.google.com/sdk/).
488+
488489
2. Run the `kubectl` installation command:
489490
-->
490491
1. 安装 [Google Cloud SDK](https://cloud.google.com/sdk/)。
492+
491493
2. 运行以下命令安装 `kubectl`
492494

493-
```
495+
```shell
494496
gcloud components install kubectl
495497
```
496498

497499
<!--
498-
3. Test to ensure the version you installed is sufficiently up-to-date:
500+
3. Test to ensure the version you installed is up-to-date:
499501
-->
500502
3. 测试以确保你安装的版本是最新的:
501503

502-
```
504+
```shell
503505
kubectl version --client
504506
```
505507

@@ -535,7 +537,7 @@ kubectl cluster-info
535537
<!--
536538
If you see a URL response, kubectl is correctly configured to access your cluster.
537539

538-
If you see a message similar to the following, kubectl is not correctly configured or not able to connect to a Kubernetes cluster.
540+
If you see a message similar to the following, kubectl is not configured correctly or is not able to connect to a Kubernetes cluster.
539541
-->
540542
如果你看到一个 URL 被返回,那么 kubectl 已经被正确配置,能够正常访问你的 Kubernetes 集群。
541543

@@ -546,7 +548,7 @@ The connection to the server <server-name:port> was refused - did you specify th
546548
```
547549

548550
<!--
549-
For example, if you are intending to run a Kubernetes cluster on your laptop (locally), you will need a tool like minikube to be installed first and then re-run the commands stated above.
551+
For example, if you are intending to run a Kubernetes cluster on your laptop (locally), you will need a tool like Minikube to be installed first and then re-run the commands stated above.
550552

551553
If kubectl cluster-info returns the url response but you can't access your cluster, to check whether it is configured properly, use:
552554
-->
@@ -561,7 +563,7 @@ kubectl cluster-info dump
561563
<!--
562564
## Optional kubectl configurations
563565
564-
## Enabling shell autocompletion
566+
### Enabling shell autocompletion
565567
566568
kubectl provides autocompletion support for Bash and Zsh, which can save you a lot of typing.
567569
@@ -803,7 +805,7 @@ You now have to ensure that the kubectl completion script gets sourced in all yo
803805
实现这点有两种方式:
804806
805807
<!--
806-
- Source the completion script in your `~/.bashrc` file:
808+
- Source the completion script in your `~/.bash_profile` file:
807809
-->
808810
- 在 `~/.bash_profile` 文件中源引自动补齐脚本
809811
@@ -812,12 +814,12 @@ You now have to ensure that the kubectl completion script gets sourced in all yo
812814
```
813815
814816
<!--
815-
- Add the completion script to the `/etc/bash_completion.d` directory:
817+
- Add the completion script to the `/usr/local/etc/bash_completion.d` directory:
816818
-->
817819
- 将自动补齐脚本添加到目录 `/usr/local/etc/bash_completion.d`:
818820
819821
```bash
820-
kubectl completion bash >//usr/local/etc/bash_completion.d/kubectl
822+
kubectl completion bash >/usr/local/etc/bash_completion.d/kubectl
821823
```
822824
823825
<!--
@@ -867,7 +869,7 @@ To do so in all your shell sessions, add the following to your `~/.zshrc` file:
867869
Zsh 的 kubectl 补齐脚本可通过 `kubectl completion zsh` 命令来生成。
868870
在 Shell 环境中引用自动补齐脚本就可以启用 kubectl 自动补齐。
869871

870-
```shell
872+
```zsh
871873
source <(kubectl completion zsh)
872874
```
873875

@@ -876,7 +878,7 @@ If you have an alias for kubectl, you can extend shell completion to work with t
876878
-->
877879
如果你为 kubectl 命令设置了别名(alias),你可以扩展 Shell 补齐,使之能够与别名一起使用:
878880

879-
```shell
881+
```zsh
880882
echo 'alias k=kubectl' >>~/.zshrc
881883
echo 'complete -F __start_kubectl k' >>~/.zshrc
882884
```

0 commit comments

Comments
 (0)