diff --git a/content/zh/docs/tasks/tools/install-kubectl.md b/content/zh/docs/tasks/tools/install-kubectl.md index afa5758861..2e87c83417 100644 --- a/content/zh/docs/tasks/tools/install-kubectl.md +++ b/content/zh/docs/tasks/tools/install-kubectl.md @@ -260,16 +260,16 @@ If you are on macOS and using [Homebrew](https://brew.sh/) package manager, you --> 2. 测试以确保你安装的版本是最新的: - ``` + ```bash kubectl version --client ``` -## 在 macOS 上用 Macports 安装 kubectl +### 在 macOS 上用 Macports 安装 kubectl 如果你使用的是 macOS 系统并使用 [Macports](https://macports.org/) 包管理器,你可以通过 Macports 安装 kubectl。 @@ -288,7 +288,7 @@ If you are on macOS and using [Macports](https://macports.org/) package manager, --> 2. 测试以确保你安装的版本是最新的: - ``` + ```bash kubectl version --client ``` @@ -361,8 +361,8 @@ If you are on Windows and using [Powershell Gallery](https://www.powershellgalle --> 1. 运行安装命令(确保指定 `DownloadLocation`): - ``` - Install-Script -Name install-kubectl -Scope CurrentUser -Force + ```powershell + Install-Script -Name 'install-kubectl' -Scope CurrentUser -Force install-kubectl.ps1 [-DownloadLocation ] ``` @@ -376,14 +376,14 @@ If you are on Windows and using [Powershell Gallery](https://www.powershellgalle - 安装程序创建 `$ HOME/.kube` 目录,并指示它创建配置文件 + 安装程序创建 `$HOME/.kube` 目录,并指示它创建配置文件 2. 测试以确保你安装的版本是最新的: - ``` + ```powershell kubectl version --client ``` @@ -444,12 +444,12 @@ Updating the installation is performed by rerunning the two commands listed in s --> 4. 创建 `.kube` 目录: - ```powerhsell + ```powershell mkdir .kube ``` 5. 进入到刚刚创建的 `.kube` 目录: @@ -485,21 +485,23 @@ kubectl 可以作为 Google Cloud SDK 的一部分进行安装。 1. 安装 [Google Cloud SDK](https://cloud.google.com/sdk/)。 + 2. 运行以下命令安装 `kubectl`: - ``` + ```shell gcloud components install kubectl ``` 3. 测试以确保你安装的版本是最新的: - ``` + ```shell kubectl version --client ``` @@ -535,7 +537,7 @@ kubectl cluster-info 如果你看到一个 URL 被返回,那么 kubectl 已经被正确配置,能够正常访问你的 Kubernetes 集群。 @@ -546,7 +548,7 @@ The connection to the server was refused - did you specify th ``` @@ -561,7 +563,7 @@ kubectl cluster-info dump - 在 `~/.bash_profile` 文件中源引自动补齐脚本 @@ -812,12 +814,12 @@ You now have to ensure that the kubectl completion script gets sourced in all yo ``` - 将自动补齐脚本添加到目录 `/usr/local/etc/bash_completion.d`: ```bash - kubectl completion bash >//usr/local/etc/bash_completion.d/kubectl + kubectl completion bash >/usr/local/etc/bash_completion.d/kubectl ``` 如果你为 kubectl 命令设置了别名(alias),你可以扩展 Shell 补齐,使之能够与别名一起使用: -```shell +```zsh echo 'alias k=kubectl' >>~/.zshrc echo 'complete -F __start_kubectl k' >>~/.zshrc ```