Skip to content

Commit 4fe7a1c

Browse files
authored
Merge pull request #413 from ivanauth/fix/issue-77-enable-watch-api-example
Enable CockroachDB rangefeeds in example for Watch API
2 parents 680cffd + 5218bce commit 4fe7a1c

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

examples/cockroachdb-tls-ingress/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This will guide you through setting up a complete example SpiceDB cluster:
55
- Managed by the operator
66
- With multiple nodes that dispatch to each other (with TLS)
77
- With a cockroachdb backing datastore
8+
- With the Watch API enabled (via CockroachDB rangefeeds)
89
- With ingress (and TLS)
910

1011
## Configure Root CA
@@ -110,6 +111,19 @@ EOF
110111
zed schema read
111112
```
112113

114+
## Watch API
115+
116+
The CockroachDB configuration in this example enables [rangefeeds], which are required for the SpiceDB [Watch API]. A Kubernetes Job runs automatically to set `kv.rangefeed.enabled = true` on the CockroachDB cluster.
117+
118+
You can verify rangefeeds are enabled by checking the CockroachDB cluster setting:
119+
120+
```sh
121+
kubectl exec cockroachdb-0 -- cockroach sql --insecure --execute="SHOW CLUSTER SETTING kv.rangefeed.enabled;"
122+
```
123+
124+
[rangefeeds]: https://www.cockroachlabs.com/docs/stable/create-and-configure-changefeeds.html
125+
[Watch API]: https://authzed.com/docs/spicedb/concepts/commands#watch
126+
113127
## Clean up
114128

115129
Clean up the changes from this example with:

examples/cockroachdb-tls-ingress/database/crdb.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,33 @@ spec:
154154
resources:
155155
requests:
156156
storage: 100Gi
157+
---
158+
# Enable rangefeeds so the SpiceDB Watch API works.
159+
apiVersion: batch/v1
160+
kind: Job
161+
metadata:
162+
name: crdb-enable-rangefeeds
163+
spec:
164+
template:
165+
spec:
166+
restartPolicy: OnFailure
167+
initContainers:
168+
- name: wait-for-crdb
169+
image: cockroachdb/cockroach:v22.1.6
170+
command:
171+
- "/bin/bash"
172+
- "-c"
173+
- |
174+
until /cockroach/cockroach sql --insecure --host=cockroachdb-public --execute="SELECT 1"; do
175+
echo "waiting for CockroachDB..."
176+
sleep 2
177+
done
178+
containers:
179+
- name: enable-rangefeeds
180+
image: cockroachdb/cockroach:v22.1.6
181+
command:
182+
- "/cockroach/cockroach"
183+
- "sql"
184+
- "--insecure"
185+
- "--host=cockroachdb-public"
186+
- "--execute=SET CLUSTER SETTING kv.rangefeed.enabled = true;"

0 commit comments

Comments
 (0)