Skip to content

Commit 585241d

Browse files
Felix Hennigfhennig
Felix Hennig
andcommitted
docs: getting started guide (#537)
# Description fixes #536 Co-authored-by: Felix Hennig <[email protected]>
1 parent 571fae1 commit 585241d

15 files changed

+446
-100
lines changed

docs/antora.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ name: zookeeper
22
version: "nightly"
33
title: Stackable Operator for Apache ZooKeeper
44
nav:
5+
- modules/getting_started/nav.adoc
56
- modules/ROOT/nav.adoc
67
prerelease: true

docs/modules/ROOT/nav.adoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
* xref:installation.adoc[]
21
* xref:configuration.adoc[]
32
* xref:usage.adoc[]
43
* Concepts

docs/modules/ROOT/pages/installation.adoc

Lines changed: 0 additions & 61 deletions
This file was deleted.
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# This script contains all the code snippets from the guide, as well as some assert tests
5+
# to test if the instructions in the guide work. The user *could* use it, but it is intended
6+
# for testing only.
7+
# The script will install the operator(s), create a product instance and interact with it.
8+
9+
if [ $# -eq 0 ]
10+
then
11+
echo "Installation method argument ('helm' or 'stackablectl') required."
12+
exit 1
13+
fi
14+
15+
case "$1" in
16+
"helm")
17+
echo "Adding 'stackable-dev' Helm Chart repository"
18+
# tag::helm-add-repo[]
19+
helm repo add stackable-dev https://repo.stackable.tech/repository/helm-dev/
20+
# end::helm-add-repo[]
21+
echo "Installing Operators with Helm"
22+
# tag::helm-install-operators[]
23+
helm install --wait commons-operator stackable-dev/commons-operator --version 0.3.0-nightly
24+
helm install --wait secret-operator stackable-dev/secret-operator --version 0.6.0-nightly
25+
helm install --wait zookeeper-operator stackable-dev/zookeeper-operator --version 0.11.0-nightly
26+
# end::helm-install-operators[]
27+
;;
28+
"stackablectl")
29+
echo "installing Operators with stackablectl"
30+
# tag::stackablectl-install-operators[]
31+
stackablectl operator install \
32+
commons=0.3.0-nightly \
33+
secret=0.6.0-nightly \
34+
zookeeper=0.11.0-nightly
35+
# end::stackablectl-install-operators[]
36+
;;
37+
*)
38+
echo "Need to give 'helm' or 'stackablectl' as an argument for which installation method to use!"
39+
exit 1
40+
;;
41+
esac
42+
43+
echo "Creating ZooKeeper cluster"
44+
# tag::install-zookeeper[]
45+
kubectl apply -f zookeeper.yaml
46+
# end::install-zookeeper[]
47+
48+
sleep 5
49+
50+
### Connect to cluster
51+
52+
echo "Awaiting ZooKeeper rollout finish"
53+
# tag::watch-zookeeper-rollout[]
54+
kubectl rollout status --watch statefulset/simple-zk-server-default
55+
# end::watch-zookeeper-rollout[]
56+
57+
# kubectl run sometimes misses log output, which is why we use run/logs/delete.
58+
# Issue for reference: https://github.com/kubernetes/kubernetes/issues/27264
59+
zkCli_ls() {
60+
# tag::zkcli-ls[]
61+
kubectl run my-pod \
62+
--stdin --tty --quiet --restart=Never \
63+
--image docker.stackable.tech/stackable/zookeeper:3.8.0-stackable0.7.1 -- \
64+
bin/zkCli.sh -server simple-zk-server-default:2282 ls / > /dev/null && \
65+
kubectl logs my-pod && \
66+
kubectl delete pods my-pod
67+
# end::zkcli-ls[]
68+
}
69+
70+
ls_result=$(zkCli_ls) >/dev/null 2>&1
71+
72+
73+
if echo "$ls_result" | grep '^\[zookeeper\]' > /dev/null; then
74+
echo "zkCli.sh ls command worked"
75+
else
76+
echo "zkCli.sh ls command did not work. command output:"
77+
echo "$ls_result"
78+
exit 1
79+
fi
80+
81+
### ZNode
82+
83+
echo "Applying ZNode"
84+
# tag::apply-znode[]
85+
kubectl apply -f znode.yaml
86+
# end::apply-znode[]
87+
88+
sleep 5
89+
90+
ls_result=$(zkCli_ls) > /dev/null 2>&1
91+
92+
if echo "$ls_result" | grep '^\[znode-.\{8\}-.\{4\}-.\{4\}-.\{4\}-.\{12\}, zookeeper\]' > /dev/null; then
93+
echo "zkCli.sh ls command worked"
94+
else
95+
echo "zkCli.sh ls command did not work. command output:"
96+
echo "$ls_result"
97+
exit 1
98+
fi
99+
100+
get_configmap() {
101+
# tag::get-znode-cm
102+
kubectl describe configmap simple-znode
103+
# end::get-znode-cm
104+
}
105+
106+
cm_output=$(get_configmap)
107+
108+
if [[ $? == 0 ]]; then
109+
echo "ConfigMap retrieved."
110+
else
111+
echo "Could not get ConfigMap 'simple-znode'"
112+
exit 1
113+
fi
114+
115+
if echo "$cm_output" | grep 2282/znode > /dev/null; then
116+
echo "ConfigMap contains a reference of the ZNode"
117+
else
118+
echo "ConfigMap doesn't seem to reference the ZNode"
119+
exit 1
120+
fi
121+
122+
echo "Script ran successfully!"
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# This script contains all the code snippets from the guide, as well as some assert tests
5+
# to test if the instructions in the guide work. The user *could* use it, but it is intended
6+
# for testing only.
7+
# The script will install the operator(s), create a product instance and interact with it.
8+
9+
if [ $# -eq 0 ]
10+
then
11+
echo "Installation method argument ('helm' or 'stackablectl') required."
12+
exit 1
13+
fi
14+
15+
case "$1" in
16+
"helm")
17+
echo "Adding 'stackable-dev' Helm Chart repository"
18+
# tag::helm-add-repo[]
19+
helm repo add {{ helm.repo_name }} {{ helm.repo_url }}
20+
# end::helm-add-repo[]
21+
echo "Installing Operators with Helm"
22+
# tag::helm-install-operators[]
23+
helm install --wait commons-operator {{ helm.repo_name }}/commons-operator --version {{ versions.commons }}
24+
helm install --wait secret-operator {{ helm.repo_name }}/secret-operator --version {{ versions.secret }}
25+
helm install --wait zookeeper-operator {{ helm.repo_name }}/zookeeper-operator --version {{ versions.zk }}
26+
# end::helm-install-operators[]
27+
;;
28+
"stackablectl")
29+
echo "installing Operators with stackablectl"
30+
# tag::stackablectl-install-operators[]
31+
stackablectl operator install \
32+
commons={{ versions.commons }} \
33+
secret={{ versions.secret }} \
34+
zookeeper={{ versions.zk }}
35+
# end::stackablectl-install-operators[]
36+
;;
37+
*)
38+
echo "Need to give 'helm' or 'stackablectl' as an argument for which installation method to use!"
39+
exit 1
40+
;;
41+
esac
42+
43+
echo "Creating ZooKeeper cluster"
44+
# tag::install-zookeeper[]
45+
kubectl apply -f zookeeper.yaml
46+
# end::install-zookeeper[]
47+
48+
sleep 5
49+
50+
### Connect to cluster
51+
52+
echo "Awaiting ZooKeeper rollout finish"
53+
# tag::watch-zookeeper-rollout[]
54+
kubectl rollout status --watch statefulset/simple-zk-server-default
55+
# end::watch-zookeeper-rollout[]
56+
57+
# kubectl run sometimes misses log output, which is why we use run/logs/delete.
58+
# Issue for reference: https://github.com/kubernetes/kubernetes/issues/27264
59+
zkCli_ls() {
60+
# tag::zkcli-ls[]
61+
kubectl run my-pod \
62+
--stdin --tty --quiet --restart=Never \
63+
--image docker.stackable.tech/stackable/zookeeper:3.8.0-stackable0.7.1 -- \
64+
bin/zkCli.sh -server simple-zk-server-default:2282 ls / > /dev/null && \
65+
kubectl logs my-pod && \
66+
kubectl delete pods my-pod
67+
# end::zkcli-ls[]
68+
}
69+
70+
ls_result=$(zkCli_ls) >/dev/null 2>&1
71+
72+
73+
if echo "$ls_result" | grep '^\[zookeeper\]' > /dev/null; then
74+
echo "zkCli.sh ls command worked"
75+
else
76+
echo "zkCli.sh ls command did not work. command output:"
77+
echo "$ls_result"
78+
exit 1
79+
fi
80+
81+
### ZNode
82+
83+
echo "Applying ZNode"
84+
# tag::apply-znode[]
85+
kubectl apply -f znode.yaml
86+
# end::apply-znode[]
87+
88+
sleep 5
89+
90+
ls_result=$(zkCli_ls) > /dev/null 2>&1
91+
92+
if echo "$ls_result" | grep '^\[znode-.\{8\}-.\{4\}-.\{4\}-.\{4\}-.\{12\}, zookeeper\]' > /dev/null; then
93+
echo "zkCli.sh ls command worked"
94+
else
95+
echo "zkCli.sh ls command did not work. command output:"
96+
echo "$ls_result"
97+
exit 1
98+
fi
99+
100+
get_configmap() {
101+
# tag::get-znode-cm
102+
kubectl describe configmap simple-znode
103+
# end::get-znode-cm
104+
}
105+
106+
cm_output=$(get_configmap)
107+
108+
if [[ $? == 0 ]]; then
109+
echo "ConfigMap retrieved."
110+
else
111+
echo "Could not get ConfigMap 'simple-znode'"
112+
exit 1
113+
fi
114+
115+
if echo "$cm_output" | grep 2282/znode > /dev/null; then
116+
echo "ConfigMap contains a reference of the ZNode"
117+
else
118+
echo "ConfigMap doesn't seem to reference the ZNode"
119+
exit 1
120+
fi
121+
122+
echo "Script ran successfully!"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[INFO ] Installing commons operator in version 0.3.0-nightly
2+
[INFO ] Installing secret operator in version 0.6.0-nightly
3+
[INFO ] Installing zookeeper operator in version 0.11.0-nightly
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[INFO ] Installing commons operator in version {{ versions.commons }}
2+
[INFO ] Installing secret operator in version {{ versions.secret }}
3+
[INFO ] Installing zookeeper operator in version {{ versions.zookeeper }}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
apiVersion: zookeeper.stackable.tech/v1alpha1
3+
kind: ZookeeperZnode
4+
metadata:
5+
name: simple-znode
6+
spec:
7+
clusterRef:
8+
name: simple-zk
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
apiVersion: zookeeper.stackable.tech/v1alpha1
3+
kind: ZookeeperCluster
4+
metadata:
5+
name: simple-zk
6+
spec:
7+
version: 3.8.0-stackable0.7.1
8+
servers:
9+
roleGroups:
10+
default:
11+
replicas: 3

docs/modules/getting_started/nav.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* xref:index.adoc[]
2+
** xref:installation.adoc[]
3+
** xref:first_steps.adoc[]

0 commit comments

Comments
 (0)