Merge pull request #3737 from cblecker/update-mac-bash

Update directions for macOS bash completion
This commit is contained in:
Andrew Chen
2017-06-06 09:02:44 -07:00
committed by GitHub
+20 -19
View File
@@ -7,14 +7,14 @@ redirect_from:
- "/docs/tasks/kubectl/install/"
- "/docs/tasks/kubectl/install.html"
- "/docs/user-guide/prereqs/"
- "/docs/user-guide/prereqs.html"
- "/docs/user-guide/prereqs.html"
---
{% 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.
{% endcapture %}
{% 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 %}
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
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:
@@ -38,7 +38,7 @@ Here are a few methods to install 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
@@ -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
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
@@ -62,7 +62,7 @@ Here are a few methods to install 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
@@ -97,7 +97,7 @@ kubectl can be installed as part of the Google Cloud SDK.
gcloud components install kubectl
```
3. Run `kubectl version` to verify that the verison 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:
@@ -117,7 +117,7 @@ Check that kubectl is properly configured by getting the cluster state:
```shell
$ 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:
```shell
@@ -142,28 +142,29 @@ echo "source <(kubectl completion bash)" >> ~/.bashrc
```
### On macOS, using bash
On macOS, autocompletion works if you install using `brew install kubectl`,
and not if you downloaded kubectl directly.
Install the bash-completion support:
On macOS, you will need to install bash-completion support via [Homebrew](https://brew.sh/) first:
```shell
## If running Bash 3.2 included with macOS
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
source $(brew --prefix)/etc/bash_completion
source <(kubectl completion bash)
```
If you've installed kubectl using the [Homebrew instructions](#install-with-homebrew-on-macos) then kubectl completion should start working immediately.
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):
```shell
echo "source $(brew --prefix)/etc/bash_completion" >> ~/.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 %}
{% capture whatsnext %}
[Learn how to launch and expose your application.](/docs/user-guide/quick-start)