Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions helm/charts/nack-resources/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Common VCS dirs
.git/
.github/
.idea/
.vscode/
.DS_Store
Thumbs.db

# Archives and charts
*.tgz
*.tar.gz
Chart.lock
21 changes: 21 additions & 0 deletions helm/charts/nack-resources/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v2
name: nack-resources
version: 0.0.1
description: A Helm chart for NACK resources - Install NATS JetStream resources (Streams, Consumers, KeyValues, ObjectStores) via NACK CRDs
sources:
- https://github.com/nats-io/nack
- https://github.com/nats-io/k8s
keywords:
- nats
- jetstream
- nack
- streams
- consumers
- keyvalue
- objectstore
home: http://github.com/nats-io/k8s
maintainers:
- email: info@nats.io
name: The NATS Authors
url: https://github.com/nats-io
icon: https://nats.io/img/nats-icon-color.png
76 changes: 76 additions & 0 deletions helm/charts/nack-resources/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Helm chart - NATS JetStream Controller (NACK) Resources

Helm chart for managing NATS JetStream resources (Streams, Consumers, KeyValues, ObjectStores) managed by the NACK controllers.

You must install the [NACK controllers](https://github.com/nats-io/nack) first to let this chart renders the custom resources (CRs).

### Install

Provide connection settings and one or more resources:

```
helm install my-resources ./helm/charts/nack-resources \
--namespace default \
-f values.yaml
```

Upgrade:

```
helm upgrade my-resources ./helm/charts/nack-resources -f values.yaml
```

Uninstall:

```
helm uninstall my-resources
```

### Values overview

- `nats`: shared connectivity used by all resources unless overridden per-item (`connection`).
- `servers`, `jsDomain`, `account`, `creds`, `nkey`, `tls{}`
- `preflight.crdChecks.enabled`: fail early if required CRDs are missing (default: `true`).
- `streams[]`: list of Stream specs. Minimal fields: `name`, `subjects`.
- `consumers[]`: list of Consumer specs. Minimal fields: `streamName`, `durableName`.
- `objectStores[]`: list of Object Store specs. Minimal field: `bucket`.
- `keyValues[]`: list of Key/Value Store specs. Minimal field: `bucket`.

See `values.yaml` for all available fields and descriptions (mirrors the NACK CRD schemas).

### Quick examples

Minimal Stream:

```
streams:
- name: orders
subjects: ["orders.*"]
```

Pull Consumer for the stream above:

```
consumers:
- streamName: orders
durableName: orders-pull
ackPolicy: explicit
```

Key/Value bucket:

```
keyValues:
- bucket: app-config
history: 5
storage: memory
```

Object Store bucket:

```
objectStores:
- bucket: media
storage: file
replicas: 1
```
9 changes: 9 additions & 0 deletions helm/charts/nack-resources/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Thank you for installing the nack-resources chart.

This chart renders NATS JetStream resources (Streams, Consumers, KeyValues, ObjectStores)
managed by the NACK controllers. Ensure the NACK CRDs and controllers are installed.

You can find more information about running NATS JetStream Controller on
Kubernetes here:

https://github.com/nats-io/nack
28 changes: 28 additions & 0 deletions helm/charts/nack-resources/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- define "nack-resources.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "nack-resources.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := include "nack-resources.name" . -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{- define "nack-resources.labels" -}}
app.kubernetes.io/name: {{ include "nack-resources.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" }}
{{- if .Values.commonLabels }}
{{- toYaml .Values.commonLabels | nindent 0 }}
{{- end }}
{{- end -}}

8 changes: 8 additions & 0 deletions helm/charts/nack-resources/templates/_preflight-crds.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{- if .Values.preflight.crdChecks.enabled }}
{{- $required := list "streams.jetstream.nats.io" "consumers.jetstream.nats.io" "keyvalues.jetstream.nats.io" "objectstores.jetstream.nats.io" -}}
{{- range $crd := $required }}
{{- if not (lookup "apiextensions.k8s.io/v1" "CustomResourceDefinition" "" $crd) }}
{{- fail (printf "Required CRD %s not found. Install NACK CRDs first (helm/charts/nack/crds)." $crd) }}
{{- end }}
{{- end }}
{{- end }}
139 changes: 139 additions & 0 deletions helm/charts/nack-resources/templates/consumers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
{{- $globals := .Values.nats | default dict -}}
{{- range .Values.consumers }}
---
apiVersion: jetstream.nats.io/v1beta2
kind: Consumer
metadata:
# include stream and durable in the resource name to avoid collisions
name: {{ printf "%s-%s-%s" $.Release.Name .streamName .durableName | trunc 63 | trimSuffix "-" }}
labels:
{{ include "nack-resources.labels" $ | nindent 4 }}
spec:
streamName: {{ .streamName | quote }}
durableName: {{ .durableName | quote }}
{{- with .deliverPolicy }}
deliverPolicy: {{ . }}
{{- end }}
{{- with .optStartSeq }}
optStartSeq: {{ . }}
{{- end }}
{{- with .optStartTime }}
optStartTime: {{ . | quote }}
{{- end }}
{{- with .replayPolicy }}
replayPolicy: {{ . }}
{{- end }}
{{- with .deliverSubject }}
deliverSubject: {{ . | quote }}
{{- end }}
{{- with .deliverGroup }}
deliverGroup: {{ . | quote }}
{{- end }}
{{- with .filterSubject }}
filterSubject: {{ . | quote }}
{{- end }}
{{- with .filterSubjects }}
filterSubjects:
{{ toYaml . | nindent 4 }}
{{- end }}

{{- with .ackPolicy }}
ackPolicy: {{ . }}
{{- end }}
{{- with .ackWait }}
ackWait: {{ . | quote }}
{{- end }}
{{- with .maxDeliver }}
maxDeliver: {{ . }}
{{- end }}
{{- with .backoff }}
backoff:
{{ toYaml . | nindent 4 }}
{{- end }}
{{- with .maxAckPending }}
maxAckPending: {{ . }}
{{- end }}

{{- with .sampleFreq }}
sampleFreq: {{ . | quote }}
{{- end }}
{{- with .rateLimitBps }}
rateLimitBps: {{ . }}
{{- end }}
{{- with .flowControl }}
flowControl: {{ . }}
{{- end }}
{{- with .heartbeatInterval }}
heartbeatInterval: {{ . | quote }}
{{- end }}
{{- with .headersOnly }}
headersOnly: {{ . }}
{{- end }}

{{- with .maxWaiting }}
maxWaiting: {{ . }}
{{- end }}
{{- with .maxRequestBatch }}
maxRequestBatch: {{ . }}
{{- end }}
{{- with .maxRequestExpires }}
maxRequestExpires: {{ . | quote }}
{{- end }}
{{- with .maxRequestMaxBytes }}
maxRequestMaxBytes: {{ . }}
{{- end }}

{{- with .inactiveThreshold }}
inactiveThreshold: {{ . | quote }}
{{- end }}
{{- with .replicas }}
replicas: {{ . }}
{{- end }}
{{- with .memStorage }}
memStorage: {{ . }}
{{- end }}

{{- with .metadata }}
metadata:
{{ toYaml . | nindent 4 }}
{{- end }}
{{- with $globals.account }}
account: {{ . | quote }}
{{- end }}
{{- with $globals.servers }}
servers:
{{ toYaml . | nindent 4 }}
{{- end }}
{{- with $globals.jsDomain }}
jsDomain: {{ . | quote }}
{{- end }}
{{- with $globals.creds }}
creds: {{ . | quote }}
{{- end }}
{{- with $globals.nkey }}
nkey: {{ . | quote }}
{{- end }}
{{- if $globals.tls }}
tls:
{{- with $globals.tls.clientCert }}
clientCert: {{. | quote }}
{{- end }}
{{- with $globals.tls.clientKey }}
clientKey: {{. | quote }}
{{- end }}
{{- with $globals.tls.rootCas }}
rootCas:
{{ toYaml . | nindent 6 }}
{{- end }}
{{- end }}
{{- with $globals.tlsFirst }}
tlsFirst: {{ . }}
{{- end }}

{{- with .preventDelete }}
preventDelete: {{ . }}
{{- end }}
{{- with .preventUpdate }}
preventUpdate: {{ . }}
{{- end }}
{{- end }}
Loading