-
Notifications
You must be signed in to change notification settings - Fork 0
/
standalone_deps.sh
executable file
·68 lines (54 loc) · 2.56 KB
/
standalone_deps.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
#!/bin/bash
# Copyright (c) 2024-2024 Hopsworks AB. All rights reserved.
CERT_MANAGER_URL=https://github.com/cert-manager/cert-manager/releases/download/v1.14.3/cert-manager.yaml
HELM_NGINX_NAME=ingress-nginx
HELM_NGINX_INSTANCE_NAME=rondb-ingress-nginx
setup_deps() {
(
set -e
RONDB_NAMESPACE=$1
echo "Setting up dependencies for standalone RonDB deployment in namespace $RONDB_NAMESPACE"
# Note:
# This is not placed entirely in Helm dependencies because
# 1. Helm will not install the CRDs
# 2. We need to know the namespace to install the Ingress controller (see below)
# Deploy cert-manager
kubectl apply -f $CERT_MANAGER_URL
echo "Created cert-manager"
# The Ingress in the Helmchart requires the nginx Ingress controller
# to run (admission webhook).
# Setting TCP parameters since raw TCP connections are not supported by default;
# see https://kubernetes.github.io/ingress-nginx/user-guide/exposing-tcp-udp-services/
# These flags will create a ConfigMap with the TCP services and ports to expose.
# WARN: This will automatically expose the MySQLd, regardless of the values.yaml.
# No need to also set RDRS HTTP (4406); can be defined in the actual Ingress.
helm upgrade --install $HELM_NGINX_INSTANCE_NAME $HELM_NGINX_NAME \
--repo https://kubernetes.github.io/ingress-nginx \
--namespace=$RONDB_NAMESPACE \
--set "tcp.3306"="$RONDB_NAMESPACE/mysqld:3306" \
--set "tcp.5406"="$RONDB_NAMESPACE/rdrs:5406"
echo "Created Nginx Ingress controller"
kubectl wait \
--namespace $RONDB_NAMESPACE \
--for=condition=ready pod \
--selector=app.kubernetes.io/component=controller \
--timeout=300s
echo "Nginx Ingress controller is ready - we can instantiate nginx Ingress instances now"
)
}
destroy_deps() {
(
set +e
set -x
# Remove cert-manager
kubectl delete -f $CERT_MANAGER_URL
# Remove all related to Nginx-Ingress controller
kubectl delete all --all -n $HELM_NGINX_NAME
kubectl delete namespace $HELM_NGINX_NAME
kubectl delete clusterrole $HELM_NGINX_INSTANCE_NAME
kubectl delete clusterrolebinding $HELM_NGINX_INSTANCE_NAME
kubectl delete ingressClass nginx
kubectl delete ValidatingWebhookConfiguration $HELM_NGINX_NAME-admission
kubectl delete ValidatingWebhookConfiguration $HELM_NGINX_INSTANCE_NAME-admission
)
}