feat: replace deprecated Unifi controller with Unifi Network Application (#77)

This commit is contained in:
James 2024-07-13 16:18:51 +01:00 committed by GitHub
parent c3ae45852d
commit ca8620cafe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 150 additions and 4 deletions

View File

@ -1 +1,2 @@
values.test.yaml values.test.yaml
charts/*.tgz

View File

@ -0,0 +1,6 @@
dependencies:
- name: mongodb
repository: https://charts.bitnami.com/bitnami
version: 15.3.0
digest: sha256:f6cc8e47d7f68e327889b4807f488a346c70c7da8c80ea623aa7a1a8c6d95877
generated: "2024-05-10T21:31:20.762106802+01:00"

View File

@ -15,10 +15,16 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes # 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. # to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/) # Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 2.0.0 version: 3.0.0
# This is the version number of the application being deployed. This version number should be # 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 # incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using. # follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes. # It is recommended to use it with quotes.
appVersion: "8.0.7" appVersion: "8.1.127"
dependencies:
- name: mongodb
version: ^15.3.0
repository: https://charts.bitnami.com/bitnami
condition: mongodb.enabled

View File

@ -60,3 +60,81 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }} {{- default "default" .Values.serviceAccount.name }}
{{- end }} {{- end }}
{{- 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 -}}

View 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 }}

View File

@ -67,6 +67,26 @@ spec:
value: {{ .Values.config.jvmMemory.startup }} value: {{ .Values.config.jvmMemory.startup }}
- name: MEM_LIMIT - name: MEM_LIMIT
value: {{ .Values.config.jvmMemory.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: resources:
{{- toYaml .Values.resources | nindent 12 }} {{- toYaml .Values.resources | nindent 12 }}
volumeMounts: volumeMounts:

View File

@ -3,7 +3,7 @@
# Declare variables to be passed into your templates. # Declare variables to be passed into your templates.
image: image:
repository: quay.io/linuxserver.io/unifi-controller repository: lscr.io/linuxserver/unifi-network-application
pullPolicy: IfNotPresent pullPolicy: IfNotPresent
# -- Overrides the image tag whose default is the chart appVersion. # -- Overrides the image tag whose default is the chart appVersion.
tag: "" tag: ""
@ -56,6 +56,31 @@ service:
combinedProtocols: true combinedProtocols: true
annotations: {} annotations: {}
mongodb:
# -- Deploy Bitnami MongoDB sub-chart
enabled: true
auth:
rootUser: root
rootPassword: unifi
databases:
- unifi
usernames:
- unifi
passwords:
- unifi
initdbScriptsConfigMap: initdb-scripts
externalMongodb:
# -- Use an external MongoDB database
enabled: false
# host: mongodb
port: 5432
database: mongo
username: mongo
# password: mongo
# existingSecret: mongo
# existingSecretPasswordKey: password
ingress: ingress:
enabled: false enabled: false
className: "" className: ""