-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·81 lines (63 loc) · 2.8 KB
/
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
#!/bin/bash
set -eou pipefail
# if we aren't in one of the orbstack/docker-desktop contexts, bail out. basically i want to prevent accidentally deploying
# this stuff to staging (or god help us, prod).
context=$(kubectl config current-context)
if [[ "$context" != "orbstack" ]] && [[ "$context" != "docker-desktop" ]] && [[ "$context" != "minikube" ]]; then
echo "You are not in the right kube context, current context is: $context. We want 'orbstack' or 'docker-desktop'"
exit 1
fi
DIR=$(dirname -- "${BASH_SOURCE[0]}")
# Build the customized (sorta) ProxySQL docker image
# pushd "$DIR/../helm/proxysql"
# docker build -t persona-id/proxysql . -t persona-id/proxysql:latest -t persona-id/proxysql:1.1.1
# popd
# Create the mysql infra
## Create the MySQL namespace, unless it already exists
kubectl get namespace mysql > /dev/null 2>&1 \
|| kubectl create ns mysql
## US1
kubectl get configmap -n mysql us1-initdb > /dev/null 2>&1 \
|| kubectl create configmap -n mysql us1-initdb --from-file="$DIR/../helm/data/mysql-us1.sql"
helm install mysql-us1 -n mysql "$DIR/../helm/mysql" \
--set nameOverride="mysql-us1" \
--set architecture="replication" \
--set auth.rootPassword="rootpw" \
--set auth.replicationPassword="replication" \
--set auth.database="web-us1" \
--set auth.username="web-us1" \
--set auth.password="web-us1" \
--set initdbScriptsConfigMap="us1-initdb"
## US2
kubectl get configmap -n mysql us2-initdb > /dev/null 2>&1 \
|| kubectl create configmap -n mysql us2-initdb --from-file="$DIR/../helm/data/mysql-us2.sql"
helm install mysql-us2 -n mysql "$DIR/../helm/mysql" \
--set nameOverride="mysql-us2" \
--set architecture="replication" \
--set auth.rootPassword="rootpw" \
--set auth.replicationPassword="replication" \
--set auth.database="web-us2" \
--set auth.username="web-us2" \
--set auth.password="web-us2" \
--set initdbScriptsConfigMap="us2-initdb"
# helm install proxysql -n mysql "$DIR/../helm/mysql" \
# --set nameOverride="proxysql" \
# --set architecture="standalone" \
# --set auth.rootPassword="rootpw" \
# --set auth.database="proxysql" \
# --set auth.username="proxysql" \
# --set auth.password="proxysql"
## End MySQL
echo "Sleeping 10s to allow mysql to finish coming up"
sleep 10
# Create the ProxySQL infra
## Create the ProxySQL namespace, unless it already exists
kubectl get namespace proxysql > /dev/null 2>&1 \
|| kubectl create ns proxysql
## ProxySQL leader cluster, which manages the configuration state of the rest of the cluster
helm install proxysql-core -n proxysql "$DIR/../helm/proxysql/core"
echo "Sleeping 10s to allow core to finish coming up"
sleep 10
## ProxySQL main cluster, which will be serving the actual proxied sql traffic
helm install proxysql-satellite -n proxysql "$DIR/../helm/proxysql/satellite"
# End ProxySQL infra