9
9
10
10
## JetStream Controller
11
11
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 )
13
17
14
18
### Getting started
15
19
16
- First install the JetStream CRDs :
20
+ Install with Helm :
17
21
18
- ``` sh
19
- $ kubectl apply -f https://github.com/nats-io/nack/releases/latest/download/crds.yml
20
22
```
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
21
29
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.
23
35
24
36
```
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}
28
38
```
29
39
30
40
#### Creating Streams and Consumers
66
76
filterSubject : orders.received
67
77
maxDeliver : 20
68
78
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
69
101
` ` `
70
102
71
103
` ` ` sh
@@ -178,7 +210,7 @@ metadata:
178
210
spec:
179
211
name: a
180
212
servers:
181
- - nats://nats:4222
213
+ - nats://nats:4222
182
214
tls:
183
215
secret:
184
216
name: nack-a-tls
@@ -209,31 +241,32 @@ Server URL and TLS certificates.
209
241
210
242
```sh
211
243
# 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
213
245
214
246
# Install TLS certs
215
247
cd examples/secure
248
+
216
249
# Install certificate issuer
217
250
kubectl apply -f issuer.yaml
251
+
218
252
# Install account A cert
219
253
kubectl apply -f nack-a-client-tls.yaml
254
+
220
255
# Install server cert
221
256
kubectl apply -f server-tls.yaml
257
+
222
258
# Install nats-box cert
223
259
kubectl apply -f client-tls.yaml
224
260
225
261
# 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
+
227
264
# Verify pods are healthy
228
265
kubectl get pods
229
266
230
- # Install nats-box to run nats cli later
231
- kubectl apply -f nats-client-box.yaml
232
-
233
267
# 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
+
237
270
# Verify pods are healthy
238
271
kubectl get pods
239
272
@@ -242,6 +275,7 @@ kubectl apply -f nack/nats-account-a.yaml
242
275
243
276
# Create stream using account A
244
277
kubectl apply -f nack/nats-stream-foo-a.yaml
278
+
245
279
# Create consumer using account A
246
280
kubectl apply -f nack/nats-consumer-bar-a.yaml
247
281
```
@@ -251,30 +285,28 @@ container to run the management CLI.
251
285
252
286
` ` ` sh
253
287
# 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
257
289
` ` `
258
290
259
291
There should now be some Streams available, verify with ` nats` command.
260
292
261
293
` ` ` sh
262
294
# 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
264
296
` ` `
265
297
266
298
You can now publish messages on a Stream.
267
299
268
300
` ` ` sh
269
301
# 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
271
303
` ` `
272
304
273
305
And pull messages from a Consumer.
274
306
275
307
` ` ` sh
276
308
# 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
278
310
` ` `
279
311
280
312
# ## Local Development
@@ -298,6 +330,7 @@ nats-server -DV -js
298
330
` ` `
299
331
300
332
Build Docker image
333
+
301
334
` ` ` sh
302
335
make jetstream-controller-docker ver=1.2.3
303
336
` ` `
@@ -314,15 +347,15 @@ For more information see the
314
347
315
348
` ` `
316
349
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
318
351
` ` `
319
352
320
353
# ## Configuring
321
354
322
355
` ` ` yaml
323
356
reloader:
324
357
enabled: true
325
- image: natsio/nats-server-config-reloader:0.6.0
358
+ image: natsio/nats-server-config-reloader:0.16.1
326
359
pullPolicy: IfNotPresent
327
360
` ` `
328
361
@@ -337,6 +370,7 @@ make nats-server-config-reloader
337
370
` ` `
338
371
339
372
Build Docker image
373
+
340
374
` ` ` sh
341
375
make nats-server-config-reloader-docker ver=1.2.3
342
376
` ` `
@@ -350,14 +384,14 @@ For more information see the
350
384
351
385
` ` `
352
386
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
354
388
` ` `
355
389
356
390
# ## Configuring
357
391
358
392
` ` ` yaml
359
393
bootconfig:
360
- image: natsio/nats-boot-config:0.5.2
394
+ image: natsio/nats-boot-config:0.16.1
361
395
pullPolicy: IfNotPresent
362
396
` ` `
363
397
@@ -372,6 +406,9 @@ make nats-boot-config
372
406
` ` `
373
407
374
408
Build Docker image
409
+
375
410
` ` ` sh
376
411
make nats-boot-config-docker ver=1.2.3
377
412
` ` `
413
+
414
+ # # API Reference
0 commit comments