-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathistio-setup.sh
executable file
·110 lines (89 loc) · 2.95 KB
/
istio-setup.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
set -o xtrace
set -o errexit
set -o nounset
set -o pipefail
source ./env.sh $1
setupIstioCSR() {
local cluster=${1}
helm upgrade cert-manager-istio-csr ./charts/cert-manager-istio-csr \
--install \
--namespace cert-manager \
--wait \
--values=./charts/cert-manager-istio-csr/values-"${cluster}".yaml \
--kube-context=kind-${cluster}
}
setupIstioBase() {
local cluster=${1}
helm upgrade istio-base ./charts/istio/base \
--install \
--wait \
--kube-context=kind-${cluster} \
--namespace istio-system \
--values=./charts/istio/base/values-"${cluster}".yaml
}
setupIstiod() {
local cluster=${1}
helm upgrade istiod ./charts/istio/istiod \
--install \
--wait \
--values=./charts/istio/istiod/values-"${cluster}".yaml \
--namespace istio-system \
--kube-context=kind-${cluster}
}
setupRemoteSecret() {
local cluster1context=${1}
local cluster2context=${2}
local apiServerIP=$(kubectl --context=kind-${cluster1context} get pod -n kube-system -l component=kube-apiserver -o jsonpath='{.items[0].status.podIP}')
local istioClusterName="${cluster1context/kind/istio}"
istioctl create-remote-secret \
--context=kind-${cluster1context} \
--server=https://${apiServerIP}:6443 \
--name=${istioClusterName} | \
kubectl apply -f - --context=kind-${cluster2context}
}
setupIngressGateway() {
local cluster=${1}
helm upgrade istio-ingressgateway ./charts/istio/ingress-gateway \
--install \
--wait \
--values=./charts/istio/ingress-gateway/values-"${cluster}".yaml \
--namespace istio-system \
--kube-context=kind-${cluster}
}
setupEastWestGateway() {
local cluster=${1}
helm upgrade istio-eastwestgateway ./charts/istio/eastwest-gateway \
--install \
--wait \
--values=./charts/istio/eastwest-gateway/values-"${cluster}".yaml \
--namespace istio-system \
--kube-context=kind-${cluster}
}
setupPrometheus() {
local cluster=${1}
kubectl --context=kind-${cluster} apply -f https://raw.githubusercontent.com/istio/istio/release-1.24/samples/addons/prometheus.yaml
}
main() {
for cluster in ${CLUSTERS[@]}; do
setupIstioCSR ${cluster}
setupIstioBase ${cluster}
setupIstiod ${cluster}
setupIngressGateway ${cluster}
# if cluster count is 1 then skip creating east west gateway
if [ ${#CLUSTERS[@]} -gt 1 ]; then
setupEastWestGateway ${cluster}
fi
# setupPrometheus ${cluster}
done
# if cluster count is 1 then skip creating remote secrets
if [ ${#CLUSTERS[@]} -gt 1 ]; then
for i in ${!CLUSTERS[@]}; do
for j in ${!CLUSTERS[@]}; do
if [ $i -ne $j ]; then
setupRemoteSecret ${CLUSTERS[$i]} ${CLUSTERS[$j]}
fi
done
done
fi
}
main