Skip to content

Commit

Permalink
NATs: fix hardcode, add merge and resolve config (#514)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Release Notes

- **New Features**
- Introduced new configuration parameters for Jetstream, including
`jetstream.size` and `jetstream.enabled`, enhancing storage and
functionality options.
- Added support for merging additional configurations with
`config.merge` and `config.resolver`.

- **Bug Fixes**
- Improved password generation and configuration merging logic for
better flexibility in deployments.

- **Version Updates**
  - NATS application version updated from `0.3.1` to `0.4.0`.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
klinch0 authored Dec 6, 2024
1 parent b7a51ba commit da1e705
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/apps/nats/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.3.1
version: 0.4.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
16 changes: 10 additions & 6 deletions packages/apps/nats/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@

### Common parameters

| Name | Description | Value |
| -------------- | ----------------------------------------------- | ------- |
| `external` | Enable external access from outside the cluster | `false` |
| `replicas` | Persistent Volume size for NATS | `2` |
| `storageClass` | StorageClass used to store the data | `""` |
| `users` | Users configuration | `{}` |
| Name | Description | Value |
| ------------------- | -------------------------------------------------- | ------- |
| `external` | Enable external access from outside the cluster | `false` |
| `replicas` | Persistent Volume size for NATS | `2` |
| `storageClass` | StorageClass used to store the data | `""` |
| `users` | Users configuration | `{}` |
| `jetstream.size` | Jetstream persistent storage size | `10Gi` |
| `jetstream.enabled` | Enable or disable Jetstream | `true` |
| `config.merge` | Additional configuration to merge into NATS config | `{}` |
| `config.resolver` | Additional configuration to merge into NATS config | `{}` |
15 changes: 12 additions & 3 deletions packages/apps/nats/templates/nats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,24 @@ spec:
nats:
fullnameOverride: {{ .Release.Name }}
config:
{{- if gt (len $passwords) 0 }}
{{- if or (gt (len $passwords) 0) (gt (len .Values.config.merge) 0) }}
merge:
{{- if gt (len $passwords) 0 }}
accounts:
A:
users:
{{- range $username, $password := $passwords }}
- user: "{{ $username }}"
password: "{{ $password }}"
{{- end }}
{{- end }}
{{- if and .Values.config (hasKey .Values.config "merge") }}
{{ toYaml .Values.config.merge | nindent 12 }}
{{- end }}
{{- end }}
{{- if and .Values.config (hasKey .Values.config "resolver") }}
resolver:
{{ toYaml .Values.config.resolver | nindent 12 }}
{{- end }}
cluster:
enabled: true
Expand All @@ -58,10 +67,10 @@ spec:
jetstream:
enabled: true
fileStore:
enabled: true
enabled: {{ .Values.jetstream.enabled }}
pvc:
enabled: true
size: 10Gi
size: {{ .Values.jetstream.size }}
{{- with .Values.storageClass }}
storageClassName: {{ . }}
{{- end }}
Expand Down
30 changes: 30 additions & 0 deletions packages/apps/nats/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,36 @@
"type": "string",
"description": "StorageClass used to store the data",
"default": ""
},
"jetstream": {
"type": "object",
"properties": {
"size": {
"type": "string",
"description": "Jetstream persistent storage size",
"default": "10Gi"
},
"enabled": {
"type": "boolean",
"description": "Enable or disable Jetstream",
"default": true
}
}
},
"config": {
"type": "object",
"properties": {
"merge": {
"type": "object",
"description": "Additional configuration to merge into NATS config",
"default": {}
},
"resolver": {
"type": "object",
"description": "Additional configuration to merge into NATS config",
"default": {}
}
}
}
}
}
46 changes: 46 additions & 0 deletions packages/apps/nats/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,49 @@ storageClass: ""
## password: strongpassword
## user2: {}
users: {}

jetstream:
## @param jetstream.size Jetstream persistent storage size
## Specifies the size of the persistent storage for Jetstream (message store).
## Default: 10Gi
size: 10Gi

## @param jetstream.enabled Enable or disable Jetstream
## Set to true to enable Jetstream for persistent messaging in NATS.
## Default: true
enabled: true

config:
## @param config.merge Additional configuration to merge into NATS config
## Allows you to customize NATS server settings by merging additional configurations.
## For example, you can add extra parameters, configure authentication, or set custom settings.
## Default: {}
## example:
##
## merge:
## $include: ./my-config.conf
## zzz$include: ./my-config-last.conf
## server_name: nats
## authorization:
## token: << $TOKEN >>
## jetstream:
## max_memory_store: << 1GB >>
##
## will yield the config:
## {
## include ./my-config.conf;
## "authorization": {
## "token": $TOKEN
## },
## "jetstream": {
## "max_memory_store": 1GB
## },
## "server_name": "nats",
## include ./my-config-last.conf;
## }
merge: {}
## @param config.resolver Additional configuration to merge into NATS config
## Allows you to customize NATS server settings by merging resolver configurations.
## Default: {}
## Example see: https://github.com/nats-io/k8s/blob/main/helm/charts/nats/values.yaml#L247
resolver: {}
3 changes: 2 additions & 1 deletion packages/apps/versions_map
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ mysql 0.5.2 HEAD
nats 0.1.0 5ca8823
nats 0.2.0 c07c4bbd
nats 0.3.0 78366f19
nats 0.3.1 HEAD
nats 0.3.1 b7375f73
nats 0.4.0 HEAD
postgres 0.1.0 f642698
postgres 0.2.0 7cd7de73
postgres 0.2.1 4a97e297
Expand Down

0 comments on commit da1e705

Please sign in to comment.