You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/zh-cn/docs/tasks/tools/included/optional-kubectl-configs-bash-linux.md
+21-7Lines changed: 21 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,12 +6,15 @@ _build:
6
6
list: never
7
7
render: never
8
8
publishResources: false
9
-
10
9
---
11
10
<!--
12
11
title: "bash auto-completion on Linux"
13
12
description: "Some optional configuration for bash auto-completion on Linux."
14
13
headless: true
14
+
_build:
15
+
list: never
16
+
render: never
17
+
publishResources: false
15
18
-->
16
19
17
20
<!--
@@ -20,9 +23,13 @@ headless: true
20
23
### 简介 {#introduction}
21
24
22
25
<!--
23
-
The kubectl completion script for Bash can be generated with the command `kubectl completion bash`. Sourcing the completion script in your shell enables kubectl autocompletion.
26
+
The kubectl completion script for Bash can be generated with the command `kubectl completion bash`.
27
+
Sourcing the completion script in your shell enables kubectl autocompletion.
24
28
25
-
However, the completion script depends on [**bash-completion**](https://github.com/scop/bash-completion), which means that you have to install this software first (you can test if you have bash-completion already installed by running `type _init_completion`).
bash-completion is provided by many package managers (see [here](https://github.com/scop/bash-completion#installation)). You can install it with `apt-get install bash-completion` or `yum install bash-completion`, etc.
46
+
bash-completion is provided by many package managers
47
+
(see [here](https://github.com/scop/bash-completion#installation)).
48
+
You can install it with `apt-get install bash-completion` or `yum install bash-completion`, etc.
40
49
41
-
The above commands create `/usr/share/bash-completion/bash_completion`, which is the main script of bash-completion. Depending on your package manager, you have to manually source this file in your `~/.bashrc` file.
50
+
The above commands create `/usr/share/bash-completion/bash_completion`,
51
+
which is the main script of bash-completion. Depending on your package manager,
52
+
you have to manually source this file in your `~/.bashrc` file.
42
53
43
-
To find out, reload your shell and run `type _init_completion`. If the command succeeds, you're already set, otherwise add the following to your `~/.bashrc` file:
54
+
To find out, reload your shell and run `type _init_completion`.
55
+
If the command succeeds, you're already set, otherwise add the following to your `~/.bashrc` file:
Copy file name to clipboardExpand all lines: content/zh-cn/docs/tasks/tools/included/optional-kubectl-configs-bash-mac.md
+28-12Lines changed: 28 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,9 +23,11 @@ _build:
23
23
### 简介 {#introduction}
24
24
25
25
<!--
26
-
The kubectl completion script for Bash can be generated with `kubectl completion bash`. Sourcing this script in your shell enables kubectl completion.
26
+
The kubectl completion script for Bash can be generated with `kubectl completion bash`.
27
+
Sourcing this script in your shell enables kubectl completion.
27
28
28
-
However, the kubectl completion script depends on [**bash-completion**](https://github.com/scop/bash-completion) which you thus have to previously install.
29
+
However, the kubectl completion script depends on
30
+
[**bash-completion**](https://github.com/scop/bash-completion) which you thus have to previously install.
There are two versions of bash-completion, v1 and v2. V1 is for Bash 3.2 (which is the default on macOS), and v2 is for Bash 4.1+. The kubectl completion script **doesn't work** correctly with bash-completion v1 and Bash 3.2. It requires **bash-completion v2** and **Bash 4.1+**. Thus, to be able to correctly use kubectl completion on macOS, you have to install and use Bash 4.1+ ([*instructions*](https://itnext.io/upgrading-bash-on-macos-7138bd1066ba)). The following instructions assume that you use Bash 4.1+ (that is, any Bash version of 4.1 or newer).
As mentioned, these instructions assume you use Bash 4.1+, which means you will install bash-completion v2 (in contrast to Bash 3.2 and bash-completion v1, in which case kubectl completion won't work).
101
+
As mentioned, these instructions assume you use Bash 4.1+, which means you will
102
+
install bash-completion v2 (in contrast to Bash 3.2 and bash-completion v1,
You now have to ensure that the kubectl completion script gets sourced in all your shell sessions. There are multiple ways to achieve this:
140
+
You now have to ensure that the kubectl completion script gets sourced in all
141
+
your shell sessions. There are multiple ways to achieve this:
129
142
130
143
- Source the completion script in your `~/.bash_profile` file:
131
144
-->
@@ -158,7 +171,10 @@ You now have to ensure that the kubectl completion script gets sourced in all yo
158
171
```
159
172
160
173
<!--
161
-
- If you installed kubectl with Homebrew (as explained [here](/docs/tasks/tools/install-kubectl-macos/#install-with-homebrew-on-macos)), then the kubectl completion script should already be in `/usr/local/etc/bash_completion.d/kubectl`. In that case, you don't need to do anything.
174
+
- If you installed kubectl with Homebrew (as explained
@@ -167,7 +183,8 @@ You now have to ensure that the kubectl completion script gets sourced in all yo
167
183
168
184
{{< note >}}
169
185
<!--
170
-
The Homebrew installation of bash-completion v2 sources all the files in the `BASH_COMPLETION_COMPAT_DIR` directory, that's why the latter two methods work.
186
+
The Homebrew installation of bash-completion v2 sources all the files in the
187
+
`BASH_COMPLETION_COMPAT_DIR` directory, that's why the latter two methods work.
Copy file name to clipboardExpand all lines: content/zh-cn/docs/tasks/tools/install-kubectl-macos.md
+14-6Lines changed: 14 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,10 @@ card:
22
22
## {{% heading "prerequisites" %}}
23
23
24
24
<!--
25
-
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.
25
+
You must use a kubectl version that is within one minor version difference of
26
+
your cluster. For example, a v{{< skew currentVersion >}} client can communicate
Copy file name to clipboardExpand all lines: content/zh-cn/docs/tasks/tools/install-kubectl-windows.md
+19-7Lines changed: 19 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,10 @@ card:
22
22
## {{% heading "prerequisites" %}}
23
23
24
24
<!--
25
-
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.
25
+
You must use a kubectl version that is within one minor version difference of
26
+
your cluster. For example, a v{{< skew currentVersion >}} client can communicate
and v{{< skew currentVersionAddMinor 1 >}} control planes.
26
29
Using the latest compatible version of kubectl helps avoid unforeseen issues.
27
30
-->
28
31
kubectl 版本和集群版本之间的差异必须在一个小版本号内。
@@ -67,7 +70,8 @@ The following methods exist for installing kubectl on Windows:
67
70
68
71
{{< note >}}
69
72
<!--
70
-
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).
73
+
To find out the latest stable version (for example, for scripting), take a look at
@@ -127,9 +132,11 @@ The following methods exist for installing kubectl on Windows:
127
132
The above command will generate a warning:
128
133
-->
129
134
上面的命令会产生一个警告:
135
+
130
136
```
131
137
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short.
132
138
```
139
+
133
140
<!--
134
141
You can ignore this warning. You are only checking the version of `kubectl` that you
135
142
have installed.
@@ -157,8 +164,10 @@ The following methods exist for installing kubectl on Windows:
157
164
158
165
{{< note >}}
159
166
<!--
160
-
[Docker Desktop for Windows](https://docs.docker.com/docker-for-windows/#kubernetes) adds its own version of `kubectl` to `PATH`.
161
-
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`.
167
+
[Docker Desktop for Windows](https://docs.docker.com/docker-for-windows/#kubernetes)
168
+
adds its own version of `kubectl` to `PATH`. If you have installed Docker Desktop before,
169
+
you may need to place your `PATH` entry before the one added by the Docker Desktop
170
+
installer or remove the Docker Desktop's `kubectl`.
@@ -172,7 +181,9 @@ If you have installed Docker Desktop before, you may need to place your `PATH` e
172
181
### 在 Windows 上用 Chocolatey、Scoop 或 winget 安装 {#install-nonstandard-package-tools}
173
182
174
183
<!--
175
-
1. To install kubectl on Windows you can use either [Chocolatey](https://chocolatey.org) package manager, [Scoop](https://scoop.sh) command-line installer, or [winget](https://learn.microsoft.com/en-us/windows/package-manager/winget/) package manager.
184
+
1. To install kubectl on Windows you can use either [Chocolatey](https://chocolatey.org)
185
+
package manager, [Scoop](https://scoop.sh) command-line installer, or
0 commit comments