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

feat(helm): add service auth config #475

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
39 changes: 39 additions & 0 deletions helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,45 @@ Create chart name and version as used by the chart label.
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Generate a random token if not set.
*/}}
{{- define "nacos.auth.token" -}}
{{- if .Values.nacos.auth.enable}}
{{- if not (empty .Values.nacos.auth.token) }}
{{- .Values.nacos.auth.token -}}
{{- else -}}
{{- randAlphaNum 64 -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Generate a random identity key if not set.
*/}}
{{- define "nacos.auth.identityKey" -}}
{{- if .Values.nacos.auth.enable}}
{{- if not (empty .Values.nacos.auth.identityKey) }}
{{- .Values.nacos.auth.identityKey -}}
{{- else -}}
{{- randAlphaNum 16 -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Generate a random identity value if not set.
*/}}
{{- define "nacos.auth.identityValue" -}}
{{- if .Values.nacos.auth.enable}}
{{- if not (empty .Values.nacos.auth.identityValue) }}
{{- .Values.nacos.auth.identityValue -}}
{{- else -}}
{{- randAlphaNum 16 -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Common labels
*/}}
Expand Down
10 changes: 10 additions & 0 deletions helm/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ spec:
apiVersion: v1
fieldPath: metadata.namespace
{{- end }}
{{- if .Values.nacos.auth.enable }}
- name: NACOS_AUTH_ENABLE
value: "true"
- name: NACOS_AUTH_TOKEN
value: {{ include "nacos.auth.token" . | quote }}
- name: NACOS_AUTH_IDENTITY_KEY
value: {{ include "nacos.auth.identityKey" . | quote }}
- name: NACOS_AUTH_IDENTITY_VALUE
value: {{ include "nacos.auth.identityValue" . | quote }}
{{- end }}
{{- if eq .Values.nacos.storage.type "mysql" }}
- name: SPRING_DATASOURCE_PLATFORM
value: "mysql"
Expand Down
8 changes: 8 additions & 0 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ nacos:
domainName: cluster.local
preferhostmode: hostname
serverPort: 8848
auth:
enable: false
## if not set, generate a random token
token: ""
## if not set, generate a random key
identityKey: ""
## if not set, generate a random value
identityValue: ""
health:
enabled: false
storage:
Expand Down