-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgetting_started.sh
More file actions
executable file
·227 lines (194 loc) · 7.12 KB
/
getting_started.sh
File metadata and controls
executable file
·227 lines (194 loc) · 7.12 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#!/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. It installs an HBase cluster and its dependencies and executes several steps
# to verify that it is working.
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 zookeeper-operator oci://oci.stackable.tech/sdp-charts/zookeeper-operator --version 25.7.0 &
helm install --wait hdfs-operator oci://oci.stackable.tech/sdp-charts/hdfs-operator --version 25.7.0 &
helm install --wait commons-operator oci://oci.stackable.tech/sdp-charts/commons-operator --version 25.7.0 &
helm install --wait secret-operator oci://oci.stackable.tech/sdp-charts/secret-operator --version 25.7.0 &
helm install --wait listener-operator oci://oci.stackable.tech/sdp-charts/listener-operator --version 25.7.0 &
helm install --wait hbase-operator oci://oci.stackable.tech/sdp-charts/hbase-operator --version 25.7.0 &
wait
# end::helm-install-operators[]
;;
"stackablectl")
echo "installing Operators with stackablectl"
# tag::stackablectl-install-operators[]
stackablectl operator install \
commons=25.7.0 \
secret=25.7.0 \
listener=25.7.0 \
zookeeper=25.7.0 \
hdfs=25.7.0 \
hbase=25.7.0
# 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-zk[]
kubectl apply -f zk.yaml
# end::install-zk[]
echo "Creating ZNode"
# tag::install-zk[]
kubectl apply -f znode.yaml
# end::install-zk[]
for (( i=1; i<=15; i++ ))
do
echo "Waiting for ZookeeperCluster to appear ..."
if eval kubectl get statefulset simple-zk-server-default; then
break
fi
sleep 1
done
echo "Awaiting ZooKeeper rollout finish"
# tag::watch-zk-rollout[]
kubectl rollout status --watch statefulset/simple-zk-server-default --timeout=300s
# end::watch-zk-rollout[]
echo "Creating HDFS cluster"
# tag::install-hdfs[]
kubectl apply -f hdfs.yaml
# end::install-hdfs[]
for (( i=1; i<=15; i++ ))
do
echo "Waiting for HdfsCluster to appear ..."
if eval kubectl get statefulset simple-hdfs-datanode-default; then
break
fi
sleep 1
done
echo "Awaiting HDFS rollout finish"
# tag::watch-hdfs-rollout[]
kubectl rollout status --watch statefulset/simple-hdfs-datanode-default --timeout=300s
kubectl rollout status --watch statefulset/simple-hdfs-namenode-default --timeout=300s
kubectl rollout status --watch statefulset/simple-hdfs-journalnode-default --timeout=300s
# end::watch-hdfs-rollout[]
sleep 5
echo "Creating HBase cluster"
# tag::install-hbase[]
kubectl apply -f hbase.yaml
# end::install-hbase[]
for (( i=1; i<=15; i++ ))
do
echo "Waiting for HBaseCluster to appear ..."
if eval kubectl get statefulset simple-hbase-master-default; then
break
fi
sleep 1
done
echo "Awaiting HBase rollout finish"
# tag::watch-hbase-rollout[]
kubectl rollout status --watch statefulset/simple-hbase-master-default --timeout=300s
kubectl rollout status --watch statefulset/simple-hbase-regionserver-default --timeout=300s
kubectl rollout status --watch statefulset/simple-hbase-restserver-default --timeout=300s
# end::watch-hbase-rollout[]
version() {
# tag::cluster-version[]
kubectl exec -n default simple-hbase-restserver-default-0 -- \
curl -s -XGET -H "Accept: application/json" "http://simple-hbase-restserver-default-headless:8080/version/cluster"
# end::cluster-version[]
}
echo "Check cluster version..."
cluster_version=$(version | jq -r '.Version')
if [ "$cluster_version" == "2.6.2-stackable25.7.0" ]; then
echo "Cluster version: $cluster_version"
else
echo "Unexpected version: $cluster_version"
exit 1
fi
echo "Check cluster status..."
# tag::cluster-status[]
kubectl exec -n default simple-hbase-restserver-default-0 \
-- curl -s -XGET -H "Accept: application/json" "http://simple-hbase-restserver-default-headless:8080/status/cluster" | json_pp
# end::cluster-status[]
echo "Check table via REST API..."
# tag::create-table[]
kubectl exec -n default simple-hbase-restserver-default-0 \
-- curl -s -XPUT -H "Accept: text/xml" -H "Content-Type: text/xml" \
"http://simple-hbase-restserver-default-headless:8080/users/schema" \
-d '<TableSchema name="users"><ColumnSchema name="cf" /></TableSchema>'
# end::create-table[]
# tag::get-table[]
kubectl exec -n default simple-hbase-restserver-default-0 \
-- curl -s -XGET -H "Accept: application/json" "http://simple-hbase-restserver-default-headless:8080/users/schema" | json_pp
# end::get-table[]
get_all() {
# tag::get-tables[]
kubectl exec -n default simple-hbase-restserver-default-0 \
-- curl -s -XGET -H "Accept: application/json" "http://simple-hbase-restserver-default-headless:8080/" | json_pp
# end::get-tables[]
}
echo "Checking tables found..."
tables_count=$(get_all | jq -r '.table' | jq '. | length')
# There should only be the one table we created
expected_tables=$(echo "
users
" | sort | sed '/^$/d')
expected_count=$(echo "$expected_tables" | wc -l)
if [ "$tables_count" == "$expected_count" ]; then
echo "...$tables_count expected table(s)"
else
echo "...an unexpected number: $tables_count instead of $expected_count"
actual_tables=$(get_all | jq -r '.table[].name' | sort)
echo "additional tables expected to be present (if any):"
comm -13 <(echo "$actual_tables") <(echo "$expected_tables")
echo "additional tables unexpectedly present (if any):"
comm -23 <(echo "$actual_tables") <(echo "$expected_tables")
echo
echo "If you have already run the script, data from the next steps will already exist"
exit 1
fi
echo "Check table via Phoenix..."
# tag::phoenix-table[]
kubectl exec -n default simple-hbase-restserver-default-0 -- \
/stackable/phoenix/bin/psql.py \
/stackable/phoenix/examples/WEB_STAT.sql \
/stackable/phoenix/examples/WEB_STAT.csv \
/stackable/phoenix/examples/WEB_STAT_QUERIES.sql
# end::phoenix-table[]
echo "Re-checking tables: found..."
tables_count=$(get_all | jq -r '.table' | jq '. | length')
# Phoenix sometimes introduces new tables, so we can list the expected tables
# here, and error out if they don't match
expected_tables=$(echo "
SYSTEM.CATALOG
SYSTEM.CHILD_LINK
SYSTEM.FUNCTION
SYSTEM.LOG
SYSTEM.MUTEX
SYSTEM.SEQUENCE
SYSTEM.STATS
SYSTEM.TASK
SYSTEM.TRANSFORM
WEB_STAT
users
" | sort | sed '/^$/d')
expected_count=$(echo "$expected_tables" | wc -l)
if [ "$tables_count" == "$expected_count" ]; then
echo "...$tables_count expected tables. Success!"
else
echo "...an unexpected number: $tables_count instead of $expected_count"
actual_tables=$(get_all | jq -r '.table[].name' | sort)
echo "additional tables expected to be present (if any):"
comm -13 <(echo "$actual_tables") <(echo "$expected_tables")
echo "additional tables unexpectedly present (if any):"
comm -23 <(echo "$actual_tables") <(echo "$expected_tables")
exit 1
fi