forked from submariner-io/submariner-charts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy_helm
72 lines (62 loc) · 3.15 KB
/
deploy_helm
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
# shellcheck shell=bash
# shellcheck source=scripts/shared/lib/source_only
. "${BASH_SOURCE%/*}"/source_only
### Constants ###
readonly SUBMARINER_BROKER_NS=submariner-k8s-broker
readonly SUBMARINER_PSK=$(LC_CTYPE=C tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 64 | head -n 1)
### Functions ###
function deploytool_prereqs() {
helm version
}
function setup_broker() {
if kubectl get crd clusters.submariner.io > /dev/null 2>&1; then
echo "Submariner CRDs already exist, skipping broker creation..."
else
echo "Installing submariner broker..."
# shellcheck disable=SC2086 # Split on purpose
helm install "${SUBMARINER_BROKER_NS}" ./submariner-k8s-broker \
--create-namespace \
--kube-context "${cluster}" \
--namespace "${SUBMARINER_BROKER_NS}" \
${deploytool_broker_args}
fi
submariner_broker_url=$(kubectl -n default get endpoints kubernetes -o jsonpath="{.subsets[0].addresses[0].ip}:{.subsets[0].ports[?(@.name=='https')].port}")
submariner_broker_ca=$(kubectl -n "${SUBMARINER_BROKER_NS}" get secrets -o jsonpath="{.items[?(@.metadata.annotations['kubernetes\.io/service-account\.name']=='${SUBMARINER_BROKER_NS}-client')].data['ca\.crt']}")
submariner_broker_token=$(kubectl -n "${SUBMARINER_BROKER_NS}" get secrets -o jsonpath="{.items[?(@.metadata.annotations['kubernetes\.io/service-account\.name']=='${SUBMARINER_BROKER_NS}-client')].data.token}"|base64 --decode)
}
function helm_install_subm() {
local crd_create=false
[[ "${cluster}" = "${broker}" ]] || crd_create=true
if kubectl wait --for=condition=Ready pods -l app=submariner-operator -n "${SUBM_NS}" --timeout=60s > /dev/null 2>&1; then
echo "Submariner already installed, skipping installation..."
return
fi
echo "Installing Submariner..."
# shellcheck disable=SC2086 # Split on purpose
helm --kube-context "${cluster}" install submariner-operator \
./submariner-operator \
--create-namespace \
--namespace "${SUBM_NS}" \
--set ipsec.psk="${SUBMARINER_PSK}" \
--set broker.server="${submariner_broker_url}" \
--set broker.token="${submariner_broker_token}" \
--set broker.namespace="${SUBMARINER_BROKER_NS}" \
--set broker.ca="${submariner_broker_ca}" \
--set submariner.cableDriver="${cable_driver}" \
--set submariner.clusterId="${cluster}" \
--set submariner.clusterCidr="${cluster_CIDRs[$cluster]}" \
--set submariner.serviceCidr="${service_CIDRs[$cluster]}" \
--set submariner.globalCidr="${global_CIDRs[$cluster]}" \
--set serviceAccounts.globalnet.create="${globalnet}" \
--set submariner.natEnabled="false" \
--set operator.image.repository="localhost:5000/submariner-operator" \
--set operator.image.tag="local" \
--set operator.image.pullPolicy="IfNotPresent" \
--set submariner.images.repository="localhost:5000" \
--set submariner.images.tag="local" \
--set brokercrds.create="${crd_create}" \
${deploytool_submariner_args}
}
function install_subm_all_clusters() {
run_subm_clusters helm_install_subm
}