Update directions for macOS bash completion

This commit is contained in:
Christoph Blecker
2017-05-16 16:44:39 -07:00
parent 9f2ecee260
commit 1bb02c055e
+20 -19
View File
@@ -7,14 +7,14 @@ redirect_from:
- "/docs/tasks/kubectl/install/" - "/docs/tasks/kubectl/install/"
- "/docs/tasks/kubectl/install.html" - "/docs/tasks/kubectl/install.html"
- "/docs/user-guide/prereqs/" - "/docs/user-guide/prereqs/"
- "/docs/user-guide/prereqs.html" - "/docs/user-guide/prereqs.html"
--- ---
{% capture overview %} {% capture overview %}
Use the Kubernetes command-line tool, [kubectl](/docs/user-guide/kubectl), to deploy and manage applications on Kubernetes. Using kubectl, you can inspect cluster resources; create, delete, and update components; and look at your new cluster and bring up example apps. Use the Kubernetes command-line tool, [kubectl](/docs/user-guide/kubectl), to deploy and manage applications on Kubernetes. Using kubectl, you can inspect cluster resources; create, delete, and update components; and look at your new cluster and bring up example apps.
{% endcapture %} {% endcapture %}
{% capture prerequisites %} {% capture prerequisites %}
Use a version of kubectl that is the same version as your server or later. Using an older kubectl with a newer server might produce validation errors. Use a version of kubectl that is the same version as your server or later. Using an older kubectl with a newer server might produce validation errors.
{% endcapture %} {% endcapture %}
Here are a few methods to install kubectl. Here are a few methods to install kubectl.
@@ -26,7 +26,7 @@ Here are a few methods to install kubectl.
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/darwin/amd64/kubectl curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/darwin/amd64/kubectl
To download a specific version, replace the `$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)` portion of the command with the specific version. To download a specific version, replace the `$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)` portion of the command with the specific version.
For example, to download version {{page.fullversion}} on MacOS, type: For example, to download version {{page.fullversion}} on MacOS, type:
@@ -38,7 +38,7 @@ Here are a few methods to install kubectl.
chmod +x ./kubectl chmod +x ./kubectl
``` ```
3. Move the binary in to your PATH. 3. Move the binary in to your PATH.
``` ```
sudo mv ./kubectl /usr/local/bin/kubectl sudo mv ./kubectl /usr/local/bin/kubectl
@@ -50,9 +50,9 @@ Here are a few methods to install kubectl.
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
To download a specific version, replace the `$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)` portion of the command with the specific version. To download a specific version, replace the `$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)` portion of the command with the specific version.
For example, to download version {{page.fullversion}} on Linux, type: For example, to download version {{page.fullversion}} on Linux, type:
curl -LO https://storage.googleapis.com/kubernetes-release/release/{{page.fullversion}}/bin/linux/amd64/kubectl curl -LO https://storage.googleapis.com/kubernetes-release/release/{{page.fullversion}}/bin/linux/amd64/kubectl
@@ -62,7 +62,7 @@ Here are a few methods to install kubectl.
chmod +x ./kubectl chmod +x ./kubectl
``` ```
3. Move the binary in to your PATH. 3. Move the binary in to your PATH.
``` ```
sudo mv ./kubectl /usr/local/bin/kubectl sudo mv ./kubectl /usr/local/bin/kubectl
@@ -97,7 +97,7 @@ kubectl can be installed as part of the Google Cloud SDK.
gcloud components install kubectl gcloud components install kubectl
``` ```
3. Run `kubectl version` to verify that the verison you've installed is sufficiently up-to-date. 3. Run `kubectl version` to verify that the verison you've installed is sufficiently up-to-date.
## Install with Homebrew on macOS ## Install with Homebrew on macOS
1. If you are on macOS and using [Homebrew](https://brew.sh/) package manager, you can install with: 1. If you are on macOS and using [Homebrew](https://brew.sh/) package manager, you can install with:
@@ -117,7 +117,7 @@ Check that kubectl is properly configured by getting the cluster state:
```shell ```shell
$ kubectl cluster-info $ kubectl cluster-info
``` ```
If you see a URL response, kubectl is correctly configured to access your cluster. If you see a URL response, kubectl is correctly configured to access your cluster.
If you see a message similar to the following, kubectl is not correctly configured: If you see a message similar to the following, kubectl is not correctly configured:
```shell ```shell
@@ -142,28 +142,29 @@ echo "source <(kubectl completion bash)" >> ~/.bashrc
``` ```
### On macOS, using bash ### On macOS, using bash
On macOS, autocompletion works if you install using `brew install kubectl`, On macOS, you will need to install bash-completion support via [Homebrew](https://brew.sh/) first:
and not if you downloaded kubectl directly.
Install the bash-completion support:
```shell ```shell
## If running Bash 3.2 included with macOS
brew install bash-completion brew install bash-completion
## or, if running Bash 4.1+
bash install bash-completion@2
``` ```
To add kubectl autocompletion to your current shell, run: Follow the "caveats" section of brew's output to add the appropriate bash completion path to your local .bashrc.
```shell If you've installed kubectl using the [Homebrew instructions](#install-with-homebrew-on-macos) then kubectl completion should start working immediately.
source $(brew --prefix)/etc/bash_completion
source <(kubectl completion bash) If you have installed kubectl manually, then run: `source <(kubectl completion bash)`
```
To add kubectl autocompletion to your profile (so it is automatically loaded in future shells): To add kubectl autocompletion to your profile (so it is automatically loaded in future shells):
```shell ```shell
echo "source $(brew --prefix)/etc/bash_completion" >> ~/.bash_profile
echo "source <(kubectl completion bash)" >> ~/.bash_profile echo "source <(kubectl completion bash)" >> ~/.bash_profile
``` ```
The Homebrew project is independent from kubernetes, so the bash-completion packages are not guaranteed to work.
{% endcapture %} {% endcapture %}
{% capture whatsnext %} {% capture whatsnext %}
[Learn how to launch and expose your application.](/docs/user-guide/quick-start) [Learn how to launch and expose your application.](/docs/user-guide/quick-start)