-
Notifications
You must be signed in to change notification settings - Fork 5
/
apply-cluster.sh
executable file
·46 lines (40 loc) · 1.59 KB
/
apply-cluster.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
#!/bin/bash
#
# apply-cluster.sh applies the k8s cluster configuration to the currently
# configured cluster. This script may be safely run multiple times to load the
# most recent configurations.
#
# Example:
#
# PROJECT_ID=mlab-sandbox CLOUDSDK_CONTAINER_CLUSTER=scraper-cluster ./apply-cluster.sh
set -x
set -e
set -u
USAGE="PROJECT_ID=<projectid> CLOUDSDK_CONTAINER_CLUSTER=<cluster> $0"
PROJECT_ID=${PROJECT_ID:?Please provide project id: $USAGE}
CLUSTER=${CLOUDSDK_CONTAINER_CLUSTER:?Please provide cluster name: $USAGE}
DATE_SKIP=${DATE_SKIP:-"0"} # Number of dates to skip between each processed date (for sandbox).
TASK_FILE_SKIP=${TASK_FILE_SKIP:-"0"} # Number of files to skip between each processed file (for sandbox).
# Use sandbox in sandbox, measurement-lab in staging & oti.
SOURCE_PROJECT=${PROJECT_ID/mlab-oti/measurement-lab}
SOURCE_PROJECT=${SOURCE_PROJECT/mlab-staging/measurement-lab}
sed -i \
-e 's/{{ANNOTATION_SOURCE_PROJECT}}/'${SOURCE_PROJECT}'/g' \
config/config.yml
sed -i \
-e 's/{{NDT_SOURCE_PROJECT}}/'${SOURCE_PROJECT}'/g' \
config/config.yml
# Create the configmap
kubectl create configmap gardener-config --dry-run \
--from-file config/config.yml \
-o yaml > k8s/${CLUSTER}/deployments/config.yml
# Apply templates
find k8s/${CLUSTER}/ -type f -exec \
sed -i \
-e 's/{{GIT_COMMIT}}/'${GIT_COMMIT}'/g' \
-e 's/{{GCLOUD_PROJECT}}/'${PROJECT_ID}'/g' \
-e 's/{{DATE_SKIP}}/'${DATE_SKIP}'/g' \
-e 's/{{TASK_FILE_SKIP}}/'${TASK_FILE_SKIP}'/g' \
{} \;
# This triggers deployment of the pod.
kubectl apply --recursive -f k8s/${CLUSTER}