This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
2-get_k8s_fleet_etcd.sh
executable file
·118 lines (104 loc) · 4.03 KB
/
2-get_k8s_fleet_etcd.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
ssh-add ~/.ssh/google_compute_engine &>/dev/null
if [ $? != 0 ]; then
echo "Your ssh-agent isn't running -- please start it and run this script again."
exit 2
fi
# fetch from settings file
project=$(cat settings | grep project= | head -1 | cut -f2 -d"=")
master_name=$(cat settings | grep master_name= | head -1 | cut -f2 -d"=")
# get master external IP
master_ip=$(gcloud compute instances list --project=$project | grep -v grep | grep $master_name | awk {'print $5'});
# path to the folder where we store our binary files
export PATH=${HOME}/k8s-bin:$PATH
# get latest k8s version
function get_latest_version_number {
local -r latest_url="https://storage.googleapis.com/kubernetes-release/release/latest.txt"
if [[ $(which wget) ]]; then
wget -qO- ${latest_url}
elif [[ $(which curl) ]]; then
curl -Ss ${latest_url}
fi
}
k8s_version=$(get_latest_version_number)
# create tmp folder
mkdir tmp
echo "Downloading and instaling fleetctl, etcdctl and kubectl ..."
# First let's check which OS we use: OS X or Linux
uname=$(uname)
if [[ "${uname}" == "Darwin" ]]
then
# OS X
#
mkdir ~/k8s-bin
cd ./tmp
# download etcd and fleet clients for OS X
ETCD_RELEASE=$(ssh core@$master_ip etcdctl --version | cut -d " " -f 3- | tr -d '\r')
echo "Downloading etcdctl v$ETCD_RELEASE for OS X"
curl -L -o etcd.zip "https://github.com/coreos/etcd/releases/download/v$ETCD_RELEASE/etcd-v$ETCD_RELEASE-darwin-amd64.zip"
unzip -j -o "etcd.zip" "etcd-v$ETCD_RELEASE-darwin-amd64/etcdctl"
mv -f etcdctl ~/k8s-bin
# clean up
rm -f etcd.zip
echo "etcdctl was copied to ~/k8s-bin"
echo " "
#
FLEET_RELEASE=$(ssh core@$master_ip fleetctl version | cut -d " " -f 3- | tr -d '\r')
echo "Downloading fleetctl v$FLEET_RELEASE for OS X"
curl -L -o fleet.zip "https://github.com/coreos/fleet/releases/download/v$FLEET_RELEASE/fleet-v$FLEET_RELEASE-darwin-amd64.zip"
unzip -j -o "fleet.zip" "fleet-v$FLEET_RELEASE-darwin-amd64/fleetctl"
mv -f fleetctl ~/k8s-bin
# clean up
rm -f fleet.zip
echo "fleetctl was copied to ~/k8s-bin "
echo " "
# download kubernetes kubectl for OS X
echo "Downloading kubernetes $k8s_version kubectl for OS X"
curl -L -o kubectl https://storage.googleapis.com/kubernetes-release/release/$k8s_version/bin/darwin/amd64/kubectl
mv -f kubectl ~/k8s-bin
#
echo " "
echo "kubectl was copied to ~/k8s-bin"
echo " "
# Make them executable
#
chmod +x ~/k8s-bin/*
cd ..
else
# Linux
#
mkdir ~/k8s-bin
cd ./tmp
# download etcd and fleet clients for Linux
ETCD_RELEASE=$(ssh core@$master_ip etcdctl --version | cut -d " " -f 3- | tr -d '\r')
echo "Downloading etcdctl $ETCD_RELEASE for Linux"
curl -L -o etcd.tar.gz "https://github.com/coreos/etcd/releases/download/v$ETCD_RELEASE/etcd-v$ETCD_RELEASE-linux-amd64.tar.gz"
tar -zxvf etcd.tar.gz etcd-v$ETCD_RELEASE-linux-amd64/etcdctl
mv -f etcd-v$ETCD_RELEASE-linux-amd64/etcdctl ~/k8s-bin
# clean up
rm -f etcd.tar.gz
rm -rf etcd-v$ETCD_RELEASE-linux-amd64
echo "etcdctl was copied to ~/k8s-bin"
echo " "
FLEET_RELEASE=$(ssh core@$master_ip fleetctl version | cut -d " " -f 3- | tr -d '\r')
cd ./tmp
echo "Downloading fleetctl v$FLEET_RELEASE for Linux"
curl -L -o fleet.tar.gz "https://github.com/coreos/fleet/releases/download/v$FLEET_RELEASE/fleet-v$FLEET_RELEASE-linux-amd64.tar.gz"
tar -zxvf fleet.tar.gz fleet-v$FLEET_RELEASE-linux-amd64/fleetctl
mv -f fleet-v$FLEET_RELEASE-linux-amd64/fleetctl ~/k8s-bin
# clean up
rm -f fleet.tar.gz
rm -rf fleet-v$FLEET_RELEASE-linux-amd64
echo "fleetctl was copied to ~/k8s-bin"
# download kubernetes kubectl for Linux
echo "Downloading kubernetes $k8s_version kubectl for Linux"
curl -L -o kubectl https://storage.googleapis.com/kubernetes-release/release/$k8s_version/bin/linux/amd64/kubectl
mv -f kubectl ~/k8s-bin
echo "kubectl was copied to ~/k8s-bin"
echo " "
#
# Make them executable
chmod +x ~/k8s-bin/*
#
cd ..
fi