Add a script that will get the latest kubectl

Getting the latest kubectl is a pain to copy and paste
from the docs. Instead, added a script that will find the latest
version and add it to /usr/bin/kubectl.

Change-Id: I86011b3ab2f8f79684fb3ec6fb5b3b4c8f2dc4f7
Partially-implements: blueprint documentation-initialization
This commit is contained in:
Ryan Hallisey 2016-08-29 17:03:49 -04:00
parent afbdc0575e
commit 5b3db1c8d9
2 changed files with 14 additions and 4 deletions

View File

@ -36,11 +36,11 @@ Execute the following commands to create an all-in-one Kubernetes setup::
git clone https://github.com/kubernetes/kube-deploy
./kube-deploy/docker-multinode/master.sh
Download kubectl::
The ``setup-kubectl.sh`` script will pull the latest kubectl from git::
wget http://storage.googleapis.com/kubernetes-release/release/v1.2.4/bin/linux/amd64/kubectl
chmod 755 kubectl
PATH=$PATH:`pwd`
git clone https://github.com/openstack/kolla-kubernetes
cd kolla-kubernetes
./tools/setup-kubectl.sh
Try it out::

10
tools/setup-kubectl.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
# https://gist.github.com/FrankDeGroot/8cbec84eabfebcf2f2e7
echo "Finding latest kubectl"
# curl -s https://github.com/kubernetes/kubernetes/releases/latest | awk -F '[<>]' '/.*/ { match($0, "tag/([^\"]+)",a); print a[1] }'
LATEST=$(wget -qO- https://github.com/kubernetes/kubernetes/releases/latest | awk -F '[<>]' '/href="\/kubernetes\/kubernetes\/tree\/.*"/ { match($0, "tree/([^\"]+)",a); print a[1] }' | head -1)
echo "Getting kubectl-$LATEST"
sudo wget -NP /usr/bin http://storage.googleapis.com/kubernetes-release/release/$LATEST/bin/linux/amd64/kubectl
sudo chmod 755 /usr/bin/kubectl