-
Notifications
You must be signed in to change notification settings - Fork 15
/
7_configure_standbys.sh
executable file
·71 lines (46 loc) · 1.5 KB
/
7_configure_standbys.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
66
67
68
69
70
71
#!/bin/bash
set -euo pipefail
. utils.sh
main() {
set_namespace $CONJUR_NAMESPACE_NAME
announce "Configuring standbys."
master_pod_name=$(get_master_pod_name)
prepare_standby_seed
configure_standbys
delete_standby_seed
enable_synchronous_replication
echo "Standbys configured."
}
prepare_standby_seed() {
echo "Preparing standby seed..."
# Create dir w/ guid from namespace name for parallel CI execution
seed_dir="tmp-$CONJUR_NAMESPACE_NAME"
mkdir -p $seed_dir
$cli exec $master_pod_name -- evoke seed standby conjur-standby > "./$seed_dir/standby-seed.tar"
}
configure_standbys() {
pod_list=$($cli get pods -l role=unset --no-headers | awk '{ print $1 }')
master_pod_ip=$($cli get pod $master_pod_name -o jsonpath='{.status.podIP}')
for pod_name in $pod_list; do
configure_standby $pod_name &
done
wait # for parallel configuration of standbys
}
configure_standby() {
local pod_name=$1
printf "Configuring standby %s...\n" $pod_name
$cli label --overwrite pod $pod_name role=standby
copy_file_to_container "./$seed_dir/standby-seed.tar" "/tmp/standby-seed.tar" "$pod_name"
$cli exec $pod_name -- evoke unpack seed /tmp/standby-seed.tar
$cli exec $pod_name -- evoke configure standby -i $master_pod_ip
set_conjur_pod_log_level $pod_name
}
delete_standby_seed() {
echo "Deleting standby seed..."
rm -rf $seed_dir
}
enable_synchronous_replication() {
echo "Starting synchronous replication..."
mastercmd evoke replication sync --force
}
main $@