-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathgetting_started.sh
More file actions
executable file
·126 lines (103 loc) · 3.48 KB
/
getting_started.sh
File metadata and controls
executable file
·126 lines (103 loc) · 3.48 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/env bash
set -euo pipefail
# DO NOT EDIT THE SCRIPT
# Instead, update the j2 template, and regenerate it for dev with `make render-docs`.
# This script contains all the code snippets from the guide, as well as some assert tests
# to test if the instructions in the guide work. The user *could* use it, but it is intended
# for testing only.
# The script will install the operator(s), create a product instance and interact with it.
if [ $# -eq 0 ]
then
echo "Installation method argument ('helm' or 'stackablectl') required."
exit 1
fi
cd "$(dirname "$0")"
case "$1" in
"helm")
echo "Installing Operators with Helm"
# tag::helm-install-operators[]
helm install --wait commons-operator oci://oci.stackable.tech/sdp-charts/commons-operator --version 0.0.0-dev
helm install --wait secret-operator oci://oci.stackable.tech/sdp-charts/secret-operator --version 0.0.0-dev
helm install --wait listener-operator oci://oci.stackable.tech/sdp-charts/listener-operator --version 0.0.0-dev
helm install --wait zookeeper-operator oci://oci.stackable.tech/sdp-charts/zookeeper-operator --version 0.0.0-dev
# end::helm-install-operators[]
;;
"stackablectl")
echo "installing Operators with stackablectl"
# tag::stackablectl-install-operators[]
stackablectl operator install \
commons=0.0.0-dev \
secret=0.0.0-dev \
listener=0.0.0-dev \
zookeeper=0.0.0-dev
# end::stackablectl-install-operators[]
;;
*)
echo "Need to give 'helm' or 'stackablectl' as an argument for which installation method to use!"
exit 1
;;
esac
echo "Creating ZooKeeper cluster"
# tag::install-zookeeper[]
kubectl apply -f zookeeper.yaml
# end::install-zookeeper[]
sleep 15
### Connect to cluster
echo "Awaiting ZooKeeper rollout finish"
# tag::watch-zookeeper-rollout[]
kubectl rollout status --watch --timeout=5m statefulset/simple-zk-server-default
# end::watch-zookeeper-rollout[]
# kubectl run sometimes misses log output, which is why we use run/logs/delete.
# Issue for reference: https://github.com/kubernetes/kubernetes/issues/27264
zkCli_ls() {
# tag::zkcli-ls[]
kubectl run my-pod \
--stdin --tty --quiet --restart=Never \
--image oci.stackable.tech/sdp/zookeeper:3.9.4-stackable0.0.0-dev -- \
bin/zkCli.sh -server simple-zk-server:2282 ls / > /dev/null && \
kubectl logs my-pod && \
kubectl delete pods my-pod
# end::zkcli-ls[]
}
ls_result=$(zkCli_ls) >/dev/null 2>&1
if echo "$ls_result" | grep '^\[zookeeper\]' > /dev/null; then
echo "zkCli.sh ls command worked"
else
echo "zkCli.sh ls command did not work. command output:"
echo "$ls_result"
exit 1
fi
### ZNode
echo "Applying ZNode"
# tag::apply-znode[]
kubectl apply -f znode.yaml
# end::apply-znode[]
sleep 5
ls_result=$(zkCli_ls) > /dev/null 2>&1
if echo "$ls_result" | grep '^\[znode-.\{8\}-.\{4\}-.\{4\}-.\{4\}-.\{12\}, zookeeper\]' > /dev/null; then
echo "zkCli.sh ls command worked"
else
echo "zkCli.sh ls command did not work. command output:"
echo "$ls_result"
exit 1
fi
get_configmap() {
# tag::get-znode-cm
kubectl describe configmap simple-znode
# end::get-znode-cm
}
cm_output=$(get_configmap)
# shellcheck disable=SC2181 # wont't fix this now, but ideally we should enable bash strict mode so we can avoid success checks.
if [[ $? == 0 ]]; then
echo "ConfigMap retrieved."
else
echo "Could not get ConfigMap 'simple-znode'"
exit 1
fi
if echo "$cm_output" | grep 2282/znode > /dev/null; then
echo "ConfigMap contains a reference of the ZNode"
else
echo "ConfigMap doesn't seem to reference the ZNode"
exit 1
fi
echo "Script ran successfully!"