Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add password for nats #477

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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.2.0
version: 0.3.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
5 changes: 5 additions & 0 deletions packages/apps/nats/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@
| `replicas` | Persistent Volume size for NATS | `2` |
| `storageClass` | StorageClass used to store the data | `""` |

### Configuration parameters

| Name | Description | Value |
| ----------- | ----------------------- | ----- |
| `users` | Users configuration | `{}` |
34 changes: 34 additions & 0 deletions packages/apps/nats/templates/nats.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
{{- $passwords := dict }}
{{- range $user, $u := .Values.users }}
{{- if $u.password }}
{{- $_ := set $passwords $user $u.password }}
{{- else if not (index $passwords $user) }}
{{- $_ := set $passwords $user (randAlphaNum 16) }}
{{- end }}
{{- end }}

{{- if .Values.users }}
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-credentials
stringData:
{{- range $user, $u := .Values.users }}
{{ quote $user }}: {{ quote (index $passwords $user) }}
{{- end }}
{{- end }}

---

apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
Expand All @@ -18,6 +40,18 @@ spec:
nats:
fullnameOverride: {{ .Release.Name }}
config:
{{- if .Values.users }}
{{- if gt (len .Values.users) 0 }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you meant to check $passwords? Because these two checks will have the same effect

merge:
kvaps marked this conversation as resolved.
Show resolved Hide resolved
accounts:
A:
users:
{{- range $username, $password := $passwords }}
- user: "{{ $username }}"
password: "{{ $password }}"
{{- end }}
{{- end }}
{{- end }}
kvaps marked this conversation as resolved.
Show resolved Hide resolved
cluster:
enabled: true
replicas: {{ .Values.replicas }}
Expand Down
12 changes: 12 additions & 0 deletions packages/apps/nats/templates/resourcemap.yaml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the service shown to the user into this file please

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ .Release.Name }}-dashboard-resources
rules:
- apiGroups:
- ""
resources:
- secrets
resourceNames:
- {{ .Release.Name }}-credentials
verbs: ["get", "list", "watch"]
kvaps marked this conversation as resolved.
Show resolved Hide resolved
44 changes: 29 additions & 15 deletions packages/apps/nats/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,34 @@
"title": "Chart Values",
"type": "object",
"properties": {
"external": {
"type": "boolean",
"description": "Enable external access from outside the cluster",
"default": false
"external": {
"type": "boolean",
"description": "Enable external access from outside the cluster",
"default": false
},
"replicas": {
"type": "number",
"description": "Persistent Volume size for NATS",
"default": 2
},
"storageClass": {
"type": "string",
"description": "StorageClass used to store the data",
"default": ""
},
"users": {
"type": "object",
"description": "Users configuration",
"additionalProperties": {
"type": "object",
"properties": {
"password": {
"type": "string",
"description": "Password for the user"
}
}
},
"replicas": {
"type": "number",
"description": "Persistent Volume size for NATS",
"default": 2
},
"storageClass": {
"type": "string",
"description": "StorageClass used to store the data",
"default": ""
}
"default": {}
}
}
}
}
7 changes: 7 additions & 0 deletions packages/apps/nats/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@
external: false
replicas: 2
storageClass: ""
## @param users [object] Users configuration
## Example:
## users:
## user1:
## password: strongpassword
## user2: {}
users: {}
3 changes: 2 additions & 1 deletion packages/apps/versions_map
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ mysql 0.5.0 4b84798
mysql 0.5.1 fab5940b
mysql 0.5.2 HEAD
nats 0.1.0 5ca8823
nats 0.2.0 HEAD
nats 0.2.0 c07c4bbd
nats 0.3.0 HEAD
postgres 0.1.0 f642698
postgres 0.2.0 7cd7de73
postgres 0.2.1 4a97e297
Expand Down
4 changes: 4 additions & 0 deletions packages/system/nats/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ nats:
persistentVolumeClaimRetentionPolicy:
whenDeleted: Delete
whenScaled: Delete
config:
cluster:
routeURLs:
k8sClusterDomain: cozy.local
Loading