NATs: fix hardcode, add merge and resolve config (#514)

<!-- 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 -->
This commit is contained in:
klinch0
2024-12-06 12:36:20 +03:00
committed by GitHub
parent b7a51ba0bb
commit da1e705a49
6 changed files with 101 additions and 11 deletions

View File

@@ -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

View File

@@ -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 | `{}` |

View File

@@ -40,8 +40,9 @@ 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:
@@ -49,6 +50,14 @@ spec:
- 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
@@ -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 }}

View File

@@ -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": {}
}
}
}
}
}

View File

@@ -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: {}

View File

@@ -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