Skip to content

Commit fc8ad13

Browse files
committed
Improve README. Modernize examples.
1 parent ad9693f commit fc8ad13

12 files changed

+3884
-203
lines changed

README.md

+64-27
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,32 @@
99

1010
## JetStream Controller
1111

12-
The JetStream controllers allows you to manage [NATS JetStream](https://github.com/nats-io/jetstream) [Streams](https://github.com/nats-io/jetstream#streams-1) and [Consumers](https://github.com/nats-io/jetstream#consumers-1) via K8S CRDs.
12+
The JetStream controllers allows you to manage [NATS JetStream](https://github.com/nats-io/jetstream) [Streams](https://docs.nats.io/nats-concepts/jetstream/streams), [Consumers](https://docs.nats.io/nats-concepts/jetstream/consumers), [Key/Value Stores](https://docs.nats.io/nats-concepts/jetstream/key-value-store), and [Object Stores](https://docs.nats.io/nats-concepts/jetstream/obj_store) via Kubernetes CRDs.
13+
14+
Resources managed by NACK controllers are expected to _exclusively_ be managed by NACK, and configuration state will be enforced if mutated by an external client.
15+
16+
## [API Reference](docs/api.md)
1317

1418
### Getting started
1519

16-
First install the JetStream CRDs:
20+
Install with Helm:
1721

18-
```sh
19-
$ kubectl apply -f https://github.com/nats-io/nack/releases/latest/download/crds.yml
2022
```
23+
helm repo add nats https://nats-io.github.io/k8s/helm/charts/
24+
helm upgrade --install nats nats/nats --set config.jetstream.enabled=true
25+
helm upgrade --install nack nats/nack --set jetstream.nats.url=nats://nats.default.svc.cluster.local:4222
26+
```
27+
28+
#### (Optional) Enable Experimental `controller-runtime` Controllers
2129

22-
Now install with Helm:
30+
> **Note**: If migrating an existing install to the `controller-runtime` architecture, it is advisable to first enable with the `-read-only` flag.
31+
>
32+
> The `jetstream-controller` logs will preview any changes that would be made to existing resources.
33+
>
34+
> The updated architecture will more reliably enforce state. If all resources are in-sync with NACK, no changes are expected.
2335
2436
```
25-
helm repo add nats https://nats-io.github.io/k8s/helm/charts/
26-
helm install nats nats/nats --set=config.jetstream.enabled=true
27-
helm install nack nats/nack --set jetstream.nats.url=nats://nats:4222
37+
helm upgrade -n nack nack nats/nack --set jetstream.additionalArgs={-control-loop=true}
2838
```
2939

3040
#### Creating Streams and Consumers
@@ -66,6 +76,28 @@ spec:
6676
filterSubject: orders.received
6777
maxDeliver: 20
6878
ackPolicy: explicit
79+
---
80+
apiVersion: jetstream.nats.io/v1beta2
81+
kind: KeyValue
82+
metadata:
83+
name: my-key-value
84+
spec:
85+
bucket: my-key-value
86+
history: 20
87+
storage: file
88+
maxBytes: 2048
89+
compression: true
90+
---
91+
apiVersion: jetstream.nats.io/v1beta2
92+
kind: ObjectStore
93+
metadata:
94+
name: my-object-store
95+
spec:
96+
bucket: my-object-store
97+
storage: file
98+
replicas: 1
99+
maxBytes: 536870912 # 512 MB
100+
compression: true
69101
```
70102
71103
```sh
@@ -178,7 +210,7 @@ metadata:
178210
spec:
179211
name: a
180212
servers:
181-
- nats://nats:4222
213+
- nats://nats:4222
182214
tls:
183215
secret:
184216
name: nack-a-tls
@@ -209,31 +241,32 @@ Server URL and TLS certificates.
209241
210242
```sh
211243
# Install cert-manager
212-
kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.6.0/cert-manager.yaml
244+
kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.17.0/cert-manager.yaml
213245
214246
# Install TLS certs
215247
cd examples/secure
248+
216249
# Install certificate issuer
217250
kubectl apply -f issuer.yaml
251+
218252
# Install account A cert
219253
kubectl apply -f nack-a-client-tls.yaml
254+
220255
# Install server cert
221256
kubectl apply -f server-tls.yaml
257+
222258
# Install nats-box cert
223259
kubectl apply -f client-tls.yaml
224260
225261
# Install NATS cluster
226-
helm install -f nats-helm.yaml nats nats/nats
262+
helm upgrade --install -f nats-helm.yaml nats nats/nats
263+
227264
# Verify pods are healthy
228265
kubectl get pods
229266
230-
# Install nats-box to run nats cli later
231-
kubectl apply -f nats-client-box.yaml
232-
233267
# Install JetStream Controller from nack
234-
helm install --set jetstream.enabled=true jetstream-controller nats/nack
235-
# Install CRDs
236-
kubectl apply -f ../../deploy/crds.yml
268+
helm upgrade --install nack nats/nack --set jetstream.enabled=true
269+
237270
# Verify pods are healthy
238271
kubectl get pods
239272
@@ -242,6 +275,7 @@ kubectl apply -f nack/nats-account-a.yaml
242275
243276
# Create stream using account A
244277
kubectl apply -f nack/nats-stream-foo-a.yaml
278+
245279
# Create consumer using account A
246280
kubectl apply -f nack/nats-consumer-bar-a.yaml
247281
```
@@ -251,30 +285,28 @@ container to run the management CLI.
251285
252286
```sh
253287
# Get container shell
254-
kubectl exec -it nats-client-box-abc-123 -- sh
255-
# Change to TLS directory
256-
cd /etc/nats-certs/clients/nack-a-tls
288+
kubectl exec -it deployment/nats-box -- /bin/sh
257289
```
258290
259291
There should now be some Streams available, verify with `nats` command.
260292
261293
```sh
262294
# List streams
263-
nats --tlscert tls.crt --tlskey tls.key --tlsca ca.crt -s tls://nats.default.svc.cluster.local stream ls
295+
nats stream ls
264296
```
265297
266298
You can now publish messages on a Stream.
267299
268300
```sh
269301
# Push message
270-
nats --tlscert tls.crt --tlskey tls.key --tlsca ca.crt -s tls://nats.default.svc.cluster.local pub foo hi
302+
nats pub foo hi
271303
```
272304
273305
And pull messages from a Consumer.
274306
275307
```sh
276308
# Pull message
277-
nats --tlscert tls.crt --tlskey tls.key --tlsca ca.crt -s tls://nats.default.svc.cluster.local consumer next foo bar
309+
nats consumer next foo bar
278310
```
279311
280312
### Local Development
@@ -298,6 +330,7 @@ nats-server -DV -js
298330
```
299331
300332
Build Docker image
333+
301334
```sh
302335
make jetstream-controller-docker ver=1.2.3
303336
```
@@ -314,15 +347,15 @@ For more information see the
314347
315348
```
316349
helm repo add nats https://nats-io.github.io/k8s/helm/charts/
317-
helm install my-nats nats/nats
350+
helm upgrade --install nats nats/nats
318351
```
319352
320353
### Configuring
321354
322355
```yaml
323356
reloader:
324357
enabled: true
325-
image: natsio/nats-server-config-reloader:0.6.0
358+
image: natsio/nats-server-config-reloader:0.16.1
326359
pullPolicy: IfNotPresent
327360
```
328361
@@ -337,6 +370,7 @@ make nats-server-config-reloader
337370
```
338371
339372
Build Docker image
373+
340374
```sh
341375
make nats-server-config-reloader-docker ver=1.2.3
342376
```
@@ -350,14 +384,14 @@ For more information see the
350384
351385
```
352386
helm repo add nats https://nats-io.github.io/k8s/helm/charts/
353-
helm install my-nats nats/nats
387+
helm upgrade --install --create-namespace --namespace nats nats nats/nats
354388
```
355389
356390
### Configuring
357391
358392
```yaml
359393
bootconfig:
360-
image: natsio/nats-boot-config:0.5.2
394+
image: natsio/nats-boot-config:0.16.1
361395
pullPolicy: IfNotPresent
362396
```
363397
@@ -372,6 +406,9 @@ make nats-boot-config
372406
```
373407
374408
Build Docker image
409+
375410
```sh
376411
make nats-boot-config-docker ver=1.2.3
377412
```
413+
414+
## API Reference

cicd/Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#syntax=docker/dockerfile-upstream:1.13
1+
#syntax=docker/dockerfile:1.13
22
ARG GO_APP
33

4-
FROM alpine:3.21.2 as deps
4+
FROM alpine:3.21.3 as deps
55

66
ARG GO_APP
77
ARG GORELEASER_DIST_DIR=/go/src/dist
@@ -28,7 +28,7 @@ RUN <<EOT
2828
cp ${BIN_PATH} /go/bin
2929
EOT
3030

31-
FROM alpine:3.21.2
31+
FROM alpine:3.21.3
3232

3333
ARG GO_APP
3434
ENV GO_APP ${GO_APP}

cicd/Dockerfile_goreleaser

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#syntax=docker/dockerfile-upstream:1.5
1+
#syntax=docker/dockerfile:1.13
22
FROM --platform=$BUILDPLATFORM golang:1.24.0-bullseye as build
33

44

0 commit comments

Comments
 (0)