-
Notifications
You must be signed in to change notification settings - Fork 34
/
deploy.sh
65 lines (52 loc) · 1.31 KB
/
deploy.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
#!/bin/bash
set -e
if [ "${1}" = 'eqiad1' ]
then
datacenter=${1}
elif [ "${1}" = 'codfw1dev' ]
then
datacenter=${1}
else
echo "Please enter datacenter."
echo "Usage:"
echo "${0} <eqiad1|codfw1dev>"
exit
fi
if [ -n "${2}" ]
then
if [ "${2}" = 'tofu' ]
then
# exit after tofu
tofuonly=1
fi
fi
if ! command -v kubectl ; then
echo "please install kubectl"
exit 1
fi
if ! command -v helm ; then
echo "please install helm"
exit 1
fi
if ! command -v tofu ; then
echo "please install tofu"
exit 1
fi
source secrets-${datacenter}.sh
python3 -m venv .venv/deploy
source .venv/deploy/bin/activate
pip install ansible==10.3.0 kubernetes==26.1.0
# install helm diff. Needed to keep helm module idempotent
helm plugin install https://github.com/databus23/helm-diff || true
cd tofu
AWS_ACCESS_KEY_ID=${ACCESS_KEY} AWS_SECRET_ACCESS_KEY=${SECRET_KEY} tofu init -backend-config=${datacenter}-backend.conf
AWS_ACCESS_KEY_ID=${ACCESS_KEY} AWS_SECRET_ACCESS_KEY=${SECRET_KEY} tofu apply -var datacenter=${datacenter}
export KUBECONFIG=$(pwd)/kube.config
if [ "${tofuonly}" = '1' ]
then
exit
fi
cd ../ansible
# install collections here to take advantage of ansible.cfg configs
ansible-galaxy collection install -U kubernetes.core -p ./collections
ansible-playbook paws.yaml --extra-vars "datacenter=${datacenter}"