Skip to content

Commit 78366f1

Browse files
authored
add password for nats (#477)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced username and password parameters for NATS authentication, enhancing security options. - Added a new configuration for specifying the Kubernetes cluster domain for routing. - Implemented a new Role in Kubernetes RBAC for managing secrets related to the NATS dashboard. - **Bug Fixes** - Updated versioning information for the NATS application to reflect the latest changes. - **Documentation** - Enhanced the README with details on new authentication parameters and configuration options. - Updated the JSON schema to include new properties for user configuration. - **Chores** - Incremented the NATS application version from 0.2.0 to 0.3.0. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 47bd46c commit 78366f1

File tree

8 files changed

+92
-17
lines changed

8 files changed

+92
-17
lines changed

packages/apps/nats/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type: application
1616
# This is the chart version. This version number should be incremented each time you make changes
1717
# to the chart and its templates, including the app version.
1818
# Versions are expected to follow Semantic Versioning (https://semver.org/)
19-
version: 0.2.0
19+
version: 0.3.0
2020

2121
# This is the version number of the application being deployed. This version number should be
2222
# incremented each time you make changes to the application. Versions are not expected to

packages/apps/nats/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@
1010
| `replicas` | Persistent Volume size for NATS | `2` |
1111
| `storageClass` | StorageClass used to store the data | `""` |
1212

13+
### Configuration parameters
14+
15+
| Name | Description | Value |
16+
| ----------- | ----------------------- | ----- |
17+
| `users` | Users configuration | `{}` |

packages/apps/nats/templates/nats.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
{{- $passwords := dict }}
2+
{{- range $user, $u := .Values.users }}
3+
{{- if $u.password }}
4+
{{- $_ := set $passwords $user $u.password }}
5+
{{- else if not (index $passwords $user) }}
6+
{{- $_ := set $passwords $user (randAlphaNum 16) }}
7+
{{- end }}
8+
{{- end }}
9+
10+
{{- if .Values.users }}
11+
apiVersion: v1
12+
kind: Secret
13+
metadata:
14+
name: {{ .Release.Name }}-credentials
15+
stringData:
16+
{{- range $user, $u := .Values.users }}
17+
{{ quote $user }}: {{ quote (index $passwords $user) }}
18+
{{- end }}
19+
{{- end }}
20+
21+
---
22+
123
apiVersion: helm.toolkit.fluxcd.io/v2
224
kind: HelmRelease
325
metadata:
@@ -18,6 +40,16 @@ spec:
1840
nats:
1941
fullnameOverride: {{ .Release.Name }}
2042
config:
43+
{{- if gt (len .Values.passwords) 0 }}
44+
merge:
45+
accounts:
46+
A:
47+
users:
48+
{{- range $username, $password := $passwords }}
49+
- user: "{{ $username }}"
50+
password: "{{ $password }}"
51+
{{- end }}
52+
{{- end }}
2153
cluster:
2254
enabled: true
2355
replicas: {{ .Values.replicas }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: Role
3+
metadata:
4+
name: {{ .Release.Name }}-dashboard-resources
5+
rules:
6+
- apiGroups:
7+
- ""
8+
resources:
9+
- secrets
10+
resourceNames:
11+
- {{ .Release.Name }}-credentials
12+
verbs: ["get", "list", "watch"]

packages/apps/nats/values.schema.json

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,34 @@
22
"title": "Chart Values",
33
"type": "object",
44
"properties": {
5-
"external": {
6-
"type": "boolean",
7-
"description": "Enable external access from outside the cluster",
8-
"default": false
5+
"external": {
6+
"type": "boolean",
7+
"description": "Enable external access from outside the cluster",
8+
"default": false
9+
},
10+
"replicas": {
11+
"type": "number",
12+
"description": "Persistent Volume size for NATS",
13+
"default": 2
14+
},
15+
"storageClass": {
16+
"type": "string",
17+
"description": "StorageClass used to store the data",
18+
"default": ""
19+
},
20+
"users": {
21+
"type": "object",
22+
"description": "Users configuration",
23+
"additionalProperties": {
24+
"type": "object",
25+
"properties": {
26+
"password": {
27+
"type": "string",
28+
"description": "Password for the user"
29+
}
30+
}
931
},
10-
"replicas": {
11-
"type": "number",
12-
"description": "Persistent Volume size for NATS",
13-
"default": 2
14-
},
15-
"storageClass": {
16-
"type": "string",
17-
"description": "StorageClass used to store the data",
18-
"default": ""
19-
}
32+
"default": {}
33+
}
2034
}
21-
}
35+
}

packages/apps/nats/values.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,10 @@
88
external: false
99
replicas: 2
1010
storageClass: ""
11+
## @param users [object] Users configuration
12+
## Example:
13+
## users:
14+
## user1:
15+
## password: strongpassword
16+
## user2: {}
17+
users: {}

packages/apps/versions_map

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ mysql 0.5.0 4b84798
4848
mysql 0.5.1 fab5940b
4949
mysql 0.5.2 HEAD
5050
nats 0.1.0 5ca8823
51-
nats 0.2.0 HEAD
51+
nats 0.2.0 c07c4bbd
52+
nats 0.3.0 HEAD
5253
postgres 0.1.0 f642698
5354
postgres 0.2.0 7cd7de73
5455
postgres 0.2.1 4a97e297

packages/system/nats/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ nats:
55
persistentVolumeClaimRetentionPolicy:
66
whenDeleted: Delete
77
whenScaled: Delete
8+
config:
9+
cluster:
10+
routeURLs:
11+
k8sClusterDomain: cozy.local

0 commit comments

Comments
 (0)