Merge pull request #35317 from yanrongshi/zh-cn]sync-install-kubectl-windows

[zh-cn]sync install-kubectl-windows.md
This commit is contained in:
Kubernetes Prow Robot 2022-07-31 07:50:28 -07:00 committed by GitHub
commit 146128808f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 66 additions and 60 deletions

View File

@ -32,48 +32,53 @@ v{{< skew currentVersionAddMinor 0 >}} 和 v{{< skew currentVersionAddMinor 1 >}
<!-- <!--
## Install kubectl on Windows ## Install kubectl on Windows
-->
## 在 Windows 上安装 kubectl {#install-kubectl-on-windows}
<!--
The following methods exist for installing kubectl on Windows: The following methods exist for installing kubectl on Windows:
--> -->
在 Windows 系统中安装 kubectl 有如下几种方法:
## 在 Windows 上安装 kubectl {#install-kubectl-on-windows}
在 Windows 系统中安装 kubectl 有如下几种方法:
<!--
- [Install kubectl binary with curl on Windows](#install-kubectl-binary-with-curl-on-windows)
- [Install on Windows using Chocolatey or Scoop](#install-on-windows-using-chocolatey-or-scoop)
-->
- [用 curl 在 Windows 上安装 kubectl](#install-kubectl-binary-with-curl-on-windows) - [用 curl 在 Windows 上安装 kubectl](#install-kubectl-binary-with-curl-on-windows)
- [在 Windows 上用 Chocolatey 或 Scoop 安装](#install-on-windows-using-chocolatey-or-scoop) - [在 Windows 上用 Chocolatey 或 Scoop 安装](#install-on-windows-using-chocolatey-or-scoop)
<!-- <!--
### Install kubectl binary with curl on Windows ### Install kubectl binary with curl on Windows
--> -->
### 用 curl 在 Windows 上安装 kubectl {#install-kubectl-binary-with-curl-on-windows} ### 用 curl 在 Windows 上安装 kubectl {#install-kubectl-binary-with-curl-on-windows}
<!-- <!--
1. Download the [latest release {{< param "fullversion" >}}](https://dl.k8s.io/release/{{< param "fullversion" >}}/bin/windows/amd64/kubectl.exe). 1. Download the [latest release {{< param "fullversion" >}}](https://dl.k8s.io/release/{{< param "fullversion" >}}/bin/windows/amd64/kubectl.exe).
Or if you have `curl` installed, use this command:
--> -->
1. 下载 [最新发行版 {{< param "fullversion" >}}](https://dl.k8s.io/release/{{< param "fullversion" >}}/bin/windows/amd64/kubectl.exe)。 1. 下载 [最新发行版 {{< param "fullversion" >}}](https://dl.k8s.io/release/{{< param "fullversion" >}}/bin/windows/amd64/kubectl.exe)。
如果你已安装了 `curl`,也可以使用此命令: <!--
Or if you have `curl` installed, use this command:
-->
如果你已安装了 `curl`,也可以使用此命令:
```powershell ```powershell
curl -LO "https://dl.k8s.io/release/{{< param "fullversion" >}}/bin/windows/amd64/kubectl.exe" curl -LO "https://dl.k8s.io/release/{{< param "fullversion" >}}/bin/windows/amd64/kubectl.exe"
``` ```
{{< note >}}
<!-- <!--
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). 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).
--> -->
{{< note >}}
要想找到最新稳定的版本(例如:为了编写脚本),可以看看这里 [https://dl.k8s.io/release/stable.txt](https://dl.k8s.io/release/stable.txt)。 要想找到最新稳定的版本(例如:为了编写脚本),可以看看这里 [https://dl.k8s.io/release/stable.txt](https://dl.k8s.io/release/stable.txt)。
{{< /note >}} {{< /note >}}
<!-- <!--
1. Validate the binary (optional) 1. Validate the binary (optional)
Download the `kubectl` checksum file: Download the `kubectl` checksum file:
--> -->
1. 验证该可执行文件(可选步骤) 2. 验证该可执行文件(可选步骤)
下载 `kubectl` 校验和文件: 下载 `kubectl` 校验和文件:
@ -105,25 +110,25 @@ The following methods exist for installing kubectl on Windows:
$($(CertUtil -hashfile .\kubectl.exe SHA256)[1] -replace " ", "") -eq $(type .\kubectl.exe.sha256) $($(CertUtil -hashfile .\kubectl.exe SHA256)[1] -replace " ", "") -eq $(type .\kubectl.exe.sha256)
``` ```
<!-- <!--
1. Append or prepend the `kubectl` binary folder to your `PATH` environment variable. 1. Append or prepend the `kubectl` binary folder to your `PATH` environment variable.
1. Test to ensure the version of `kubectl` is the same as downloaded: 1. Test to ensure the version of `kubectl` is the same as downloaded:
Or use this for detailed view of version: -->
-->
1. 将 `kubectl` 二进制文件夹追加或插入到你的 `PATH` 环境变量中。
1. 测试一下,确保此 `kubectl` 的版本和期望版本一致: 3. 将 `kubectl` 二进制文件夹追加或插入到你的 `PATH` 环境变量中。
4. 测试一下,确保此 `kubectl` 的版本和期望版本一致:
```cmd ```cmd
kubectl version --client kubectl version --client
``` ```
或者使用下面命令来查看版本的详细信息: 或者使用下面命令来查看版本的详细信息:
```cmd ```cmd
kubectl version --client --output=yaml kubectl version --client --output=yaml
``` ```
<!-- <!--
[Docker Desktop for Windows](https://docs.docker.com/docker-for-windows/#kubernetes) adds its own version of `kubectl` to `PATH`. [Docker Desktop for Windows](https://docs.docker.com/docker-for-windows/#kubernetes) adds its own version of `kubectl` to `PATH`.
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`. 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`.
@ -159,30 +164,28 @@ If you have installed Docker Desktop before, you may need to place your `PATH` e
{{% /tab %}} {{% /tab %}}
{{< /tabs >}} {{< /tabs >}}
<!--
1. Test to ensure the version you installed is up-to-date: <!--
--> 1. Test to ensure the version you installed is up-to-date:
-->
2. 测试一下,确保安装的是最新版本: 2. 测试一下,确保安装的是最新版本:
```powershell ```powershell
kubectl version --client kubectl version --client
``` ```
<!-- <!--
1. Navigate to your home directory: 1. Navigate to your home directory:
--> -->
3. 导航到你的 home 目录: 3. 导航到你的 home 目录:
<!--
# If you're using cmd.exe, run: cd %USERPROFILE%
-->
```powershell ```powershell
# 当你用 cmd.exe 时,则运行: cd %USERPROFILE% # 当你用 cmd.exe 时,则运行: cd %USERPROFILE%
cd ~ cd ~
``` ```
<!-- <!--
1. Create the `.kube` directory: 1. Create the `.kube` directory:
--> -->
4. 创建目录 `.kube` 4. 创建目录 `.kube`
@ -190,17 +193,17 @@ If you have installed Docker Desktop before, you may need to place your `PATH` e
mkdir .kube mkdir .kube
``` ```
<!-- <!--
1. Change to the `.kube` directory you just created: 1. Change to the `.kube` directory you just created:
--> -->
5. 切换到新创建的目录 `.kube` 5. 切换到新创建的目录 `.kube`
```powershell ```powershell
cd .kube cd .kube
``` ```
<!-- <!--
1. Configure kubectl to use a remote Kubernetes cluster: 1. Configure kubectl to use a remote Kubernetes cluster:
--> -->
6. 配置 kubectl以接入远程的 Kubernetes 集群: 6. 配置 kubectl以接入远程的 Kubernetes 集群:
@ -260,11 +263,12 @@ kubectl 为 Bash、Zsh、Fish 和 PowerShell 提供自动补全功能,可以
<!-- <!--
1. Validate the binary (optional) 1. Validate the binary (optional)
Download the `kubectl-convert` checksum file:
--> -->
1. 验证该可执行文件(可选步骤) 2. 验证该可执行文件(可选步骤)
<!--
Download the `kubectl-convert` checksum file:
-->
下载 `kubectl-convert` 校验和文件: 下载 `kubectl-convert` 校验和文件:
```powershell ```powershell
@ -273,11 +277,12 @@ kubectl 为 Bash、Zsh、Fish 和 PowerShell 提供自动补全功能,可以
<!-- <!--
Validate the `kubectl-convert` binary against the checksum file: Validate the `kubectl-convert` binary against the checksum file:
-->
基于校验和验证 `kubectl-convert` 的可执行文件:
<!--
- Using Command Prompt to manually compare `CertUtil`'s output to the checksum file downloaded: - Using Command Prompt to manually compare `CertUtil`'s output to the checksum file downloaded:
--> -->
基于校验和,验证 `kubectl-convert` 的可执行文件:
- 用提示的命令对 `CertUtil` 的输出和下载的校验和文件进行手动比较。 - 用提示的命令对 `CertUtil` 的输出和下载的校验和文件进行手动比较。
```cmd ```cmd
@ -288,6 +293,7 @@ kubectl 为 Bash、Zsh、Fish 和 PowerShell 提供自动补全功能,可以
<!-- <!--
- Using PowerShell to automate the verification using the `-eq` operator to get a `True` or `False` result: - Using PowerShell to automate the verification using the `-eq` operator to get a `True` or `False` result:
--> -->
- 使用 PowerShell `-eq` 操作使验证自动化,获得 `True` 或者 `False` 的结果: - 使用 PowerShell `-eq` 操作使验证自动化,获得 `True` 或者 `False` 的结果:
```powershell ```powershell
@ -299,9 +305,9 @@ kubectl 为 Bash、Zsh、Fish 和 PowerShell 提供自动补全功能,可以
1. Verify plugin is successfully installed 1. Verify plugin is successfully installed
--> -->
1. 将 `kubectl-convert` 二进制文件夹附加或添加到你的 `PATH` 环境变量中。 3. 将 `kubectl-convert` 二进制文件夹附加或添加到你的 `PATH` 环境变量中。
1. 验证插件是否安装成功 4. 验证插件是否安装成功
```shell ```shell
kubectl convert --help kubectl convert --help