File: configure_service.sh

package info (click to toggle)
golang-github-google-certificate-transparency 0.0~git20160709.0.0f6e3d1~ds1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster
  • size: 5,676 kB
  • sloc: cpp: 35,278; python: 11,838; java: 1,911; sh: 1,885; makefile: 950; xml: 520; ansic: 225
file content (97 lines) | stat: -rwxr-xr-x 2,951 bytes parent folder | download
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
#!/bin/bash
set -e
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
GCLOUD="gcloud"
if [ "$1" == "" ]; then
  echo "Usage: $0 <config-file>"
  exit 1
fi
CONFIG_FILE="$1"

. ${DIR}/config.sh ${CONFIG_FILE}

case "${INSTANCE_TYPE}" in
  "mirror")
    eval $(typeset -A -p MIRROR_ZONES | sed 's/MIRROR_ZONES=/NODE_ZONES=/')
    eval $(typeset -A -p MIRROR_MACHINES | \
           sed 's/MIRROR_MACHINES=/NODE_MACHINES=/')
    export NODE_NUM_REPLICAS=${MIRROR_NUM_REPLICAS}
    export NODE_ZONES
    ;;
  "log")
    eval $(typeset -A -p LOG_ZONES | sed 's/LOG_ZONES=/NODE_ZONES=/')
    eval $(typeset -A -p LOG_MACHINES | \
           sed 's/LOG_MACHINES=/NODE_MACHINES=/')
    export NODE_NUM_REPLICAS=${LOG_NUM_REPLICAS}
    export NODE_ZONES
   ;;
  *)
    echo "Unknown INSTANCE_TYPE: ${INSTANCE_TYPE}"
    exit 1
esac

ZONE_LIST=$(echo ${NODE_ZONES[*]} | tr " " "\n" | sort | uniq )

echo "============================================================="
echo "Creating network rules..."
gcloud compute http-health-checks create get-sth-check \
    --port 80 \
    --request-path /ct/v1/get-sth
gcloud compute firewall-rules create ${INSTANCE_TYPE}-node-80 \
    --allow tcp:80 \
    --target-tags ${INSTANCE_TYPE}-node

for zone in ${ZONE_LIST}; do
  gcloud compute instance-groups unmanaged \
      create "${INSTANCE_TYPE}-group-${zone}" \
      --zone ${zone} &
done
wait

for i in `seq 0 $((${NODE_NUM_REPLICAS} - 1))`; do
  gcloud compute instance-groups unmanaged add-instances \
      "${INSTANCE_TYPE}-group-${NODE_ZONES[${i}]}" \
      --zone ${NODE_ZONES[${i}]} \
      --instances ${NODE_MACHINES[${i}]} &
done
wait

gcloud compute addresses create "${INSTANCE_TYPE}-ip" \
    --global
export EXTERNAL_IP=$(gcloud compute addresses list "${INSTANCE_TYPE}-ip" |
                     awk -- "/${INSTANCE_TYPE}-ip/ {print \$2}")
echo "Service IP: ${EXTERNAL_IP}"


gcloud compute backend-services create "${INSTANCE_TYPE}-lb-backend" \
    --http-health-check "get-sth-check" \
    --timeout "30"

for zone in ${ZONE_LIST}; do
  gcloud compute backend-services add-backend "${INSTANCE_TYPE}-lb-backend" \
    --instance-group "${INSTANCE_TYPE}-group-${zone}" \
    --zone ${zone} \
    --balancing-mode "UTILIZATION" \
    --capacity-scaler "1" \
    --max-utilization "0.8"
done


gcloud compute url-maps create "${INSTANCE_TYPE}-lb-url-map" \
    --default-service "${INSTANCE_TYPE}-lb-backend"

gcloud compute target-http-proxies create "${INSTANCE_TYPE}-lb-http-proxy" \
    --url-map "${INSTANCE_TYPE}-lb-url-map"

gcloud compute forwarding-rules create "${INSTANCE_TYPE}-fwd" \
    --global \
    --address "${EXTERNAL_IP}" \
    --ip-protocol "TCP" \
    --port-range "80" \
    --target-http-proxy "${INSTANCE_TYPE}-lb-http-proxy"

echo "============================================================="
echo "External IPs:"
gcloud compute forwarding-rules list
echo "============================================================="