From 441043a22a59d34b34cbdcdf8dc2437c552ef5c8 Mon Sep 17 00:00:00 2001 From: Justin Santa Barbara Date: Wed, 19 Oct 2016 13:08:21 -0400 Subject: [PATCH 1/4] Instructions for how to download kubectl --- _data/guides.yml | 2 + docs/getting-started-guides/kubectl.md | 63 ++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 docs/getting-started-guides/kubectl.md diff --git a/_data/guides.yml b/_data/guides.yml index 40d47b08d6..e77e8e1b01 100644 --- a/_data/guides.yml +++ b/_data/guides.yml @@ -12,6 +12,8 @@ toc: path: /docs/getting-started-guides/kubeadm/ - title: Hello World on Google Container Engine path: /docs/hellonode/ + - title: Downloading kubectl + path: /docs/getting-started-guides/kubectl/ - title: Downloading or Building Kubernetes path: /docs/getting-started-guides/binary_release/ - title: Online Training Course diff --git a/docs/getting-started-guides/kubectl.md b/docs/getting-started-guides/kubectl.md new file mode 100644 index 0000000000..6c5043e744 --- /dev/null +++ b/docs/getting-started-guides/kubectl.md @@ -0,0 +1,63 @@ +--- +--- + + + +## Overview + +kubectl is the command line tool you will use when interacting with kubernetes. + +You should use a version of kubectl that is newer than your server. `kubectl version` will print +the server and client versions. + +## Download a release + +Download kubectl from the [official Kubernetes releases](https://console.cloud.google.com/storage/browser/kubernetes-release/release/): + +On MacOS: + +``` +wget https://storage.googleapis.com/kubernetes-release/release/v1.4.3/bin/darwin/amd64/kubectl +chmod +x kubectl +mv kubectl /usr/local/bin/kubectl +``` + +On Linux: + +``` +wget https://storage.googleapis.com/kubernetes-release/release/v1.4.3/bin/linux/amd64/kubectl +chmod +x kubectl +mv kubectl /usr/local/bin/kubectl +``` + + +You may need to `sudo` the `mv`; you can put it anywhere in your `PATH` - some people prefer to install to `~/bin`. + + +## Alternatives + +### Download as part of the Google Cloud SDK + +kubectl can be installed as part of the Google Cloud SDK: + +First install the [Google Cloud SDK](https://cloud.google.com/sdk/). + +After Google Cloud SDK installs, run the following command to install `kubectl`: + +```shell +gcloud components install kubectl +``` + +Do check that the version is sufficiently up-to-date using `kubectl version --client`. + +### Install with brew + +If you are on MacOS and using brew, you can install with: + +```shell +brew install kubectl +``` + +Do check that the version is sufficiently up-to-date using `kubectl version --client`. From 0ebd20ccfbb56b1e3730ad5d559de5e7377d12a8 Mon Sep 17 00:00:00 2001 From: Justin Santa Barbara Date: Fri, 21 Oct 2016 21:05:23 -0400 Subject: [PATCH 2/4] Fixes per code review --- _data/guides.yml | 2 +- docs/getting-started-guides/kubectl.md | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/_data/guides.yml b/_data/guides.yml index e77e8e1b01..a661cbfb9a 100644 --- a/_data/guides.yml +++ b/_data/guides.yml @@ -12,7 +12,7 @@ toc: path: /docs/getting-started-guides/kubeadm/ - title: Hello World on Google Container Engine path: /docs/hellonode/ - - title: Downloading kubectl + - title: Installing kubectl path: /docs/getting-started-guides/kubectl/ - title: Downloading or Building Kubernetes path: /docs/getting-started-guides/binary_release/ diff --git a/docs/getting-started-guides/kubectl.md b/docs/getting-started-guides/kubectl.md index 6c5043e744..0498ceb646 100644 --- a/docs/getting-started-guides/kubectl.md +++ b/docs/getting-started-guides/kubectl.md @@ -7,10 +7,12 @@ li>.highlighter-rouge {position:relative; top:3px;} ## Overview -kubectl is the command line tool you will use when interacting with kubernetes. +kubectl is the command line tool you use to interact with Kubernetes clusters. -You should use a version of kubectl that is newer than your server. `kubectl version` will print -the server and client versions. +You should use a version of kubectl that is at least as new as your server. +`kubectl version` will print the server and client versions. Using the same version of kubectl +as your server naturally works; using a newer kubectl than your server also works; but if you use +an older kubectl with a newer server you may see odd validation errors . ## Download a release @@ -18,16 +20,16 @@ Download kubectl from the [official Kubernetes releases](https://console.cloud.g On MacOS: -``` -wget https://storage.googleapis.com/kubernetes-release/release/v1.4.3/bin/darwin/amd64/kubectl +```shell +wget https://storage.googleapis.com/kubernetes-release/release/v1.4.4/bin/darwin/amd64/kubectl chmod +x kubectl mv kubectl /usr/local/bin/kubectl ``` On Linux: -``` -wget https://storage.googleapis.com/kubernetes-release/release/v1.4.3/bin/linux/amd64/kubectl +```shell +wget https://storage.googleapis.com/kubernetes-release/release/v1.4.4/bin/linux/amd64/kubectl chmod +x kubectl mv kubectl /usr/local/bin/kubectl ``` @@ -50,7 +52,7 @@ After Google Cloud SDK installs, run the following command to install `kubectl`: gcloud components install kubectl ``` -Do check that the version is sufficiently up-to-date using `kubectl version --client`. +Do check that the version is sufficiently up-to-date using `kubectl version`. ### Install with brew @@ -60,4 +62,5 @@ If you are on MacOS and using brew, you can install with: brew install kubectl ``` -Do check that the version is sufficiently up-to-date using `kubectl version --client`. +The homebrew project is independent from kubernetes, so do check that the version is +sufficiently up-to-date using `kubectl version`. \ No newline at end of file From 689c4b02b48783991c2e8cdf2e6c2a7446b8546d Mon Sep 17 00:00:00 2001 From: Justin Santa Barbara Date: Fri, 21 Oct 2016 21:05:38 -0400 Subject: [PATCH 3/4] Add kubectl shell autocompletion section --- docs/getting-started-guides/kubectl.md | 43 +++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/docs/getting-started-guides/kubectl.md b/docs/getting-started-guides/kubectl.md index 0498ceb646..b346b75c7d 100644 --- a/docs/getting-started-guides/kubectl.md +++ b/docs/getting-started-guides/kubectl.md @@ -63,4 +63,45 @@ brew install kubectl ``` The homebrew project is independent from kubernetes, so do check that the version is -sufficiently up-to-date using `kubectl version`. \ No newline at end of file +sufficiently up-to-date using `kubectl version`. + + +# Enabling shell autocompletion + +kubectl includes autocompletion support, which can save a lot of typing! + +The completion script itself is generated by kubectl, so you typically just need to invoke it from your profile. + +Common examples are provided here, but for more details please consult `kubectl completion -h` + +## On Linux, using bash + +To add it to your current shell: `source <(kubectl completion bash)` + +To add kubectl autocompletion to your profile (so it is automatically loaded in future shells): + +```shell +echo "source <(kubectl completion bash)" >> ~/.bashrc +``` + +## On MacOS, using bash + +On MacOS, you will need to install the bash-completion support first: + +```shell +brew install bash-completion +``` + +To add it to your current shell: + +```shell +source $(brew --prefix)/etc/bash_completion +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" >> ~/.bashrc +echo "source <(kubectl completion bash)" >> ~/.bashrc +``` From 500aec5eedf60f574d4022b65f162f6f6dd0344c Mon Sep 17 00:00:00 2001 From: Justin Santa Barbara Date: Fri, 21 Oct 2016 21:39:25 -0400 Subject: [PATCH 4/4] A few updates based on MacOS testing --- docs/getting-started-guides/kubectl.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/getting-started-guides/kubectl.md b/docs/getting-started-guides/kubectl.md index b346b75c7d..bd2512707b 100644 --- a/docs/getting-started-guides/kubectl.md +++ b/docs/getting-started-guides/kubectl.md @@ -102,6 +102,9 @@ 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" >> ~/.bashrc -echo "source <(kubectl completion bash)" >> ~/.bashrc +echo "source $(brew --prefix)/etc/bash_completion" >> ~/.bash_profile +echo "source <(kubectl completion bash)" >> ~/.bash_profile ``` + +Please note that this only appears to work currently if you install using `brew install kubectl`, +and not if you downloaded kubectl directly. \ No newline at end of file