[ja] Translate content/ja/docs/tasks/tools/install-kubectl-windows.md (#45486)
* [ja] Translate content/ja/docs/tasks/tools/install-kubectl-windows.md * remove revieweres added a link to the minikube installation website del command updatepull/45852/head
parent
e620690a01
commit
de98cc74a5
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
title: "Tools Included"
|
||||
description: "メインのkubectl-installs-*.mdページに含まれるスニペット。"
|
||||
headless: true
|
||||
toc_hide: true
|
||||
_build:
|
||||
list: never
|
||||
render: never
|
||||
publishResources: false
|
||||
---
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
title: "kubectl-convertの概要"
|
||||
description: >-
|
||||
Kubernetes APIのあるバージョンから別のバージョンにマニフェストを変換することができるkubectlプラグイン。
|
||||
headless: true
|
||||
_build:
|
||||
list: never
|
||||
render: never
|
||||
publishResources: false
|
||||
---
|
||||
|
||||
異なるAPIバージョン間でマニフェストを変換できる、Kubernetesコマンドラインツール`kubectl`のプラグインです。
|
||||
これは特に、新しいKubernetesのリリースで、非推奨ではないAPIバージョンにマニフェストを移行する場合に役に立ちます。
|
||||
詳細については[非推奨ではないAPIへの移行](/docs/reference/using-api/deprecation-guide/#migrate-to-non-deprecated-apis)を参照してください。
|
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
title: "次の項目"
|
||||
description: "kubectlをインストールした後の次の項目。"
|
||||
headless: true
|
||||
_build:
|
||||
list: never
|
||||
render: never
|
||||
publishResources: false
|
||||
---
|
||||
|
||||
* [Minikubeをインストールする](https://minikube.sigs.k8s.io/docs/start/)
|
||||
* クラスターの作成に関する詳細を[スタートガイド](/ja/docs/setup/)で確認する。
|
||||
* [アプリケーションを起動して公開する方法を学ぶ。](/ja/docs/tasks/access-application-cluster/service-access-application-cluster/)
|
||||
* あなたが作成していないクラスターにアクセスする必要がある場合は、[クラスターアクセスドキュメントの共有](/ja/docs/tasks/access-application-cluster/configure-access-multiple-clusters/)を参照してください。
|
||||
* [kubectlリファレンスドキュメント](/docs/reference/kubectl/kubectl/)を参照する
|
|
@ -0,0 +1,73 @@
|
|||
---
|
||||
title: "bash auto-completion on Linux"
|
||||
description: "Some optional configuration for bash auto-completion on Linux."
|
||||
headless: true
|
||||
_build:
|
||||
list: never
|
||||
render: never
|
||||
publishResources: false
|
||||
---
|
||||
|
||||
### 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.
|
||||
|
||||
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.
|
||||
|
||||
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:
|
||||
|
||||
```bash
|
||||
source /usr/share/bash-completion/bash_completion
|
||||
```
|
||||
|
||||
Reload your shell and verify that bash-completion is correctly installed by typing `type _init_completion`.
|
||||
|
||||
### Enable kubectl autocompletion
|
||||
|
||||
#### 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:
|
||||
|
||||
{{< tabs name="kubectl_bash_autocompletion" >}}
|
||||
{{< tab name="User" codelang="bash" >}}
|
||||
echo 'source <(kubectl completion bash)' >>~/.bashrc
|
||||
{{< /tab >}}
|
||||
{{< tab name="System" codelang="bash" >}}
|
||||
kubectl completion bash | sudo tee /etc/bash_completion.d/kubectl > /dev/null
|
||||
sudo chmod a+r /etc/bash_completion.d/kubectl
|
||||
{{< /tab >}}
|
||||
{{< /tabs >}}
|
||||
|
||||
If you have an alias for kubectl, you can extend shell completion to work with that alias:
|
||||
|
||||
```bash
|
||||
echo 'alias k=kubectl' >>~/.bashrc
|
||||
echo 'complete -o default -F __start_kubectl k' >>~/.bashrc
|
||||
```
|
||||
|
||||
{{< note >}}
|
||||
bash-completion sources all completion scripts in `/etc/bash_completion.d`.
|
||||
{{< /note >}}
|
||||
|
||||
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
|
||||
```
|
|
@ -0,0 +1,109 @@
|
|||
---
|
||||
title: "bash auto-completion on macOS"
|
||||
description: "Some optional configuration for bash auto-completion on macOS."
|
||||
headless: true
|
||||
_build:
|
||||
list: never
|
||||
render: never
|
||||
publishResources: false
|
||||
---
|
||||
|
||||
### Introduction
|
||||
|
||||
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.
|
||||
|
||||
{{< 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).
|
||||
{{< /warning >}}
|
||||
|
||||
### Upgrade Bash
|
||||
|
||||
The instructions here assume you use Bash 4.1+. You can check your Bash's version by running:
|
||||
|
||||
```bash
|
||||
echo $BASH_VERSION
|
||||
```
|
||||
|
||||
If it is too old, you can install/upgrade it using Homebrew:
|
||||
|
||||
```bash
|
||||
brew install bash
|
||||
```
|
||||
|
||||
Reload your shell and verify that the desired version is being used:
|
||||
|
||||
```bash
|
||||
echo $BASH_VERSION $SHELL
|
||||
```
|
||||
|
||||
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).
|
||||
{{< /note >}}
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
As stated in the output of this command, add the following to your `~/.bash_profile` file:
|
||||
|
||||
```bash
|
||||
brew_etc="$(brew --prefix)/etc" && [[ -r "${brew_etc}/profile.d/bash_completion.sh" ]] && . "${brew_etc}/profile.d/bash_completion.sh"
|
||||
```
|
||||
|
||||
Reload your shell and verify that bash-completion v2 is correctly installed with `type _init_completion`.
|
||||
|
||||
### 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:
|
||||
|
||||
- Source the completion script in your `~/.bash_profile` file:
|
||||
|
||||
```bash
|
||||
echo 'source <(kubectl completion bash)' >>~/.bash_profile
|
||||
```
|
||||
|
||||
- Add the completion script to the `/usr/local/etc/bash_completion.d` directory:
|
||||
|
||||
```bash
|
||||
kubectl completion bash >/usr/local/etc/bash_completion.d/kubectl
|
||||
```
|
||||
|
||||
- If you have an alias for kubectl, you can extend shell completion to work with that alias:
|
||||
|
||||
```bash
|
||||
echo 'alias k=kubectl' >>~/.bash_profile
|
||||
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.
|
||||
|
||||
{{< 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.
|
||||
{{< /note >}}
|
||||
|
||||
In any case, after reloading your shell, kubectl completion should be working.
|
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
title: "fish auto-completion"
|
||||
description: "Optional configuration to enable fish shell auto-completion."
|
||||
headless: true
|
||||
_build:
|
||||
list: never
|
||||
render: never
|
||||
publishResources: false
|
||||
---
|
||||
|
||||
{{< note >}}
|
||||
Autocomplete for Fish requires kubectl 1.23 or later.
|
||||
{{< /note >}}
|
||||
|
||||
The kubectl completion script for Fish can be generated with the command `kubectl completion fish`. Sourcing the completion script in your shell enables kubectl autocompletion.
|
||||
|
||||
To do so in all your shell sessions, add the following line to your `~/.config/fish/config.fish` file:
|
||||
|
||||
```shell
|
||||
kubectl completion fish | source
|
||||
```
|
||||
|
||||
After reloading your shell, kubectl autocompletion should be working.
|
|
@ -0,0 +1,28 @@
|
|||
---
|
||||
title: "PowerShellの自動補完"
|
||||
description: "PowerShellの自動補完に対するいくつかの補助的な設定。"
|
||||
headless: true
|
||||
_build:
|
||||
list: never
|
||||
render: never
|
||||
publishResources: false
|
||||
---
|
||||
|
||||
PowerShellにおけるkubectlの補完スクリプトは`kubectl completion powershell`コマンドで生成できます。
|
||||
|
||||
すべてのシェルセッションでこれを行うには、次の行を`$PROFILE`ファイルに追加します。
|
||||
|
||||
```powershell
|
||||
kubectl completion powershell | Out-String | Invoke-Expression
|
||||
```
|
||||
|
||||
このコマンドは、PowerShellを起動する度に自動補完のスクリプトを再生成します。
|
||||
生成されたスクリプトを直接`$PROFILE`ファイルに追加することもできます。
|
||||
|
||||
生成されたスクリプトを`$PROFILE`ファイルに追加するためには、PowerShellのプロンプトで次の行を実行します:
|
||||
|
||||
```powershell
|
||||
kubectl completion powershell >> $PROFILE
|
||||
```
|
||||
|
||||
シェルをリロードした後、kubectlの自動補完が機能します。
|
|
@ -0,0 +1,28 @@
|
|||
---
|
||||
title: "zsh auto-completion"
|
||||
description: "Some optional configuration for zsh auto-completion."
|
||||
headless: true
|
||||
_build:
|
||||
list: never
|
||||
render: never
|
||||
publishResources: false
|
||||
---
|
||||
|
||||
The kubectl completion script for Zsh can be generated with the command `kubectl completion zsh`. Sourcing the completion script in your shell enables kubectl autocompletion.
|
||||
|
||||
To do so in all your shell sessions, add the following to your `~/.zshrc` file:
|
||||
|
||||
```zsh
|
||||
source <(kubectl completion zsh)
|
||||
```
|
||||
|
||||
If you have an alias for kubectl, kubectl autocompletion will automatically work with it.
|
||||
|
||||
After reloading your shell, kubectl autocompletion should be working.
|
||||
|
||||
If you get an error like `2: command not found: compdef`, then add the following to the beginning of your `~/.zshrc` file:
|
||||
|
||||
```zsh
|
||||
autoload -Uz compinit
|
||||
compinit
|
||||
```
|
|
@ -0,0 +1,46 @@
|
|||
---
|
||||
title: "kubectlの設定を検証する"
|
||||
description: "kubectlを検証する方法。"
|
||||
headless: true
|
||||
_build:
|
||||
list: never
|
||||
render: never
|
||||
publishResources: false
|
||||
---
|
||||
|
||||
kubectlがKubernetesクラスターを探索し接続するために、[kubeconfigファイル](/ja/docs/concepts/configuration/organize-cluster-access-kubeconfig/)が必要です。
|
||||
これは、[kube-up.sh](https://github.com/kubernetes/kubernetes/blob/master/cluster/kube-up.sh)によりクラスターを作成した際や、Minikubeクラスターを正常にデプロイした際に自動生成されます。
|
||||
デフォルトでは、kubectlの設定は`~/.kube/config`に格納されています。
|
||||
|
||||
クラスターの状態を取得し、kubectlが適切に設定されていることを確認してください:
|
||||
|
||||
```shell
|
||||
kubectl cluster-info
|
||||
```
|
||||
|
||||
URLのレスポンスが表示されている場合は、kubectlはクラスターに接続するよう正しく設定されています。
|
||||
|
||||
以下のようなメッセージが表示されている場合は、kubectlは正しく設定されていないか、Kubernetesクラスターに接続できていません。
|
||||
|
||||
```
|
||||
The connection to the server <server-name:port> was refused - did you specify the right host or port?
|
||||
```
|
||||
|
||||
たとえば、ラップトップ上(ローカル環境)でKubernetesクラスターを起動するような場合、[Minikube](https://minikube.sigs.k8s.io/docs/start/)などのツールを最初にインストールしてから、上記のコマンドを再実行する必要があります。
|
||||
|
||||
kubectl cluster-infoがURLレスポンスを返したにもかかわらずクラスターにアクセスできない場合は、次のコマンドで設定が正しいことを確認してください:
|
||||
|
||||
```shell
|
||||
kubectl cluster-info dump
|
||||
```
|
||||
|
||||
### エラーメッセージ'No Auth Provider Found'のトラブルシューティング{#no-auth-provider-found}
|
||||
|
||||
Kubernetes 1.26にて、kubectlは以下のクラウドプロバイダーが提供するマネージドKubernetesのビルトイン認証を削除しました。
|
||||
これらのプロバイダーは、クラウド固有の認証を提供するkubectlプラグインをリリースしています。
|
||||
手順については以下のプロバイダーのドキュメントを参照してください:
|
||||
|
||||
* Azure AKS: [kubelogin plugin](https://azure.github.io/kubelogin/)
|
||||
* Google Kubernetes Engine: [gke-gcloud-auth-plugin](https://cloud.google.com/kubernetes-engine/docs/how-to/cluster-access-for-kubectl#install_plugin)
|
||||
|
||||
(この変更とは関係なく、他の理由で同じエラーメッセージが表示される可能性もあります。)
|
|
@ -0,0 +1,350 @@
|
|||
---
|
||||
title: Install and Set Up kubectl on Linux
|
||||
content_type: task
|
||||
weight: 10
|
||||
---
|
||||
|
||||
## {{% 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.
|
||||
Using the latest compatible version of kubectl helps avoid unforeseen issues.
|
||||
|
||||
## Install kubectl on Linux
|
||||
|
||||
The following methods exist for installing kubectl on Linux:
|
||||
|
||||
- [Install kubectl binary with curl on Linux](#install-kubectl-binary-with-curl-on-linux)
|
||||
- [Install using native package management](#install-using-native-package-management)
|
||||
- [Install using other package management](#install-using-other-package-management)
|
||||
|
||||
### Install kubectl binary with curl on Linux
|
||||
|
||||
1. Download the latest release with the command:
|
||||
|
||||
{{< tabs name="download_binary_linux" >}}
|
||||
{{< tab name="x86-64" codelang="bash" >}}
|
||||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
||||
{{< /tab >}}
|
||||
{{< tab name="ARM64" codelang="bash" >}}
|
||||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl"
|
||||
{{< /tab >}}
|
||||
{{< /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.
|
||||
|
||||
For example, to download version {{< skew currentPatchVersion >}} on Linux x86-64, type:
|
||||
|
||||
```bash
|
||||
curl -LO https://dl.k8s.io/release/v{{< skew currentPatchVersion >}}/bin/linux/amd64/kubectl
|
||||
```
|
||||
|
||||
And for Linux ARM64, type:
|
||||
|
||||
```bash
|
||||
curl -LO https://dl.k8s.io/release/v{{< skew currentPatchVersion >}}/bin/linux/arm64/kubectl
|
||||
```
|
||||
|
||||
{{< /note >}}
|
||||
|
||||
1. Validate the binary (optional)
|
||||
|
||||
Download the kubectl checksum file:
|
||||
|
||||
{{< tabs name="download_checksum_linux" >}}
|
||||
{{< tab name="x86-64" codelang="bash" >}}
|
||||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
|
||||
{{< /tab >}}
|
||||
{{< tab name="ARM64" codelang="bash" >}}
|
||||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl.sha256"
|
||||
{{< /tab >}}
|
||||
{{< /tabs >}}
|
||||
|
||||
Validate the kubectl binary against the checksum file:
|
||||
|
||||
```bash
|
||||
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
|
||||
```
|
||||
|
||||
If valid, the output is:
|
||||
|
||||
```console
|
||||
kubectl: OK
|
||||
```
|
||||
|
||||
If the check fails, `sha256` exits with nonzero status and prints output similar to:
|
||||
|
||||
```console
|
||||
kubectl: FAILED
|
||||
sha256sum: WARNING: 1 computed checksum did NOT match
|
||||
```
|
||||
|
||||
{{< note >}}
|
||||
Download the same version of the binary and checksum.
|
||||
{{< /note >}}
|
||||
|
||||
1. Install kubectl
|
||||
|
||||
```bash
|
||||
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
|
||||
```
|
||||
|
||||
{{< note >}}
|
||||
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
|
||||
mkdir -p ~/.local/bin
|
||||
mv ./kubectl ~/.local/bin/kubectl
|
||||
# and then append (or prepend) ~/.local/bin to $PATH
|
||||
```
|
||||
|
||||
{{< /note >}}
|
||||
|
||||
1. Test to ensure the version you installed is up-to-date:
|
||||
|
||||
```bash
|
||||
kubectl version --client
|
||||
```
|
||||
|
||||
Or use this for detailed view of version:
|
||||
|
||||
```cmd
|
||||
kubectl version --client --output=yaml
|
||||
```
|
||||
|
||||
### Install using native package management
|
||||
|
||||
{{< tabs name="kubectl_install" >}}
|
||||
{{% tab name="Debian-based distributions" %}}
|
||||
|
||||
1. Update the `apt` package index and install packages needed to use the Kubernetes `apt` repository:
|
||||
|
||||
```shell
|
||||
sudo apt-get update
|
||||
# apt-transport-https may be a dummy package; if so, you can skip that package
|
||||
sudo apt-get install -y apt-transport-https ca-certificates curl
|
||||
```
|
||||
|
||||
2. Download the public signing key for the Kubernetes package repositories. The same signing key is used for all repositories so you can disregard the version in the URL:
|
||||
|
||||
```shell
|
||||
# If the folder `/etc/apt/keyrings` does not exist, it should be created before the curl command, read the note below.
|
||||
# sudo mkdir -p -m 755 /etc/apt/keyrings
|
||||
curl -fsSL https://pkgs.k8s.io/core:/stable:/{{< param "version" >}}/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
|
||||
```
|
||||
|
||||
{{< note >}}
|
||||
In releases older than Debian 12 and Ubuntu 22.04, folder `/etc/apt/keyrings` does not exist by default, and it should be created before the curl command.
|
||||
{{< /note >}}
|
||||
|
||||
3. Add the appropriate Kubernetes `apt` repository. If you want to use Kubernetes version different than {{< param "version" >}},
|
||||
replace {{< param "version" >}} with the desired minor version in the command below:
|
||||
|
||||
```shell
|
||||
# This overwrites any existing configuration in /etc/apt/sources.list.d/kubernetes.list
|
||||
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/{{< param "version" >}}/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
|
||||
```
|
||||
|
||||
{{< note >}}
|
||||
To upgrade kubectl to another minor release, you'll need to bump the version in `/etc/apt/sources.list.d/kubernetes.list` before running `apt-get update` and `apt-get upgrade`. This procedure is described in more detail in [Changing The Kubernetes Package Repository](/docs/tasks/administer-cluster/kubeadm/change-package-repository/).
|
||||
{{< /note >}}
|
||||
|
||||
4. Update `apt` package index, then install kubectl:
|
||||
|
||||
```shell
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y kubectl
|
||||
```
|
||||
|
||||
{{% /tab %}}
|
||||
|
||||
{{% tab name="Red Hat-based distributions" %}}
|
||||
|
||||
1. Add the Kubernetes `yum` repository. If you want to use Kubernetes version
|
||||
different than {{< param "version" >}}, replace {{< param "version" >}} with
|
||||
the desired minor version in the command below.
|
||||
|
||||
```bash
|
||||
# This overwrites any existing configuration in /etc/yum.repos.d/kubernetes.repo
|
||||
cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
|
||||
[kubernetes]
|
||||
name=Kubernetes
|
||||
baseurl=https://pkgs.k8s.io/core:/stable:/{{< param "version" >}}/rpm/
|
||||
enabled=1
|
||||
gpgcheck=1
|
||||
gpgkey=https://pkgs.k8s.io/core:/stable:/{{< param "version" >}}/rpm/repodata/repomd.xml.key
|
||||
EOF
|
||||
```
|
||||
|
||||
{{< note >}}
|
||||
To upgrade kubectl to another minor release, you'll need to bump the version in `/etc/yum.repos.d/kubernetes.repo` before running `yum update`. This procedure is described in more detail in [Changing The Kubernetes Package Repository](/docs/tasks/administer-cluster/kubeadm/change-package-repository/).
|
||||
{{< /note >}}
|
||||
|
||||
2. Install kubectl using `yum`:
|
||||
|
||||
```bash
|
||||
sudo yum install -y kubectl
|
||||
```
|
||||
|
||||
{{% /tab %}}
|
||||
|
||||
{{% tab name="SUSE-based distributions" %}}
|
||||
|
||||
1. Add the Kubernetes `zypper` repository. If you want to use Kubernetes version
|
||||
different than {{< param "version" >}}, replace {{< param "version" >}} with
|
||||
the desired minor version in the command below.
|
||||
|
||||
```bash
|
||||
# This overwrites any existing configuration in /etc/zypp/repos.d/kubernetes.repo
|
||||
cat <<EOF | sudo tee /etc/zypp/repos.d/kubernetes.repo
|
||||
[kubernetes]
|
||||
name=Kubernetes
|
||||
baseurl=https://pkgs.k8s.io/core:/stable:/{{< param "version" >}}/rpm/
|
||||
enabled=1
|
||||
gpgcheck=1
|
||||
gpgkey=https://pkgs.k8s.io/core:/stable:/{{< param "version" >}}/rpm/repodata/repomd.xml.key
|
||||
EOF
|
||||
```
|
||||
|
||||
{{< note >}}
|
||||
To upgrade kubectl to another minor release, you'll need to bump the version in `/etc/zypp/repos.d/kubernetes.repo`
|
||||
before running `zypper update`. This procedure is described in more detail in
|
||||
[Changing The Kubernetes Package Repository](/docs/tasks/administer-cluster/kubeadm/change-package-repository/).
|
||||
{{< /note >}}
|
||||
|
||||
2. Install kubectl using `zypper`:
|
||||
|
||||
```bash
|
||||
sudo zypper install -y kubectl
|
||||
```
|
||||
|
||||
{{% /tab %}}
|
||||
{{< /tabs >}}
|
||||
|
||||
### Install using other package management
|
||||
|
||||
{{< 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.
|
||||
|
||||
```shell
|
||||
snap install kubectl --classic
|
||||
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).
|
||||
|
||||
```shell
|
||||
brew install kubectl
|
||||
kubectl version --client
|
||||
```
|
||||
|
||||
{{% /tab %}}
|
||||
|
||||
{{< /tabs >}}
|
||||
|
||||
## Verify kubectl configuration
|
||||
|
||||
{{< include "included/verify-kubectl.md" >}}
|
||||
|
||||
## Optional kubectl configurations and plugins
|
||||
|
||||
### Enable shell autocompletion
|
||||
|
||||
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.
|
||||
|
||||
{{< tabs name="kubectl_autocompletion" >}}
|
||||
{{< tab name="Bash" include="included/optional-kubectl-configs-bash-linux.md" />}}
|
||||
{{< tab name="Fish" include="included/optional-kubectl-configs-fish.md" />}}
|
||||
{{< tab name="Zsh" include="included/optional-kubectl-configs-zsh.md" />}}
|
||||
{{< /tabs >}}
|
||||
|
||||
### Install `kubectl convert` plugin
|
||||
|
||||
{{< include "included/kubectl-convert-overview.md" >}}
|
||||
|
||||
1. Download the latest release with the command:
|
||||
|
||||
{{< tabs name="download_convert_binary_linux" >}}
|
||||
{{< tab name="x86-64" codelang="bash" >}}
|
||||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl-convert"
|
||||
{{< /tab >}}
|
||||
{{< tab name="ARM64" codelang="bash" >}}
|
||||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl-convert"
|
||||
{{< /tab >}}
|
||||
{{< /tabs >}}
|
||||
|
||||
1. Validate the binary (optional)
|
||||
|
||||
Download the kubectl-convert checksum file:
|
||||
|
||||
{{< tabs name="download_convert_checksum_linux" >}}
|
||||
{{< tab name="x86-64" codelang="bash" >}}
|
||||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl-convert.sha256"
|
||||
{{< /tab >}}
|
||||
{{< tab name="ARM64" codelang="bash" >}}
|
||||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl-convert.sha256"
|
||||
{{< /tab >}}
|
||||
{{< /tabs >}}
|
||||
|
||||
Validate the kubectl-convert binary against the checksum file:
|
||||
|
||||
```bash
|
||||
echo "$(cat kubectl-convert.sha256) kubectl-convert" | sha256sum --check
|
||||
```
|
||||
|
||||
If valid, the output is:
|
||||
|
||||
```console
|
||||
kubectl-convert: OK
|
||||
```
|
||||
|
||||
If the check fails, `sha256` exits with nonzero status and prints output similar to:
|
||||
|
||||
```console
|
||||
kubectl-convert: FAILED
|
||||
sha256sum: WARNING: 1 computed checksum did NOT match
|
||||
```
|
||||
|
||||
{{< note >}}
|
||||
Download the same version of the binary and checksum.
|
||||
{{< /note >}}
|
||||
|
||||
1. Install kubectl-convert
|
||||
|
||||
```bash
|
||||
sudo install -o root -g root -m 0755 kubectl-convert /usr/local/bin/kubectl-convert
|
||||
```
|
||||
|
||||
1. Verify plugin is successfully installed
|
||||
|
||||
```shell
|
||||
kubectl convert --help
|
||||
```
|
||||
|
||||
If you do not see an error, it means the plugin is successfully installed.
|
||||
|
||||
1. After installing the plugin, clean up the installation files:
|
||||
|
||||
```bash
|
||||
rm kubectl-convert kubectl-convert.sha256
|
||||
```
|
||||
|
||||
## {{% heading "whatsnext" %}}
|
||||
|
||||
{{< include "included/kubectl-whats-next.md" >}}
|
|
@ -0,0 +1,303 @@
|
|||
---
|
||||
title: Install and Set Up kubectl on macOS
|
||||
content_type: task
|
||||
weight: 10
|
||||
---
|
||||
|
||||
## {{% 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.
|
||||
Using the latest compatible version of kubectl helps avoid unforeseen issues.
|
||||
|
||||
## Install kubectl on macOS
|
||||
|
||||
The following methods exist for installing kubectl on macOS:
|
||||
|
||||
- [Install kubectl on macOS](#install-kubectl-on-macos)
|
||||
- [Install kubectl binary with curl on macOS](#install-kubectl-binary-with-curl-on-macos)
|
||||
- [Install with Homebrew on macOS](#install-with-homebrew-on-macos)
|
||||
- [Install with Macports on macOS](#install-with-macports-on-macos)
|
||||
- [Verify kubectl configuration](#verify-kubectl-configuration)
|
||||
- [Optional kubectl configurations and plugins](#optional-kubectl-configurations-and-plugins)
|
||||
- [Enable shell autocompletion](#enable-shell-autocompletion)
|
||||
- [Install `kubectl convert` plugin](#install-kubectl-convert-plugin)
|
||||
|
||||
### Install kubectl binary with curl on macOS
|
||||
|
||||
1. Download the latest release:
|
||||
|
||||
{{< tabs name="download_binary_macos" >}}
|
||||
{{< tab name="Intel" codelang="bash" >}}
|
||||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/amd64/kubectl"
|
||||
{{< /tab >}}
|
||||
{{< tab name="Apple Silicon" codelang="bash" >}}
|
||||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/arm64/kubectl"
|
||||
{{< /tab >}}
|
||||
{{< /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.
|
||||
|
||||
For example, to download version {{< skew currentPatchVersion >}} on Intel macOS, type:
|
||||
|
||||
```bash
|
||||
curl -LO "https://dl.k8s.io/release/v{{< skew currentPatchVersion >}}/bin/darwin/amd64/kubectl"
|
||||
```
|
||||
|
||||
And for macOS on Apple Silicon, type:
|
||||
|
||||
```bash
|
||||
curl -LO "https://dl.k8s.io/release/v{{< skew currentPatchVersion >}}/bin/darwin/arm64/kubectl"
|
||||
```
|
||||
|
||||
{{< /note >}}
|
||||
|
||||
1. Validate the binary (optional)
|
||||
|
||||
Download the kubectl checksum file:
|
||||
|
||||
{{< tabs name="download_checksum_macos" >}}
|
||||
{{< tab name="Intel" codelang="bash" >}}
|
||||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/amd64/kubectl.sha256"
|
||||
{{< /tab >}}
|
||||
{{< tab name="Apple Silicon" codelang="bash" >}}
|
||||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/arm64/kubectl.sha256"
|
||||
{{< /tab >}}
|
||||
{{< /tabs >}}
|
||||
|
||||
Validate the kubectl binary against the checksum file:
|
||||
|
||||
```bash
|
||||
echo "$(cat kubectl.sha256) kubectl" | shasum -a 256 --check
|
||||
```
|
||||
|
||||
If valid, the output is:
|
||||
|
||||
```console
|
||||
kubectl: OK
|
||||
```
|
||||
|
||||
If the check fails, `shasum` exits with nonzero status and prints output similar to:
|
||||
|
||||
```console
|
||||
kubectl: FAILED
|
||||
shasum: WARNING: 1 computed checksum did NOT match
|
||||
```
|
||||
|
||||
{{< note >}}
|
||||
Download the same version of the binary and checksum.
|
||||
{{< /note >}}
|
||||
|
||||
1. Make the kubectl binary executable.
|
||||
|
||||
```bash
|
||||
chmod +x ./kubectl
|
||||
```
|
||||
|
||||
1. Move the kubectl binary to a file location on your system `PATH`.
|
||||
|
||||
```bash
|
||||
sudo mv ./kubectl /usr/local/bin/kubectl
|
||||
sudo chown root: /usr/local/bin/kubectl
|
||||
```
|
||||
|
||||
{{< note >}}
|
||||
Make sure `/usr/local/bin` is in your PATH environment variable.
|
||||
{{< /note >}}
|
||||
|
||||
1. Test to ensure the version you installed is up-to-date:
|
||||
|
||||
```bash
|
||||
kubectl version --client
|
||||
```
|
||||
|
||||
Or use this for detailed view of version:
|
||||
|
||||
```cmd
|
||||
kubectl version --client --output=yaml
|
||||
```
|
||||
|
||||
1. After installing and validating kubectl, delete the checksum file:
|
||||
|
||||
```bash
|
||||
rm kubectl.sha256
|
||||
```
|
||||
|
||||
### Install with Homebrew on macOS
|
||||
|
||||
If you are on macOS and using [Homebrew](https://brew.sh/) package manager,
|
||||
you can install kubectl with Homebrew.
|
||||
|
||||
1. Run the installation command:
|
||||
|
||||
```bash
|
||||
brew install kubectl
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```bash
|
||||
brew install kubernetes-cli
|
||||
```
|
||||
|
||||
1. Test to ensure the version you installed is up-to-date:
|
||||
|
||||
```bash
|
||||
kubectl version --client
|
||||
```
|
||||
|
||||
### Install with Macports on macOS
|
||||
|
||||
If you are on macOS and using [Macports](https://macports.org/) package manager,
|
||||
you can install kubectl with Macports.
|
||||
|
||||
1. Run the installation command:
|
||||
|
||||
```bash
|
||||
sudo port selfupdate
|
||||
sudo port install kubectl
|
||||
```
|
||||
|
||||
1. Test to ensure the version you installed is up-to-date:
|
||||
|
||||
```bash
|
||||
kubectl version --client
|
||||
```
|
||||
|
||||
## Verify kubectl configuration
|
||||
|
||||
{{< include "included/verify-kubectl.md" >}}
|
||||
|
||||
## Optional kubectl configurations and plugins
|
||||
|
||||
### Enable shell autocompletion
|
||||
|
||||
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.
|
||||
|
||||
{{< tabs name="kubectl_autocompletion" >}}
|
||||
{{< tab name="Bash" include="included/optional-kubectl-configs-bash-mac.md" />}}
|
||||
{{< tab name="Fish" include="included/optional-kubectl-configs-fish.md" />}}
|
||||
{{< tab name="Zsh" include="included/optional-kubectl-configs-zsh.md" />}}
|
||||
{{< /tabs >}}
|
||||
|
||||
### Install `kubectl convert` plugin
|
||||
|
||||
{{< include "included/kubectl-convert-overview.md" >}}
|
||||
|
||||
1. Download the latest release with the command:
|
||||
|
||||
{{< tabs name="download_convert_binary_macos" >}}
|
||||
{{< tab name="Intel" codelang="bash" >}}
|
||||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/amd64/kubectl-convert"
|
||||
{{< /tab >}}
|
||||
{{< tab name="Apple Silicon" codelang="bash" >}}
|
||||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/arm64/kubectl-convert"
|
||||
{{< /tab >}}
|
||||
{{< /tabs >}}
|
||||
|
||||
1. Validate the binary (optional)
|
||||
|
||||
Download the kubectl-convert checksum file:
|
||||
|
||||
{{< tabs name="download_convert_checksum_macos" >}}
|
||||
{{< tab name="Intel" codelang="bash" >}}
|
||||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/amd64/kubectl-convert.sha256"
|
||||
{{< /tab >}}
|
||||
{{< tab name="Apple Silicon" codelang="bash" >}}
|
||||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/arm64/kubectl-convert.sha256"
|
||||
{{< /tab >}}
|
||||
{{< /tabs >}}
|
||||
|
||||
Validate the kubectl-convert binary against the checksum file:
|
||||
|
||||
```bash
|
||||
echo "$(cat kubectl-convert.sha256) kubectl-convert" | shasum -a 256 --check
|
||||
```
|
||||
|
||||
If valid, the output is:
|
||||
|
||||
```console
|
||||
kubectl-convert: OK
|
||||
```
|
||||
|
||||
If the check fails, `shasum` exits with nonzero status and prints output similar to:
|
||||
|
||||
```console
|
||||
kubectl-convert: FAILED
|
||||
shasum: WARNING: 1 computed checksum did NOT match
|
||||
```
|
||||
|
||||
{{< note >}}
|
||||
Download the same version of the binary and checksum.
|
||||
{{< /note >}}
|
||||
|
||||
1. Make kubectl-convert binary executable
|
||||
|
||||
```bash
|
||||
chmod +x ./kubectl-convert
|
||||
```
|
||||
|
||||
1. Move the kubectl-convert binary to a file location on your system `PATH`.
|
||||
|
||||
```bash
|
||||
sudo mv ./kubectl-convert /usr/local/bin/kubectl-convert
|
||||
sudo chown root: /usr/local/bin/kubectl-convert
|
||||
```
|
||||
|
||||
{{< note >}}
|
||||
Make sure `/usr/local/bin` is in your PATH environment variable.
|
||||
{{< /note >}}
|
||||
|
||||
1. Verify plugin is successfully installed
|
||||
|
||||
```shell
|
||||
kubectl convert --help
|
||||
```
|
||||
|
||||
If you do not see an error, it means the plugin is successfully installed.
|
||||
|
||||
1. After installing the plugin, clean up the installation files:
|
||||
|
||||
```bash
|
||||
rm kubectl-convert kubectl-convert.sha256
|
||||
```
|
||||
|
||||
### Uninstall kubectl on macOS
|
||||
|
||||
Depending on how you installed `kubectl`, use one of the following methods.
|
||||
|
||||
### Uninstall kubectl using the command-line
|
||||
|
||||
1. Locate the `kubectl` binary on your system:
|
||||
|
||||
```bash
|
||||
which kubectl
|
||||
```
|
||||
|
||||
1. Remove the `kubectl` binary:
|
||||
|
||||
```bash
|
||||
sudo rm <path>
|
||||
```
|
||||
Replace `<path>` with the path to the `kubectl` binary from the previous step. For example, `sudo rm /usr/local/bin/kubectl`.
|
||||
|
||||
### Uninstall kubectl using homebrew
|
||||
|
||||
If you installed `kubectl` using Homebrew, run the following command:
|
||||
|
||||
```bash
|
||||
brew remove kubectl
|
||||
```
|
||||
|
||||
## {{% heading "whatsnext" %}}
|
||||
|
||||
{{< include "included/kubectl-whats-next.md" >}}
|
||||
|
||||
|
|
@ -0,0 +1,203 @@
|
|||
---
|
||||
title: Windows上でのkubectlのインストールおよびセットアップ
|
||||
content_type: task
|
||||
weight: 10
|
||||
---
|
||||
|
||||
## {{% heading "prerequisites" %}}
|
||||
|
||||
kubectlのバージョンは、クラスターのマイナーバージョンとの差分が1つ以内でなければなりません。
|
||||
たとえば、クライアントがv{{< skew currentVersion >}}であれば、v{{< skew currentVersionAddMinor -1 >}}、v{{< skew currentVersionAddMinor 0 >}}、v{{< skew currentVersionAddMinor 1 >}}のコントロールプレーンと通信できます。
|
||||
最新の互換性のあるバージョンのkubectlを使うことで、不測の事態を避けることができるでしょう。
|
||||
|
||||
## Windowsへkubectlをインストールする
|
||||
|
||||
Windowsへkubectlをインストールするには、次の方法があります:
|
||||
|
||||
- [curlを使用してWindowsへkubectlのバイナリをインストールする](#install-kubectl-binary-with-curl-on-windows)
|
||||
- [Chocolatey、Scoopまたはwingetを使用してWindowsへインストールする](#install-nonstandard-package-tools)
|
||||
|
||||
### curlを使用してWindowsへkubectlのバイナリをインストールする{#install-kubectl-binary-with-curl-on-windows}
|
||||
|
||||
1. 最新の{{< skew currentVersion >}}のパッチリリースをダウンロードしてください:
|
||||
[kubectl {{< skew currentPatchVersion >}}](https://dl.k8s.io/release/v{{< skew currentPatchVersion >}}/bin/windows/amd64/kubectl.exe)。
|
||||
|
||||
または、`curl`がインストールされていれば、次のコマンドも使用できます:
|
||||
|
||||
```powershell
|
||||
curl.exe -LO "https://dl.k8s.io/release/v{{< skew currentPatchVersion >}}/bin/windows/amd64/kubectl.exe"
|
||||
```
|
||||
|
||||
{{< note >}}
|
||||
最新の安定版を入手する際は(たとえばスクリプトで使用する場合)、[https://dl.k8s.io/release/stable.txt](https://dl.k8s.io/release/stable.txt)を参照してください。
|
||||
{{< /note >}}
|
||||
|
||||
1. バイナリを検証してください(オプション)
|
||||
|
||||
`kubectl`のチェックサムファイルをダウンロードします:
|
||||
|
||||
```powershell
|
||||
curl.exe -LO "https://dl.k8s.io/v{{< skew currentPatchVersion >}}/bin/windows/amd64/kubectl.exe.sha256"
|
||||
```
|
||||
|
||||
チェックサムファイルに対して`kubectl`バイナリを検証します:
|
||||
|
||||
- コマンドプロンプトを使用して、`CertUtil`の出力とダウンロードしたチェックサムファイルを手動で比較します:
|
||||
|
||||
```cmd
|
||||
CertUtil -hashfile kubectl.exe SHA256
|
||||
type kubectl.exe.sha256
|
||||
```
|
||||
|
||||
- PowerShellにて`-eq`オペレーターを使用して自動で検証を行い、`True`または`False`で結果を取得します:
|
||||
|
||||
```powershell
|
||||
$(Get-FileHash -Algorithm SHA256 .\kubectl.exe).Hash -eq $(Get-Content .\kubectl.exe.sha256)
|
||||
```
|
||||
|
||||
1. `kubectl`バイナリのフォルダーを`PATH`環境変数に追加します。
|
||||
|
||||
1. `kubectl`のバージョンがダウンロードしたものと同じであることを確認してください:
|
||||
|
||||
```cmd
|
||||
kubectl version --client
|
||||
```
|
||||
|
||||
または、バージョンの詳細を表示するために次を使用します:
|
||||
|
||||
```cmd
|
||||
kubectl version --client --output=yaml
|
||||
```
|
||||
|
||||
|
||||
|
||||
{{< note >}}
|
||||
[Docker Desktop for Windows](https://docs.docker.com/docker-for-windows/#kubernetes)は、それ自身のバージョンの`kubectl`を`PATH`に追加します。
|
||||
Docker Desktopをすでにインストールしている場合、Docker Desktopインストーラーによって追加された`PATH`の前に追加するか、Docker Desktopの`kubectl`を削除してください。
|
||||
{{< /note >}}
|
||||
|
||||
### Chocolatey、Scoopまたはwingetを使用してWindowsへインストールする{#install-nonstandard-package-tools}
|
||||
|
||||
1. Windowsへkubectlをインストールするために、[Chocolatey](https://chocolatey.org)パッケージマネージャーや[Scoop](https://scoop.sh)コマンドラインインストーラー、[winget](https://learn.microsoft.com/en-us/windows/package-manager/winget/)パッケージマネージャーを使用することもできます。
|
||||
|
||||
{{< tabs name="kubectl_win_install" >}}
|
||||
{{% tab name="choco" %}}
|
||||
```powershell
|
||||
choco install kubernetes-cli
|
||||
```
|
||||
{{% /tab %}}
|
||||
{{% tab name="scoop" %}}
|
||||
```powershell
|
||||
scoop install kubectl
|
||||
```
|
||||
{{% /tab %}}
|
||||
{{% tab name="winget" %}}
|
||||
```powershell
|
||||
winget install -e --id Kubernetes.kubectl
|
||||
```
|
||||
{{% /tab %}}
|
||||
{{< /tabs >}}
|
||||
|
||||
1. インストールしたバージョンが最新であることを確認してください:
|
||||
|
||||
```powershell
|
||||
kubectl version --client
|
||||
```
|
||||
|
||||
1. ホームディレクトリへ移動してください:
|
||||
|
||||
```powershell
|
||||
# cmd.exeを使用している場合はcd %USERPROFILE%を実行してください。
|
||||
cd ~
|
||||
```
|
||||
|
||||
1. `.kube`ディレクトリを作成してください:
|
||||
|
||||
```powershell
|
||||
mkdir .kube
|
||||
```
|
||||
|
||||
1. 作成した`.kube`ディレクトリへ移動してください:
|
||||
|
||||
```powershell
|
||||
cd .kube
|
||||
```
|
||||
|
||||
1. リモートのKubernetesクラスターを使うために、kubectlを設定してください:
|
||||
|
||||
```powershell
|
||||
New-Item config -type file
|
||||
```
|
||||
|
||||
{{< note >}}
|
||||
Notepadなどの選択したテキストエディターから設定ファイルを編集してください。
|
||||
{{< /note >}}
|
||||
|
||||
## kubectlの設定を検証する
|
||||
|
||||
{{< include "included/verify-kubectl.md" >}}
|
||||
|
||||
## オプションのkubectlの設定とプラグイン
|
||||
|
||||
### シェルの自動補完を有効にする
|
||||
|
||||
kubectlはBash、Zsh、Fish、PowerShellの自動補完を提供しています。
|
||||
これにより、入力を大幅に削減することができます。
|
||||
|
||||
以下にPowerShellの自動補完の設定手順を示します。
|
||||
|
||||
{{< include "included/optional-kubectl-configs-pwsh.md" >}}
|
||||
|
||||
### `kubectl convert`プラグインをインストールする
|
||||
|
||||
{{< include "included/kubectl-convert-overview.md" >}}
|
||||
|
||||
1. 次のコマンドを使用して最新リリースをダウンロードしてください:
|
||||
|
||||
```powershell
|
||||
curl.exe -LO "https://dl.k8s.io/release/v{{< skew currentPatchVersion >}}/bin/windows/amd64/kubectl-convert.exe"
|
||||
```
|
||||
|
||||
1. バイナリを検証してください(オプション)。
|
||||
|
||||
`kubectl-convert`のチェックサムファイルをダウンロードします:
|
||||
|
||||
```powershell
|
||||
curl.exe -LO "https://dl.k8s.io/v{{< skew currentPatchVersion >}}/bin/windows/amd64/kubectl-convert.exe.sha256"
|
||||
```
|
||||
|
||||
チェックサムファイルに対して`kubectl-convert`バイナリを検証します:
|
||||
|
||||
- コマンドプロンプトを使用して、`CertUtil`の出力とダウンロードしたチェックサムファイルを手動で比較します:
|
||||
|
||||
```cmd
|
||||
CertUtil -hashfile kubectl-convert.exe SHA256
|
||||
type kubectl-convert.exe.sha256
|
||||
```
|
||||
|
||||
- PowerShellにて`-eq`オペレーターを使用して自動で検証を行い、`True`または`False`で結果を取得します:
|
||||
|
||||
```powershell
|
||||
$($(CertUtil -hashfile .\kubectl-convert.exe SHA256)[1] -replace " ", "") -eq $(type .\kubectl-convert.exe.sha256)
|
||||
```
|
||||
|
||||
1. `kubectl-convert`バイナリのフォルダーを`PATH`環境変数に追加します。
|
||||
|
||||
1. プラグインが正常にインストールされたことを確認してください。
|
||||
|
||||
```shell
|
||||
kubectl convert --help
|
||||
```
|
||||
|
||||
何もエラーが表示されない場合は、プラグインが正常にインストールされたことを示しています。
|
||||
|
||||
1. プラグインのインストール後、インストールファイルを削除してください:
|
||||
|
||||
```powershell
|
||||
del kubectl-convert.exe
|
||||
del kubectl-convert.exe.sha256
|
||||
```
|
||||
|
||||
## {{% heading "whatsnext" %}}
|
||||
|
||||
{{< include "included/kubectl-whats-next.md" >}}
|
Loading…
Reference in New Issue