Update kubectl isntall docs to refer to packaged versions of binary (#7669)
This commit is contained in:
@@ -16,10 +16,107 @@ Use a version of kubectl that is the same version as your server or later. Using
|
|||||||
## Install kubectl
|
## Install kubectl
|
||||||
|
|
||||||
Here are a few methods to install kubectl.
|
Here are a few methods to install kubectl.
|
||||||
Pick the one that suits your environment best.
|
|
||||||
|
|
||||||
{% capture steps %}
|
{% capture steps %}
|
||||||
### Install kubectl binary via curl
|
|
||||||
|
## Install kubectl binary via native package management
|
||||||
|
|
||||||
|
{% capture ubuntu %}
|
||||||
|
|
||||||
|
```bash
|
||||||
|
apt-get update && apt-get install -y apt-transport-https
|
||||||
|
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
|
||||||
|
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
|
||||||
|
deb http://apt.kubernetes.io/ kubernetes-xenial main
|
||||||
|
EOF
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y kubectl
|
||||||
|
```
|
||||||
|
|
||||||
|
{% endcapture %}
|
||||||
|
|
||||||
|
{% capture centos %}
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
|
||||||
|
[kubernetes]
|
||||||
|
name=Kubernetes
|
||||||
|
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
|
||||||
|
enabled=1
|
||||||
|
gpgcheck=1
|
||||||
|
repo_gpgcheck=1
|
||||||
|
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
|
||||||
|
EOF
|
||||||
|
yum install -y kubectl
|
||||||
|
```
|
||||||
|
|
||||||
|
{% endcapture %}
|
||||||
|
|
||||||
|
{% assign tab_set_name = "kubectl_install" %}
|
||||||
|
{% assign tab_names = "Ubuntu, Debian or HypriotOS;CentOS, RHEL or Fedora" | split: ';' | compact %}
|
||||||
|
{% assign tab_contents = site.emptyArray | push: ubuntu | push: centos %}
|
||||||
|
|
||||||
|
{% include tabs.md %}
|
||||||
|
|
||||||
|
## Install with snap on Ubuntu
|
||||||
|
|
||||||
|
kubectl is available as a [snap](https://snapcraft.io/) application.
|
||||||
|
|
||||||
|
1. If you are on Ubuntu or one of other Linux distributions that support [snap](https://snapcraft.io/docs/core/install) package manager, you can install with:
|
||||||
|
|
||||||
|
sudo snap install kubectl --classic
|
||||||
|
|
||||||
|
2. Run `kubectl version` to verify that the version you've installed is sufficiently up-to-date.
|
||||||
|
|
||||||
|
## Install with Homebrew on macOS
|
||||||
|
|
||||||
|
1. If you are on macOS and using [Homebrew](https://brew.sh/) package manager, you can install with:
|
||||||
|
|
||||||
|
brew install kubectl
|
||||||
|
|
||||||
|
2. Run `kubectl version` to verify that the version you've installed is sufficiently up-to-date.
|
||||||
|
|
||||||
|
## Install with Powershell from PSGallery
|
||||||
|
|
||||||
|
1. If you are on Windows and using [Powershell Gallery](https://www.powershellgallery.com/) package manager, you can install and update with:
|
||||||
|
|
||||||
|
Install-Script -Name install-kubectl -Scope CurrentUser -Force
|
||||||
|
install-kubectl.ps1 [-DownloadLocation <path>]
|
||||||
|
|
||||||
|
If no Downloadlocation is specified, kubectl will be installed in users temp Directory
|
||||||
|
2. The installer creates $HOME/.kube and instructs it to create a config file
|
||||||
|
3. Updating
|
||||||
|
re-run Install-Script to update the installer
|
||||||
|
re-run install-kubectl.ps1 to install latest binaries
|
||||||
|
|
||||||
|
## Install with Chocolatey on Windows
|
||||||
|
|
||||||
|
1. If you are on Windows and using [Chocolatey](https://chocolatey.org) package manager, you can install with:
|
||||||
|
|
||||||
|
choco install kubernetes-cli
|
||||||
|
|
||||||
|
2. Run `kubectl version` to verify that the version you've installed is sufficiently up-to-date.
|
||||||
|
3. Configure kubectl to use a remote Kubernetes cluster:
|
||||||
|
|
||||||
|
cd C:\users\yourusername (Or wherever your %HOME% directory is)
|
||||||
|
mkdir .kube
|
||||||
|
cd .kube
|
||||||
|
New-Item config -type file
|
||||||
|
|
||||||
|
Edit the config file with a text editor of your choice, such as Notepad for example.
|
||||||
|
|
||||||
|
## Download as part of the Google Cloud SDK
|
||||||
|
|
||||||
|
kubectl can be installed as part of the Google Cloud SDK.
|
||||||
|
|
||||||
|
1. Install the [Google Cloud SDK](https://cloud.google.com/sdk/).
|
||||||
|
2. Run the following command to install `kubectl`:
|
||||||
|
|
||||||
|
gcloud components install kubectl
|
||||||
|
|
||||||
|
3. Run `kubectl version` to verify that the version you've installed is sufficiently up-to-date.
|
||||||
|
|
||||||
|
## Install kubectl binary via curl
|
||||||
|
|
||||||
{% capture macos %}
|
{% capture macos %}
|
||||||
1. Download the latest release with the command:
|
1. Download the latest release with the command:
|
||||||
@@ -87,64 +184,6 @@ Pick the one that suits your environment best.
|
|||||||
|
|
||||||
{% include tabs.md %}
|
{% include tabs.md %}
|
||||||
|
|
||||||
### Download as part of the Google Cloud SDK
|
|
||||||
|
|
||||||
kubectl can be installed as part of the Google Cloud SDK.
|
|
||||||
|
|
||||||
1. Install the [Google Cloud SDK](https://cloud.google.com/sdk/).
|
|
||||||
2. Run the following command to install `kubectl`:
|
|
||||||
|
|
||||||
gcloud components install kubectl
|
|
||||||
|
|
||||||
3. Run `kubectl version` to verify that the version you've installed is sufficiently up-to-date.
|
|
||||||
|
|
||||||
### Install with snap on Ubuntu
|
|
||||||
|
|
||||||
kubectl is available as a [snap](https://snapcraft.io/) application.
|
|
||||||
|
|
||||||
1. If you are on Ubuntu or one of other Linux distributions that support [snap](https://snapcraft.io/docs/core/install) package manager, you can install with:
|
|
||||||
|
|
||||||
sudo snap install kubectl --classic
|
|
||||||
|
|
||||||
2. Run `kubectl version` to verify that the version you've installed is sufficiently up-to-date.
|
|
||||||
|
|
||||||
### Install with Homebrew on macOS
|
|
||||||
|
|
||||||
1. If you are on macOS and using [Homebrew](https://brew.sh/) package manager, you can install with:
|
|
||||||
|
|
||||||
brew install kubectl
|
|
||||||
|
|
||||||
2. Run `kubectl version` to verify that the version you've installed is sufficiently up-to-date.
|
|
||||||
|
|
||||||
### Install with Powershell from PSGallery
|
|
||||||
|
|
||||||
1. If you are on Windows and using [Powershell Gallery](https://www.powershellgallery.com/) package manager, you can install and update with:
|
|
||||||
|
|
||||||
Install-Script -Name install-kubectl -Scope CurrentUser -Force
|
|
||||||
install-kubectl.ps1 [-DownloadLocation <path>]
|
|
||||||
|
|
||||||
If no Downloadlocation is specified, kubectl will be installed in users temp Directory
|
|
||||||
2. The installer creates $HOME/.kube and instructs it to create a config file
|
|
||||||
3. Updating
|
|
||||||
re-run Install-Script to update the installer
|
|
||||||
re-run install-kubectl.ps1 to install latest binaries
|
|
||||||
|
|
||||||
### Install with Chocolatey on Windows
|
|
||||||
|
|
||||||
1. If you are on Windows and using [Chocolatey](https://chocolatey.org) package manager, you can install with:
|
|
||||||
|
|
||||||
choco install kubernetes-cli
|
|
||||||
|
|
||||||
2. Run `kubectl version` to verify that the version you've installed is sufficiently up-to-date.
|
|
||||||
3. Configure kubectl to use a remote Kubernetes cluster:
|
|
||||||
|
|
||||||
cd C:\users\yourusername (Or wherever your %HOME% directory is)
|
|
||||||
mkdir .kube
|
|
||||||
cd .kube
|
|
||||||
New-Item config -type file
|
|
||||||
|
|
||||||
Edit the config file with a text editor of your choice, such as Notepad for example.
|
|
||||||
|
|
||||||
## Configure kubectl
|
## Configure kubectl
|
||||||
|
|
||||||
In order for kubectl to find and access a Kubernetes cluster, it needs a [kubeconfig file](/docs/tasks/access-application-cluster/configure-access-multiple-clusters/), which is created automatically when you create a cluster using kube-up.sh or successfully deploy a Minikube cluster. See the [getting started guides](/docs/setup/) for more about creating clusters. If you need access to a cluster you didn't create, see the [Sharing Cluster Access document](/docs/tasks/access-application-cluster/configure-access-multiple-clusters/).
|
In order for kubectl to find and access a Kubernetes cluster, it needs a [kubeconfig file](/docs/tasks/access-application-cluster/configure-access-multiple-clusters/), which is created automatically when you create a cluster using kube-up.sh or successfully deploy a Minikube cluster. See the [getting started guides](/docs/setup/) for more about creating clusters. If you need access to a cluster you didn't create, see the [Sharing Cluster Access document](/docs/tasks/access-application-cluster/configure-access-multiple-clusters/).
|
||||||
@@ -166,7 +205,6 @@ The connection to the server <server-name:port> was refused - did you specify th
|
|||||||
|
|
||||||
For example, if you are intending to run a Kubernetes cluster on your laptop (locally), you will need a tool like minikube to be installed first and then re-run the commands stated above.
|
For example, if you are intending to run a Kubernetes cluster on your laptop (locally), you will need a tool like minikube to be installed first and then re-run the commands stated above.
|
||||||
|
|
||||||
|
|
||||||
If kubectl cluster-info returns the url response but you can't access your cluster, to check whether it is configured properly, use:
|
If kubectl cluster-info returns the url response but you can't access your cluster, to check whether it is configured properly, use:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
@@ -224,7 +262,6 @@ fi
|
|||||||
|
|
||||||
Or when using [Oh-My-Zsh](http://ohmyz.sh/), edit the ~/.zshrc file and update the `plugins=` line to include the kubectl plugin.
|
Or when using [Oh-My-Zsh](http://ohmyz.sh/), edit the ~/.zshrc file and update the `plugins=` line to include the kubectl plugin.
|
||||||
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
source <(kubectl completion zsh)
|
source <(kubectl completion zsh)
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user