-
Notifications
You must be signed in to change notification settings - Fork 0
/
pond-install.sh
executable file
·71 lines (62 loc) · 2.1 KB
/
pond-install.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
#!/bin/bash
# Copyright (c) 2023 Ho Kim ([email protected]). All rights reserved.
# Use of this source code is governed by a GPL-3-style license that can be
# found in the LICENSE file.
# Prehibit errors
set -e -o pipefail
###########################################################
# Main Function #
###########################################################
for cluster_name in $("$(dirname "$0")/ceph-ls.sh"); do
echo -n "* ${cluster_name}: "
kubectl config use-context "${cluster_name}"
# Infer namespace
cluster_namespace="$(
cat "$(pwd)/clusters/${cluster_name}.yaml" |
grep -Po '^ +namespace\: *\K[0-9a-z-]+$' |
head -n 1 ||
true
)"
if [ "x${cluster_namespace}" = 'x' ]; then
continue
elif
! echo "${cluster_namespace}" |
grep -Po '^tenant-[0-9a-z-]+' >/dev/null
then
continue
fi
# Install Data Pond
cat "$(pwd)/clusters/_common_pre.yaml" |
sed "s/__NAMESPACE__/${cluster_namespace}/g" |
kubectl create -f - || true
kubectl apply \
--context "${cluster_name}" \
--filename "$(pwd)/clusters/${cluster_name}.yaml"
cat "$(pwd)/clusters/_common_post.yaml" |
sed "s/__NAMESPACE__/${cluster_namespace}/g" |
kubectl create -f - || true
# Bind models to each owned storage
if
kubectl \
--context "${cluster_name}" \
get namespace 'csi-rook-ceph' \
>/dev/null 2>/dev/null
then
cat "$(pwd)/clusters/_binding.yaml" |
sed "s/__NAMESPACE__/${cluster_namespace}/g" |
kubectl create -f - || true
fi
# Install Data Pond Functions
for function_set in $(ls "$(pwd)/functions"); do
kubectl create configmap "${function_set}-functions" \
--namespace="${cluster_namespace}" \
--from-file=$(pwd)/functions/${function_set} \
--output=yaml \
--dry-run=client |
kubectl apply -f -
done
done
# Cleanup
kubectl config use-context 'default'
# Done
exec echo 'Finished!'