mirror of
https://github.com/Thumbscrew/k8s-charts.git
synced 2025-07-08 21:52:44 +00:00
feat: replace deprecated Unifi controller with Unifi Network Application (#77)
This commit is contained in:
@ -60,3 +60,81 @@ Create the name of the service account to use
|
||||
{{- default "default" .Values.serviceAccount.name }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create a default fully qualified app name.
|
||||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||
*/}}
|
||||
{{- define "unifi-controller.mongodb.fullname" -}}
|
||||
{{- printf "%s-%s" .Release.Name "mongodb" | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Set mongodb host
|
||||
*/}}
|
||||
{{- define "unifi-controller.mongodb.host" -}}
|
||||
{{- if .Values.mongodb.enabled -}}
|
||||
{{- template "unifi-controller.mongodb.fullname" . -}}
|
||||
{{- else -}}
|
||||
{{ required "A valid externalMongodb.host is required" .Values.externalMongodb.host }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Set mongodb secret
|
||||
*/}}
|
||||
{{- define "unifi-controller.mongodb.secret" -}}
|
||||
{{- if .Values.mongodb.enabled -}}
|
||||
{{- template "unifi-controller.mongodb.fullname" . -}}
|
||||
{{- else -}}
|
||||
{{- template "unifi-controller.fullname" . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Set mongodb port
|
||||
*/}}
|
||||
{{- define "unifi-controller.mongodb.port" -}}
|
||||
{{- if .Values.mongodb.enabled -}}
|
||||
{{- if .Values.mongodb.service -}}
|
||||
{{- .Values.mongodb.service.port | default 27017 }}
|
||||
{{- else -}}
|
||||
5432
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- required "A valid externalMongodb.port is required" .Values.externalMongodb.port -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Set mongodb username
|
||||
*/}}
|
||||
{{- define "unifi-controller.mongodb.username" -}}
|
||||
{{- if .Values.mongodb.enabled -}}
|
||||
{{ required "A valid mongodb.auth.usernames is required" (first .Values.mongodb.auth.usernames) }}
|
||||
{{- else -}}
|
||||
{{ required "A valid externalMongodb.username is required" .Values.externalMongodb.username }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Set mongodb password
|
||||
*/}}
|
||||
{{- define "unifi-controller.mongodb.password" -}}
|
||||
{{- if .Values.mongodb.enabled -}}
|
||||
{{ required "A valid mongodb.auth.passwords is required" (first .Values.mongodb.auth.passwords) }}
|
||||
{{- else if not (and .Values.externalMongodb.existingSecret .Values.externalMongodb.existingSecretPasswordKey) -}}
|
||||
{{ required "A valid externalMongodb.password is required" .Values.externalMongodb.password }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Set mongodb database
|
||||
*/}}
|
||||
{{- define "unifi-controller.mongodb.database" -}}
|
||||
{{- if .Values.mongodb.enabled -}}
|
||||
{{- (first .Values.mongodb.auth.databases) | default "unifi" }}
|
||||
{{- else -}}
|
||||
{{ required "A valid externalMongodb.database is required" .Values.externalMongodb.database }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
10
charts/unifi-controller/templates/configmap.yaml
Normal file
10
charts/unifi-controller/templates/configmap.yaml
Normal file
@ -0,0 +1,10 @@
|
||||
{{- if .Values.mongodb.enabled -}}
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: initdb-scripts
|
||||
data:
|
||||
init-mongo.js: |
|
||||
db = db.getSiblingDB("{{ include "unifi-controller.mongodb.database" . }}");
|
||||
db.grantRolesToUser("{{ include "unifi-controller.mongodb.username" . }}", [{role: "dbOwner", db: "{{ include "unifi-controller.mongodb.database" . }}_stat"}])
|
||||
{{- end }}
|
@ -67,6 +67,26 @@ spec:
|
||||
value: {{ .Values.config.jvmMemory.startup }}
|
||||
- name: MEM_LIMIT
|
||||
value: {{ .Values.config.jvmMemory.limit }}
|
||||
- name: MONGO_HOST
|
||||
value: {{ include "unifi-controller.mongodb.host" . }}
|
||||
- name: MONGO_PORT
|
||||
value: {{ include "unifi-controller.mongodb.port" . | quote }}
|
||||
- name: MONGO_USER
|
||||
value: {{ include "unifi-controller.mongodb.username" . }}
|
||||
{{- if or .Values.mongodb.enabled .Values.externalMongodb.existingSecret }}
|
||||
- name: MONGO_PASS
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
{{- if .Values.mongodb.enabled }}
|
||||
name: {{ .Values.mongodb.existingSecret | default (include "unifi-controller.mongodb.fullname" .) }}
|
||||
key: mongodb-passwords
|
||||
{{- else }}
|
||||
name: {{ .Values.externalMongodb.existingSecret }}
|
||||
key: {{ .Values.externalMongodb.existingSecretPasswordKey }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
- name: MONGO_DBNAME
|
||||
value: {{ include "unifi-controller.mongodb.database" . }}
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 12 }}
|
||||
volumeMounts:
|
||||
|
Reference in New Issue
Block a user