-
Notifications
You must be signed in to change notification settings - Fork 6
/
02_install_consul.sh
executable file
·67 lines (57 loc) · 2.04 KB
/
02_install_consul.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
#! /bin/bash
# source setup_kubeconfig.sh
source helper.sh
# setting up gossip encryption
if [ ! -s gossipEncryptionKey ]; then
consul keygen > gossipEncryptionKey
fi
LICENSE_PATH=$HOME/licenses/consul_v2lic.hclic
CONSUL_HELM_VERSION=1.1.0
helm repo add hashicorp https://helm.releases.hashicorp.com
helm repo update
c1_kctx
kubectl create secret generic consul-gossipencryptionkey --from-file=key=gossipEncryptionKey
kubectl create secret generic consul-license \
--from-file=license=$LICENSE_PATH
if helm status consul 2>&1 1>/dev/null; then
helm upgrade consul hashicorp/consul -f values1_consul.yaml \
--set global.datacenter=cluster-1 \
--version $CONSUL_HELM_VERSION \
--wait
else
helm install consul hashicorp/consul -f values1_consul.yaml \
--set global.datacenter=cluster-1 \
--version $CONSUL_HELM_VERSION \
--wait
fi
kubectl wait --for=condition=available --timeout=5m deployment.apps/consul-mesh-gateway
echo ".: waiting for Cluster-1 IP address"
while ! kubectl get svc consul-ui -o jsonpath={..ip} --allow-missing-template-keys=false 2>/dev/null; do
sleep 5
done
echo ""
c2_kctx
kubectl create secret generic consul-gossipencryptionkey --from-file=key=gossipEncryptionKey
kubectl create secret generic consul-license \
--from-file=license=$LICENSE_PATH
if helm status consul 2>&1 1>/dev/null; then
helm upgrade consul hashicorp/consul -f values2_consul.yaml \
--set global.datacenter=cluster-2 \
--version $CONSUL_HELM_VERSION \
--wait
else
helm install consul hashicorp/consul -f values2_consul.yaml \
--set global.datacenter=cluster-2 \
--version $CONSUL_HELM_VERSION \
--wait
fi
kubectl wait --for=condition=available --timeout=1m deployment.apps/consul-mesh-gateway
echo ".: waiting for Cluster-2 IP address"
while ! kubectl get svc consul-ui -o jsonpath={..ip} --allow-missing-template-keys=false 2>/dev/null; do
sleep 5
done
echo ""
setup-consul 2>&1 1>/dev/null
consul acl policy update -name "anonymous-token-policy" -rules @consul_config/anonymous-policy.hcl
detect_endpoints;
c1_kctx;