Merge pull request #40110 from windsonsea/inslin
Tweak line wrappings in 5 files of tasks/tools/pull/40307/head
commit
b63fbaa1cb
|
@ -10,17 +10,26 @@ _build:
|
|||
|
||||
### Introduction
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
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`).
|
||||
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`).
|
||||
|
||||
### Install bash-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.
|
||||
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.
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
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:
|
||||
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:
|
||||
|
||||
```bash
|
||||
source /usr/share/bash-completion/bash_completion
|
||||
|
@ -32,7 +41,8 @@ Reload your shell and verify that bash-completion is correctly installed by typi
|
|||
|
||||
#### Bash
|
||||
|
||||
You now need to ensure that the kubectl completion script gets sourced in all your shell sessions. There are two ways in which you can do this:
|
||||
You now need to ensure that the kubectl completion script gets sourced in all
|
||||
your shell sessions. There are two ways in which you can do this:
|
||||
|
||||
{{< tabs name="kubectl_bash_autocompletion" >}}
|
||||
{{< tab name="User" codelang="bash" >}}
|
||||
|
@ -57,6 +67,7 @@ bash-completion sources all completion scripts in `/etc/bash_completion.d`.
|
|||
|
||||
Both approaches are equivalent. After reloading your shell, kubectl autocompletion should be working.
|
||||
To enable bash autocompletion in current session of shell, source the ~/.bashrc file:
|
||||
|
||||
```bash
|
||||
source ~/.bashrc
|
||||
```
|
||||
|
|
|
@ -10,12 +10,21 @@ _build:
|
|||
|
||||
### Introduction
|
||||
|
||||
The kubectl completion script for Bash can be generated with `kubectl completion bash`. Sourcing this script in your shell enables kubectl completion.
|
||||
The kubectl completion script for Bash can be generated with `kubectl completion bash`.
|
||||
Sourcing this script in your shell enables kubectl completion.
|
||||
|
||||
However, the kubectl completion script depends on [**bash-completion**](https://github.com/scop/bash-completion) which you thus have to previously install.
|
||||
However, the kubectl completion script depends on
|
||||
[**bash-completion**](https://github.com/scop/bash-completion) which you thus have to previously install.
|
||||
|
||||
{{< warning>}}
|
||||
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).
|
||||
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).
|
||||
{{< /warning >}}
|
||||
|
||||
### Upgrade Bash
|
||||
|
@ -43,10 +52,13 @@ Homebrew usually installs it at `/usr/local/bin/bash`.
|
|||
### Install bash-completion
|
||||
|
||||
{{< note >}}
|
||||
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).
|
||||
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).
|
||||
{{< /note >}}
|
||||
|
||||
You can test if you have bash-completion v2 already installed with `type _init_completion`. If not, you can install it with Homebrew:
|
||||
You can test if you have bash-completion v2 already installed with `type _init_completion`.
|
||||
If not, you can install it with Homebrew:
|
||||
|
||||
```bash
|
||||
brew install bash-completion@2
|
||||
|
@ -62,7 +74,8 @@ Reload your shell and verify that bash-completion v2 is correctly installed with
|
|||
|
||||
### Enable kubectl autocompletion
|
||||
|
||||
You now have to ensure that the kubectl completion script gets sourced in all your shell sessions. There are multiple ways to achieve this:
|
||||
You now have to ensure that the kubectl completion script gets sourced in all
|
||||
your shell sessions. There are multiple ways to achieve this:
|
||||
|
||||
- Source the completion script in your `~/.bash_profile` file:
|
||||
|
||||
|
@ -83,10 +96,14 @@ You now have to ensure that the kubectl completion script gets sourced in all yo
|
|||
echo 'complete -o default -F __start_kubectl k' >>~/.bash_profile
|
||||
```
|
||||
|
||||
- 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.
|
||||
- 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.
|
||||
|
||||
{{< note >}}
|
||||
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.
|
||||
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.
|
||||
{{< /note >}}
|
||||
|
||||
In any case, after reloading your shell, kubectl completion should be working.
|
||||
|
|
|
@ -12,7 +12,10 @@ card:
|
|||
|
||||
## {{% heading "prerequisites" %}}
|
||||
|
||||
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.
|
||||
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.
|
||||
Using the latest compatible version of kubectl helps avoid unforeseen issues.
|
||||
|
||||
## Install kubectl on Linux
|
||||
|
@ -32,7 +35,8 @@ The following methods exist for installing kubectl on Linux:
|
|||
```
|
||||
|
||||
{{< note >}}
|
||||
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.
|
||||
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.
|
||||
|
||||
For example, to download version {{< param "fullversion" >}} on Linux, type:
|
||||
|
||||
|
@ -79,7 +83,8 @@ For example, to download version {{< param "fullversion" >}} on Linux, type:
|
|||
```
|
||||
|
||||
{{< note >}}
|
||||
If you do not have root access on the target system, you can still install kubectl to the `~/.local/bin` directory:
|
||||
If you do not have root access on the target system, you can still install
|
||||
kubectl to the `~/.local/bin` directory:
|
||||
|
||||
```bash
|
||||
chmod +x kubectl
|
||||
|
@ -95,11 +100,14 @@ For example, to download version {{< param "fullversion" >}} on Linux, type:
|
|||
```bash
|
||||
kubectl version --client
|
||||
```
|
||||
|
||||
{{< note >}}
|
||||
The above command will generate a warning:
|
||||
|
||||
```
|
||||
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short.
|
||||
```
|
||||
|
||||
You can ignore this warning. You are only checking the version of `kubectl` that you
|
||||
have installed.
|
||||
|
||||
|
@ -122,7 +130,9 @@ For example, to download version {{< param "fullversion" >}} on Linux, type:
|
|||
sudo apt-get update
|
||||
sudo apt-get install -y ca-certificates curl
|
||||
```
|
||||
|
||||
If you use Debian 9 (stretch) or earlier you would also need to install `apt-transport-https`:
|
||||
|
||||
```shell
|
||||
sudo apt-get install -y apt-transport-https
|
||||
```
|
||||
|
@ -145,6 +155,7 @@ For example, to download version {{< param "fullversion" >}} on Linux, type:
|
|||
sudo apt-get update
|
||||
sudo apt-get install -y kubectl
|
||||
```
|
||||
|
||||
{{< note >}}
|
||||
In releases older than Debian 12 and Ubuntu 22.04, `/etc/apt/keyrings` does not exist by default.
|
||||
You can create this directory if you need to, making it world-readable but writeable only by admins.
|
||||
|
@ -172,7 +183,9 @@ sudo yum install -y kubectl
|
|||
|
||||
{{< tabs name="other_kubectl_install" >}}
|
||||
{{% tab name="Snap" %}}
|
||||
If you are on Ubuntu or another Linux distribution that supports the [snap](https://snapcraft.io/docs/core/install) package manager, kubectl is available as a [snap](https://snapcraft.io/) application.
|
||||
If you are on Ubuntu or another Linux distribution that supports the
|
||||
[snap](https://snapcraft.io/docs/core/install) package manager, kubectl
|
||||
is available as a [snap](https://snapcraft.io/) application.
|
||||
|
||||
```shell
|
||||
snap install kubectl --classic
|
||||
|
@ -182,7 +195,8 @@ kubectl version --client
|
|||
{{% /tab %}}
|
||||
|
||||
{{% tab name="Homebrew" %}}
|
||||
If you are on Linux and using [Homebrew](https://docs.brew.sh/Homebrew-on-Linux) package manager, kubectl is available for [installation](https://docs.brew.sh/Homebrew-on-Linux#install).
|
||||
If you are on Linux and using [Homebrew](https://docs.brew.sh/Homebrew-on-Linux)
|
||||
package manager, kubectl is available for [installation](https://docs.brew.sh/Homebrew-on-Linux#install).
|
||||
|
||||
```shell
|
||||
brew install kubectl
|
||||
|
@ -201,7 +215,8 @@ kubectl version --client
|
|||
|
||||
### Enable shell autocompletion
|
||||
|
||||
kubectl provides autocompletion support for Bash, Zsh, Fish, and PowerShell, which can save you a lot of typing.
|
||||
kubectl provides autocompletion support for Bash, Zsh, Fish, and PowerShell,
|
||||
which can save you a lot of typing.
|
||||
|
||||
Below are the procedures to set up autocompletion for Bash, Fish, and Zsh.
|
||||
|
||||
|
|
|
@ -12,7 +12,10 @@ card:
|
|||
|
||||
## {{% heading "prerequisites" %}}
|
||||
|
||||
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.
|
||||
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.
|
||||
Using the latest compatible version of kubectl helps avoid unforeseen issues.
|
||||
|
||||
## Install kubectl on macOS
|
||||
|
@ -42,7 +45,8 @@ The following methods exist for installing kubectl on macOS:
|
|||
{{< /tabs >}}
|
||||
|
||||
{{< note >}}
|
||||
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.
|
||||
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.
|
||||
|
||||
For example, to download version {{< param "fullversion" >}} on Intel macOS, type:
|
||||
|
||||
|
@ -119,9 +123,11 @@ The following methods exist for installing kubectl on macOS:
|
|||
|
||||
{{< note >}}
|
||||
The above command will generate a warning:
|
||||
|
||||
```
|
||||
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short.
|
||||
```
|
||||
|
||||
You can ignore this warning. You are only checking the version of `kubectl` that you
|
||||
have installed.
|
||||
|
||||
|
@ -141,7 +147,8 @@ The following methods exist for installing kubectl on macOS:
|
|||
|
||||
### Install with Homebrew on macOS
|
||||
|
||||
If you are on macOS and using [Homebrew](https://brew.sh/) package manager, you can install kubectl with Homebrew.
|
||||
If you are on macOS and using [Homebrew](https://brew.sh/) package manager,
|
||||
you can install kubectl with Homebrew.
|
||||
|
||||
1. Run the installation command:
|
||||
|
||||
|
@ -163,7 +170,8 @@ If you are on macOS and using [Homebrew](https://brew.sh/) package manager, you
|
|||
|
||||
### Install with Macports on macOS
|
||||
|
||||
If you are on macOS and using [Macports](https://macports.org/) package manager, you can install kubectl with Macports.
|
||||
If you are on macOS and using [Macports](https://macports.org/) package manager,
|
||||
you can install kubectl with Macports.
|
||||
|
||||
1. Run the installation command:
|
||||
|
||||
|
@ -186,7 +194,8 @@ If you are on macOS and using [Macports](https://macports.org/) package manager,
|
|||
|
||||
### Enable shell autocompletion
|
||||
|
||||
kubectl provides autocompletion support for Bash, Zsh, Fish, and PowerShell which can save you a lot of typing.
|
||||
kubectl provides autocompletion support for Bash, Zsh, Fish, and PowerShell
|
||||
which can save you a lot of typing.
|
||||
|
||||
Below are the procedures to set up autocompletion for Bash, Fish, and Zsh.
|
||||
|
||||
|
|
|
@ -12,7 +12,10 @@ card:
|
|||
|
||||
## {{% heading "prerequisites" %}}
|
||||
|
||||
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.
|
||||
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.
|
||||
Using the latest compatible version of kubectl helps avoid unforeseen issues.
|
||||
|
||||
## Install kubectl on Windows
|
||||
|
@ -33,7 +36,8 @@ The following methods exist for installing kubectl on Windows:
|
|||
```
|
||||
|
||||
{{< 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 >}}
|
||||
|
||||
1. Validate the binary (optional)
|
||||
|
@ -53,7 +57,8 @@ The following methods exist for installing kubectl on Windows:
|
|||
type kubectl.exe.sha256
|
||||
```
|
||||
|
||||
- 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
|
||||
$(Get-FileHash -Algorithm SHA256 .\kubectl.exe).Hash -eq $(Get-Content .\kubectl.exe.sha256)
|
||||
|
@ -66,14 +71,16 @@ The following methods exist for installing kubectl on Windows:
|
|||
```cmd
|
||||
kubectl version --client
|
||||
```
|
||||
|
||||
{{< note >}}
|
||||
The above command will generate a warning:
|
||||
|
||||
```
|
||||
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short.
|
||||
```
|
||||
|
||||
You can ignore this warning. You are only checking the version of `kubectl` that you
|
||||
have installed.
|
||||
|
||||
{{< /note >}}
|
||||
|
||||
Or use this for detailed view of version:
|
||||
|
@ -89,13 +96,17 @@ The following methods exist for installing kubectl on Windows:
|
|||
```
|
||||
|
||||
{{< note >}}
|
||||
[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`.
|
||||
[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`.
|
||||
{{< /note >}}
|
||||
|
||||
### Install on Windows using Chocolatey, Scoop, or winget {#install-nonstandard-package-tools}
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
{{< tabs name="kubectl_win_install" >}}
|
||||
{{% tab name="choco" %}}
|
||||
|
@ -158,7 +169,8 @@ Edit the config file with a text editor of your choice, such as Notepad.
|
|||
|
||||
### Enable shell autocompletion
|
||||
|
||||
kubectl provides autocompletion support for Bash, Zsh, Fish, and PowerShell, which can save you a lot of typing.
|
||||
kubectl provides autocompletion support for Bash, Zsh, Fish, and PowerShell,
|
||||
which can save you a lot of typing.
|
||||
|
||||
Below are the procedures to set up autocompletion for PowerShell.
|
||||
|
||||
|
@ -191,7 +203,8 @@ Below are the procedures to set up autocompletion for PowerShell.
|
|||
type kubectl-convert.exe.sha256
|
||||
```
|
||||
|
||||
- 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
|
||||
$($(CertUtil -hashfile .\kubectl-convert.exe SHA256)[1] -replace " ", "") -eq $(type .\kubectl-convert.exe.sha256)
|
||||
|
|
Loading…
Reference in New Issue