-
Notifications
You must be signed in to change notification settings - Fork 76
/
install-rok8s-requirements
executable file
·170 lines (148 loc) · 6.03 KB
/
install-rok8s-requirements
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/bin/bash -e
# MODIFIED by Ross Kukulinski <ross@kukulinski.com>
# Copyright 2016 Ross Kukulinski All rights reserved
# Copyright 2014 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# used to install kubectl inside the build environment plus other tools these scripts leverage.
# uncomment for troubleshooting if required
# set -xv
ROK8S_INSTALL_PATH="${ROK8S_INSTALL_PATH:-/usr/local/bin}"
mkdir -p "${ROK8S_INSTALL_PATH}"
PKG_MANAGER=$( command -v dnf || command -v yum || command -v apt-get || command -v apk || command -v brew ) || echo "Supported package manager not found"
if [[ $PKG_MANAGER = *"apk"* ]]; then
PKG_INSTALL="${PKG_MANAGER} add"
else
PKG_INSTALL="${PKG_MANAGER} install -y"
fi
KUBECTL_VERSION="${KUBECTL_VERSION:-v1.22.11}"
HELM_VERSION="${HELM_VERSION:-v3.11.1}"
HELM2_VERSION="${HELM2_VERSION:-v2.17.0}"
SOPS_VERSION="${SOPS_VERSION:-v3.7.3}"
# make sure sudo is installed
if ! hash sudo 2>/dev/null; then
echo Installing sudo...
# shellcheck disable=SC2086
$PKG_INSTALL sudo
fi
# remove default setting of requiretty if it exists
#sed -i '/Defaults requiretty/d' /etc/sudoers
# make sure wget is installed
if ! hash wget 2>/dev/null; then
echo Installing wget...
# shellcheck disable=SC2086
sudo $PKG_INSTALL wget
fi
# make sure jq is installed
if ! hash jq 2>/dev/null; then
echo Installing jq...
# shellcheck disable=SC2086
sudo $PKG_INSTALL jq
fi
if ! hash pip 2>/dev/null; then
echo Installing pip
if [[ $PKG_MANAGER = *"apk"* ]]; then
# shellcheck disable=SC2086
sudo $PKG_INSTALL py-pip python3-dev
elif [[ $PKG_MANAGER = *"dnf"* ]]; then
# shellcheck disable=SC2086
sudo $PKG_INSTALL python-pip python-devel
elif [[ $PKG_MANAGER = *"yum"* ]]; then
# shellcheck disable=SC2086
sudo $PKG_INSTALL python-pip python-devel
elif [[ $PKG_MANAGER = *"apt"* ]]; then
# shellcheck disable=SC2086
sudo $PKG_INSTALL python-pip python-dev
elif [[ $PKG_MANAGER = *"brew"* ]]; then
# shellcheck disable=SC2086
sudo $PKG_INSTALL python
fi
fi
# make sure gcloud is installed
if ! hash gcloud 2>/dev/null; then
echo Installing gcloud...
gcloud components update --quiet || \
curl https://dl.google.com/dl/cloudsdk/channels/rapid/install_google_cloud_sdk.bash | \
bash -s -- --disable-prompts
ln -s "${HOME}/google-cloud-sdk/bin/gcloud" "${ROK8S_INSTALL_PATH}/gcloud"
ln -s "${HOME}/google-cloud-sdk/bin/docker-credential-gcloud" "${ROK8S_INSTALL_PATH}/docker-credential-gcloud"
ln -s "${HOME}/google-cloud-sdk/bin/gsutil" "${ROK8S_INSTALL_PATH}/gsutil"
fi
# make sure awscli is installed
if ! hash aws 2>/dev/null; then
echo Installing aws...
pip install awscli
fi
# make sure kubectl is installed
if ! hash kubectl 2>/dev/null; then
echo Installing kubectl...
wget -q "https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl" -O "${ROK8S_INSTALL_PATH}/kubectl"
chmod +x "${ROK8S_INSTALL_PATH}/kubectl"
fi
# make sure sops is installed
if ! hash sops 2>/dev/null; then
echo Installing sops...
curl -fsSLo "${ROK8S_INSTALL_PATH}/sops" "https://github.com/mozilla/sops/releases/download/${SOPS_VERSION}/sops-${SOPS_VERSION}.$(uname | tr '[:upper:]' '[:lower:]')"
chmod +x "${ROK8S_INSTALL_PATH}/sops"
fi
# make sure helm 3 is installed
if ! hash helm 2>/dev/null; then
echo Installing helm...
mkdir "${ROK8S_INSTALL_PATH}/helm-tmp"
curl "https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz" | tar xzvf - -C "${ROK8S_INSTALL_PATH}/helm-tmp"
mv "${ROK8S_INSTALL_PATH}/helm-tmp/linux-amd64/helm" "${ROK8S_INSTALL_PATH}/helm"
chmod +x "${ROK8S_INSTALL_PATH}/helm"
rm -rf "${ROK8S_INSTALL_PATH}/helm-tmp"
fi
# make sure helm2 is installed
if ! hash helm2 2>/dev/null; then
echo Installing helm2...
mkdir "${ROK8S_INSTALL_PATH}/helm2-tmp"
curl "https://get.helm.sh/helm-${HELM2_VERSION}-linux-amd64.tar.gz" | tar xzvf - -C "${ROK8S_INSTALL_PATH}/helm2-tmp"
mv "${ROK8S_INSTALL_PATH}/helm2-tmp/linux-amd64/helm" "${ROK8S_INSTALL_PATH}/helm2"
chmod +x "${ROK8S_INSTALL_PATH}/helm2"
rm -rf "${ROK8S_INSTALL_PATH}/helm2-tmp"
fi
# make sure kubeval is installed
if ! hash kubeval 2>/dev/null; then
echo Installing kubeval...
cd "${ROK8S_INSTALL_PATH}"
curl -L "https://github.com/garethr/kubeval/releases/download/0.7.3/kubeval-linux-amd64.tar.gz" | tar xzvf -
echo "0582bd259fb8045562d3db3bc01ab834d8f210e7 kubeval" | sha1sum -c -
chmod +x "${ROK8S_INSTALL_PATH}/kubeval"
fi
# make sure aws-iam-authenticator is installed
if ! hash aws-iam-authenticator 2>/dev/null; then
echo Installing aws-iam-authenticator...
cd "${ROK8S_INSTALL_PATH}"
wget -q "https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v0.3.0/heptio-authenticator-aws_0.3.0_linux_amd64" -O "${ROK8S_INSTALL_PATH}/aws-iam-authenticator"
echo "1053ac315df5f1e306f62969dbf1e1308f608efd aws-iam-authenticator" | sha1sum -c -
chmod +x "${ROK8S_INSTALL_PATH}/aws-iam-authenticator"
fi
# make sure vault is installed
if ! hash vault 2>/dev/null; then
echo Installing vault...
cd "${ROK8S_INSTALL_PATH}"
curl -LO "https://releases.hashicorp.com/vault/1.9.3/vault_1.9.3_linux_amd64.zip"
unzip vault_1.9.3_linux_amd64.zip
rm vault_1.9.3_linux_amd64.zip
chmod +x vault
fi
if ! hash yq 2>/dev/null; then
echo Installing yq...
cd "${ROK8S_INSTALL_PATH}"
curl -L "https://github.com/mikefarah/yq/releases/download/v4.8.0/yq_linux_amd64.tar.gz" | tar zxvf -
echo "1bdbf68deeaf36267ec9ee9d39dded381f12d9d5e86ba352fdbb54cd78a4b068 yq_linux_amd64" | sha256sum -c -
mv yq_linux_amd64 yq
chmod +x yq
fi