-
Notifications
You must be signed in to change notification settings - Fork 15
/
6_configure_master.sh
executable file
·76 lines (56 loc) · 2.14 KB
/
6_configure_master.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
72
73
74
75
76
#!/bin/bash
set -euo pipefail
. utils.sh
main() {
set_namespace $CONJUR_NAMESPACE_NAME
configure_master_pod
wait_for_master
configure_cli_pod
}
configure_master_pod() {
announce "Configuring master pod."
local master_pod_name=$(get_master_pod_name)
$cli label --overwrite pod $master_pod_name role=master
MASTER_ALTNAMES="localhost,conjur-master"
# Configure Conjur master server using evoke.
$cli exec $master_pod_name -- evoke configure master \
--accept-eula \
-h conjur-master.$CONJUR_NAMESPACE_NAME.svc.cluster.local \
--master-altnames "$MASTER_ALTNAMES" \
--follower-altnames conjur-follower,conjur-follower.$CONJUR_NAMESPACE_NAME.svc.cluster.local \
-p $CONJUR_ADMIN_PASSWORD \
$CONJUR_ACCOUNT
echo "Master pod configured."
set_conjur_pod_log_level $master_pod_name
# Write standby seed to persistent storage if /opt/conjur/data is mounted
if $cli exec $master_pod_name -- ls /opt/conjur/data &>/dev/null; then
$cli exec $master_pod_name -- bash -c "evoke seed standby > /opt/conjur/data/standby-seed.tar"
echo "Seed created in persistent storage."
fi
}
wait_for_master() {
local conjur_url="https://conjur-master.$CONJUR_NAMESPACE_NAME.svc.cluster.local"
local test_curl_pod=$(get_test_curl_pod_name)
echo "Waiting for DAP Master to be ready..."
# Wait for 10 successful connections in a row
local COUNTER=0
while [ $COUNTER -lt 10 ]; do
local response=$($cli exec $test_curl_pod -- sh -c "curl -k --silent --head $conjur_url/health")
if [ -z "$(echo $response | grep "Conjur-Health: OK")" ]; then
sleep 5
COUNTER=0
else
let COUNTER=COUNTER+1
fi
sleep 1
echo "Successful Health Checks: $COUNTER (waiting for 10)"
done
}
configure_cli_pod() {
announce "Configuring Conjur CLI."
local conjur_url="https://conjur-master.$CONJUR_NAMESPACE_NAME.svc.cluster.local"
local conjur_cli_pod=$(get_conjur_cli_pod_name)
$cli exec $conjur_cli_pod -- sh -c "echo y | conjur init -a $CONJUR_ACCOUNT -u $conjur_url --self-signed --force"
$cli exec $conjur_cli_pod -- conjur login -i admin -p $CONJUR_ADMIN_PASSWORD
}
main $@