2020 exit 1
2121fi
2222
23+ echo " Waiting for node(s) to be ready..."
24+ kubectl wait node --all --for=condition=Ready --timeout=120s
25+
2326cd " $( dirname " $0 " ) "
2427
2528case " $1 " in
5255;;
5356esac
5457
58+ # TODO: Remove once https://github.com/stackabletech/issues/issues/828 has been implemented (see that issue for details).
59+ until kubectl get crd druidclusters.druid.stackable.tech > /dev/null 2>&1 ; do echo " Waiting for CRDs to be installed" && sleep 1; done
60+
5561echo " Installing ZooKeeper from zookeeper.yaml"
5662# tag::install-zookeeper[]
5763kubectl apply -f zookeeper.yaml
8995
9096echo " Awaiting HDFS rollout finish"
9197# tag::watch-hdfs-rollout[]
92- kubectl rollout status --watch statefulset/simple-hdfs-datanode-default --timeout=300s
93- kubectl rollout status --watch statefulset/simple-hdfs-journalnode-default --timeout=300s
94- kubectl rollout status --watch statefulset/simple-hdfs-namenode-default --timeout=300s
98+ kubectl rollout status --watch statefulset/simple-hdfs-datanode-default --timeout=600s
99+ kubectl rollout status --watch statefulset/simple-hdfs-journalnode-default --timeout=600s
100+ kubectl rollout status --watch statefulset/simple-hdfs-namenode-default --timeout=600s
95101# end::watch-hdfs-rollout[]
96102
97103echo " Installing PostgreSQL for Druid"
@@ -125,39 +131,36 @@ done
125131
126132echo " Awaiting Druid rollout finish"
127133# tag::watch-druid-rollout[]
128- kubectl rollout status --watch statefulset/simple-druid-broker-default --timeout=300s
129- kubectl rollout status --watch statefulset/simple-druid-coordinator-default --timeout=300s
130- kubectl rollout status --watch statefulset/simple-druid-historical-default --timeout=300s
131- kubectl rollout status --watch statefulset/simple-druid-middlemanager-default --timeout=300s
132- kubectl rollout status --watch statefulset/simple-druid-router-default --timeout=300s
134+ kubectl rollout status --watch statefulset/simple-druid-broker-default --timeout=600s
135+ kubectl rollout status --watch statefulset/simple-druid-coordinator-default --timeout=600s
136+ kubectl rollout status --watch statefulset/simple-druid-historical-default --timeout=600s
137+ kubectl rollout status --watch statefulset/simple-druid-middlemanager-default --timeout=600s
138+ kubectl rollout status --watch statefulset/simple-druid-router-default --timeout=600s
133139# end::watch-druid-rollout[]
134140
135- echo " Starting port-forwarding of port 9088"
136- # shellcheck disable=2069 # we want all output to be blackholed
137- # tag::port-forwarding[]
138- kubectl port-forward svc/simple-druid-router 9088 > /dev/null 2>&1 &
139- # end::port-forwarding[]
140- PORT_FORWARD_PID=$!
141- # shellcheck disable=2064 # we want the PID evaluated now, not at the time the trap is
142- trap " kill $PORT_FORWARD_PID " EXIT
143- sleep 5
141+ COORDINATOR=" simple-druid-coordinator-default-headless.default.svc.cluster.local"
142+ BROKER=" simple-druid-broker-default-headless.default.svc.cluster.local"
144143
145144submit_job () {
146- # tag::submit-job[]
147- curl -s -k -X ' POST' -H ' Content-Type:application/json' -d @ingestion_spec.json https://localhost:9088/druid/indexer/v1/task
148- # end::submit-job[]
145+ # tag::submit-job[]
146+ kubectl exec simple-druid-coordinator-default-0 -i -- \
147+ curl -s -k -X POST -H ' Content-Type:application/json' --data-binary @- \
148+ " https://${COORDINATOR} :8281/druid/indexer/v1/task" < ingestion_spec.json
149+ # end::submit-job[]
149150}
150151
151152echo " Submitting job"
152153task_id=$( submit_job | sed -e ' s/.*":"\([^"]\+\).*/\1/g' )
153154
154155request_job_status () {
155- curl -s -k " https://localhost:9088/druid/indexer/v1/task/${task_id} /status" | sed -e ' s/.*statusCode":"\([^"]\+\).*/\1/g'
156+ kubectl exec simple-druid-coordinator-default-0 -- \
157+ curl -s -k " https://${COORDINATOR} :8281/druid/indexer/v1/task/${task_id} /status" \
158+ | sed -e ' s/.*statusCode":"\([^"]\+\).*/\1/g'
156159}
157160
158161while [ " $( request_job_status) " == " RUNNING" ]; do
159162 echo " Task still running..."
160- sleep 5
163+ sleep 10
161164done
162165
163166task_status=$( request_job_status)
@@ -170,18 +173,22 @@ else
170173fi
171174
172175segment_load_status () {
173- curl -s -k https://localhost:9088/druid/coordinator/v1/loadstatus | sed -e ' s/.*wikipedia":\([0-9\.]\+\).*/\1/g'
176+ kubectl exec simple-druid-coordinator-default-0 -- \
177+ curl -s -k " https://${COORDINATOR} :8281/druid/coordinator/v1/loadstatus" \
178+ | sed -e ' s/.*wikipedia":\([0-9\.]\+\).*/\1/g'
174179}
175180
176181while [ " $( segment_load_status) " != " 100.0" ]; do
177182 echo " Segments still loading..."
178- sleep 5
183+ sleep 10
179184done
180185
181186query_data () {
182- # tag::query-data[]
183- curl -s -k -X ' POST' -H ' Content-Type:application/json' -d @query.json https://localhost:9088/druid/v2/sql
184- # end::query-data[]
187+ # tag::query-data[]
188+ kubectl exec simple-druid-broker-default-0 -i -- \
189+ curl -s -k -X POST -H ' Content-Type:application/json' --data-binary @- \
190+ " https://${BROKER} :8282/druid/v2/sql" < query.json
191+ # end::query-data[]
185192}
186193
187194echo " Querying data..."
0 commit comments