-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathgetting_started.sh
More file actions
executable file
·128 lines (108 loc) · 4.35 KB
/
getting_started.sh
File metadata and controls
executable file
·128 lines (108 loc) · 4.35 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
#!/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`.
# The getting started guide script
# It uses tagged regions which are included in the documentation
# https://docs.asciidoctor.org/asciidoc/latest/directives/include-tagged-regions/
#
# There are two variants to go through the guide - using stackablectl or helm
# The script takes either 'stackablectl' or 'helm' as an argument
#
# The script can be run as a test as well, to make sure that the tutorial works
# It includes some assertions throughout, and at the end especially.
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 26.3.0
helm install --wait secret-operator oci://oci.stackable.tech/sdp-charts/secret-operator --version 26.3.0
helm install --wait listener-operator oci://oci.stackable.tech/sdp-charts/listener-operator --version 26.3.0
helm install --wait trino-operator oci://oci.stackable.tech/sdp-charts/trino-operator --version 26.3.0
# end::helm-install-operators[]
;;
"stackablectl")
echo "installing Operators with stackablectl"
# tag::stackablectl-install-operators[]
stackablectl operator install \
commons=26.3.0 \
secret=26.3.0 \
listener=26.3.0 \
trino=26.3.0
# end::stackablectl-install-operators[]
;;
*)
echo "Need to provide 'helm' or 'stackablectl' as an argument for which installation method to use!"
exit 1
;;
esac
# TODO: Remove once https://github.com/stackabletech/issues/issues/828 has been
# implemented (see that issue for details).
until kubectl get crd trinoclusters.trino.stackable.tech >/dev/null 2>&1; do
echo "Waiting for CRDs to be installed"
sleep 1
done
until kubectl get crd trinocatalogs.trino.stackable.tech >/dev/null 2>&1; do
echo "Waiting for CRDs to be installed"
sleep 1
done
echo "Installing Trino cluster from trino.yaml"
# tag::install-trino[]
kubectl apply -f trino.yaml
# end::install-trino[]
sleep 15
echo "Awaiting Trino rollout finish"
# tag::watch-trino-rollout[]
kubectl rollout status --watch --timeout=5m statefulset/simple-trino-coordinator-default
kubectl rollout status --watch --timeout=5m statefulset/simple-trino-worker-default
# end::watch-trino-rollout[]
sleep 5
echo "Starting port-forwarding of coordinator port 8443"
# shellcheck disable=2069 # we want all output to be blackholed
# tag::port-forwarding[]
kubectl port-forward svc/simple-trino-coordinator 8443 2>&1 >/dev/null &
# end::port-forwarding[]
PORT_FORWARD_PID=$!
# shellcheck disable=2064 # we want the PID evaluated now, not at the time the trap is
trap "kill $PORT_FORWARD_PID" EXIT
sleep 5
echo "Start testing Trino"
echo "Downloading Trino CLI tool as trino.jar"
# tag::download-trino-cli[]
curl --fail --output trino.jar https://repo.stackable.tech/repository/packages/trino-cli/trino-cli-479
# end::download-trino-cli[]
echo "Run chmod +x for trino.jar"
# tag::chmod-trino-cli[]
chmod +x trino.jar
# end::chmod-trino-cli[]
echo "Retrieve catalogs"
# tag::retrieve-trino-catalogs[]
./trino.jar --insecure --output-format=CSV_UNQUOTED --server https://localhost:8443 --user admin --execute "SHOW CATALOGS"
# end::retrieve-trino-catalogs[]
# for testing
catalogs=$(./trino.jar --insecure --output-format=CSV_UNQUOTED --server https://localhost:8443 --user admin --execute "SHOW CATALOGS" 2>/dev/null)
if [ "$catalogs" != "system" ]; then
echo "Received $catalogs as catalogs. Expected 'system'"
exit 1
fi
echo "Retrieve amount of worker(s)"
# tag::retrieve-trino-workers[]
./trino.jar --insecure --output-format=CSV_UNQUOTED --server https://localhost:8443 --user admin --execute "SELECT COUNT(*) as nodes FROM system.runtime.nodes WHERE coordinator=false AND state='active'"
# end::retrieve-trino-workers[]
# for testing
nodes=$(./trino.jar --insecure --output-format=CSV_UNQUOTED --server https://localhost:8443 --user admin --execute "SELECT COUNT(*) as nodes FROM system.runtime.nodes WHERE coordinator=false AND state='active'" 2>/dev/null)
if [ "$nodes" != "1" ]; then
echo "Received $nodes workers(s). Expected 1."
exit 1
fi
# cleanup
# tag::cleanup-trino-cli[]
rm trino.jar
# end::cleanup-trino-cli[]
echo "All tests finished successfully!"