-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmmcai-setup.sh
executable file
·95 lines (75 loc) · 2.61 KB
/
mmcai-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
#!/bin/bash
source logging.sh
## welcome message
div
log "Welcome to MMC.AI setup!"
div
NAMESPACE="mmcai-system"
div
log_good "Please provide information for billing database:"
div
read -p "MySQL database node hostname: " mysql_node_hostname
read -sp "MySQL root password: " MYSQL_ROOT_PASSWORD
echo ""
div
log_good "Creating directories for billing database:"
div
wget -O mysql-pre-setup.sh https://raw.githubusercontent.com/MemVerge/mmc.ai-setup/main/mysql-pre-setup.sh
chmod +x mysql-pre-setup.sh
./mysql-pre-setup.sh
div
log_good "Creating namespaces if needed..."
div
function helm_login() {
# Extract creds
secret_json=$(
kubectl get secret memverge-dockerconfig -n mmcai-system --output="jsonpath={.data.\.dockerconfigjson}" |
base64 --decode
)
secret_user=$(echo ${secret_json} | jq -r '.auths."ghcr.io/memverge".username')
secret_token=$(echo ${secret_json} | jq -r '.auths."ghcr.io/memverge".password')
# Attempt login
if echo $secret_token | helm registry login ghcr.io/memverge -u $secret_user --password-stdin; then
div
log_good "Helm login was successful."
else
div
log_bad "Helm login was unsuccessful."
log_bad "Please provide an mmcai-ghcr-secret.yaml that allows helm login."
div
log "Report:"
cat mmcai-ghcr-secret.yaml
div
exit 1
fi
}
if [[ -f "mmcai-ghcr-secret.yaml" ]]; then
kubectl apply -f mmcai-ghcr-secret.yaml
helm registry logout ghcr.io/memverge
helm_login
else
kubectl create ns $NAMESPACE
kubectl create ns mmcloud-operator-system
fi
## Create monitoring namespace
kubectl get namespace monitoring &>/dev/null || kubectl create namespace monitoring
div
log_good "Creating secrets if needed..."
div
## Create MySQL secret
kubectl -n $NAMESPACE get secret mmai-mysql-secret &>/dev/null || \
# While we only need mysql-root-password, all of these keys are necessary for the secret according to the mysql Helm chart documentation
kubectl -n $NAMESPACE create secret generic mmai-mysql-secret \
--from-literal=mysql-root-password=$MYSQL_ROOT_PASSWORD \
--from-literal=mysql-password=$MYSQL_ROOT_PASSWORD \
--from-literal=mysql-replication-password=$MYSQL_ROOT_PASSWORD
div
log_good "Beginning installation..."
div
## install mmc.ai system
helm install --debug -n $NAMESPACE mmcai-cluster oci://ghcr.io/memverge/charts/mmcai-cluster \
--version 0.2.0 \
--set billing.database.nodeHostname=$mysql_node_hostname
## install mmc.ai management
helm install --debug -n $NAMESPACE mmcai-manager oci://ghcr.io/memverge/charts/mmcai-manager \
--version 0.2.0