-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathdeploy
More file actions
228 lines (173 loc) · 4.99 KB
/
deploy
File metadata and controls
228 lines (173 loc) · 4.99 KB
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#!/bin/bash
source bin/lib
set -e
if [[ "${CI}" ]]; then
set -x
fi
function usage() {
echo -n \
"Usage: $(basename "$0") -t TERRAFORM_DIR [--plan,--skip-tf]
Deploys the project infrastructure.
-t TERRAFORM_DIR: The terraform directory. Required.
--plan: Only run Terraform plan.
--skip-tf: Skips Terraform apply. Will still gather terraform output
"
}
###################
# Parse arguments #
###################
while [[ "$#" -gt 0 ]]; do case $1 in
-t)
TERRAFORM_DIR=${2}
shift
shift
;;
--skip-tf)
SKIP_TF=1
shift
;;
--plan)
PLAN_ONLY=1
shift
;;
--help)
usage
exit 0
shift
;;
*)
usage "Unknown parameter passed: $1"
shift
shift
;;
esac done
###################################
# Check and configure environment #
###################################
if [[ -z ${TERRAFORM_DIR} ]]; then
echo "Must pass in TERRAFORM_DIR with -t"
exit 1
fi
require_env "IMAGE_TAG"
require_env "GIT_COMMIT"
require_env "ARM_CLIENT_ID"
require_env "ARM_CLIENT_SECRET"
require_env "ARM_TENANT_ID"
# Directory for rendered values and templates
CONF_DIR='/opt/conf'
mkdir -p ${CONF_DIR}
# Set up environment
setup_env
# Print some information
echo "===== Running Deploy ====="
echo "IMAGE_TAG: ${IMAGE_TAG}"
# ---------------------------------------------------
if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
#########################
# Add IP to KV firewall #
#########################
bin/azlogin
bin/kv_add_ip
#####################
# Deploy Terraform #
#####################
pushd ${TERRAFORM_DIR}
if [[ "${SKIP_TF}" != 1 ]]; then
echo "Deploying infrastructure with Terraform..."
terraform init --upgrade
if [ "${PLAN_ONLY}" ]; then
terraform plan
exit 0
fi
terraform apply -auto-approve
fi
# Gather terraform output
gather_tf_output
popd
##############################
# Remove IP from KV firewall #
##############################
bin/kv_rmv_ip
############################
# Render Helm chart values #
############################
render_values
########################
# Login to the cluster #
########################
cluster_login
######################
# Deploy Helm charts #
######################
echo "Deploying helm charts..."
setup_helm
# Install namespaces
echo "Installing namespaces..."
helm upgrade --install \
pc-namespaces helm/pc-namespaces \
-n pc-namespaces \
--create-namespace
# Install cert-manager
echo "Installing cert-manager..."
helm upgrade --install \
cert-manager \
--namespace pc \
--version v1.6.0 \
--set installCRDs=true jetstack/cert-manager
echo "==================="
echo "==== STAC API ====="
echo "==================="
echo "Deploying STAC API helm chart..."
helm upgrade --install planetary-computer-stac helm/published/planetary-computer-stac \
-n pc \
--kube-context "${KUBE_CONTEXT}" \
--wait \
--timeout 2m0s \
-f ${DEPLOY_VALUES_FILE}
echo "================"
echo "==== Tiler ====="
echo "================"
echo "Deploying Tiler helm chart..."
helm upgrade --install planetary-computer-tiler helm/published/planetary-computer-tiler \
-n pc \
--kube-context "${KUBE_CONTEXT}" \
--wait \
--timeout 2m0s \
-f ${DEPLOY_VALUES_FILE}
echo "=================="
echo "==== Ingress ====="
echo "=================="
echo "Deploying ingress component..."
helm upgrade --install pc-apis-ingress helm/pc-apis-ingress \
-n pc \
--kube-context "${KUBE_CONTEXT}" \
--wait \
--timeout 2m0s \
-f ${DEPLOY_VALUES_FILE}
echo "Installing ingress-nginx..."
helm upgrade --install nginx-ingress ingress-nginx/ingress-nginx \
-n pc \
--set controller.replicaCount=2 \
--set controller.service.externalTrafficPolicy="Local" \
--set controller.service.loadBalancerIP="${INGRESS_IP}" \
--set controller.service.annotations."service\.beta\.kubernetes\.io/azure-dns-label-name"="${DNS_LABEL}" \
--wait \
--timeout 2m0s
echo "====================="
echo "==== Prometheus ====="
echo "====================="
echo "Deploying prometheus crd..."
kubectl apply -f helm/prometheus-crd --server-side
echo "Deploying prometheus component..."
kubectl apply -f helm/pc-apis-prometheus
echo "==========================="
echo "==== Overprovisioning ====="
echo "==========================="
helm upgrade --install overprovisioning helm/overprovisioning \
--kube-context "${KUBE_CONTEXT}" \
--wait \
#########################
# Deploy Azure Function #
#########################
deploy_funcs
fi