-
Notifications
You must be signed in to change notification settings - Fork 68
/
noobaa_install.sh
executable file
·92 lines (81 loc) · 2.94 KB
/
noobaa_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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
function check_minikube_version() {
is_correct_version=$(kubectl version | grep 'Server Version: version.Info{Major:"1", Minor:"18"')
if [ -z "$is_correct_version" ]; then
echo "Minikube uses incompatible k8s version"
echo "Execute 'minikube config set kubernetes-version v1.18.8' and restart minikube"
exit 0
fi
}
function wait_for_backingstore_ready() {
for (( ; ; )); do
backingstore_ready=$(kubectl get backingstore -o=jsonpath='{.items[0].status.phase}')
if [[ $backingstore_ready == "Ready" ]]; then
echo "Backingstore ready!"
break
fi
echo "Waiting for backingstore to be ready"
sleep 5
done
}
function wait_for_pods_created() {
for (( ; ; )); do
noobaa_pods=$(kubectl get pods --no-headers -l app=noobaa | wc -l)
if [[ $noobaa_pods == "3" ]]; then
echo "Noobaa pods ready!"
break
fi
echo "Waiting for the 3 noobaa pods to be ready"
sleep 5
done
}
function wait_for_pods_running() {
kubectl wait --for=condition=ready pods -l app=noobaa >/dev/null 2>&1
}
function install_noobaa() {
echo -n "Downloading NooBaa CLI..."
uKernel="$(uname -s)"
case "${uKernel}" in
Darwin*) os=mac ;;
Linux*) os=linux ;;
esac
wget -P ${DIR} https://github.com/noobaa/noobaa-operator/releases/download/v2.3.0/noobaa-${os}-v2.3.0 >/dev/null 2>&1
mv ${DIR}/noobaa-${os}-* ${DIR}/noobaa
chmod +x ${DIR}/noobaa
echo "done"
echo "Installing NooBaa..."
${DIR}/noobaa install --mini=true >/dev/null 2>&1
wait_for_pods_created
wait_for_pods_running
echo "Installed NooBaa"
echo "Creating Backing Store"
${DIR}/noobaa backingstore create pv-pool my-pv-bs --num-volumes 3 --pv-size-gb 16 --storage-class standard >/dev/null 2>&1
echo "Created Backing Store"
wait_for_backingstore_ready
echo "Delete Bucket Class"
${DIR}/noobaa bucketclass delete noobaa-default-bucket-class >/dev/null 2>&1
echo "Delete Bucket Class"
echo "Creating Bucket Class"
${DIR}/noobaa bucketclass create noobaa-default-bucket-class --backingstores=my-pv-bs --placement="" >/dev/null 2>&1
echo "Created Bucket Class"
echo "done"
}
function run_data_loader() {
echo -n "Creating test OBC..."
kubectl create -f ${DIR}/obc.yaml >/dev/null 2>&1
while [ -z "$(kubectl get obc | grep Bound)" ]; do sleep 10; done
echo "done"
key_id=$(${DIR}/noobaa status 2>&1 | grep AWS_ACCESS_KEY_ID | awk -F ": " '{print $2}')
acc_key=$(${DIR}/noobaa status 2>&1 | grep AWS_SECRET_ACCESS_KEY | awk -F ": " '{print $2}')
bucket=$(${DIR}/noobaa bucket list 2>&1 | grep my-bucket)
echo -n "Loading data to example bucket..."
sed -e "s|{KEY_ID}|${key_id}|g" \
-e "s|{ACCESS_KEY}|${acc_key}|g" \
-e "s|{BUCKET}|${bucket}|g" ${DIR}/data-loader-noobaa.yaml | kubectl create -f - >/dev/null 2>&1
kubectl wait --for=condition=complete job/example-noobaa-data
echo "done"
}
check_minikube_version
install_noobaa
run_data_loader