From fe6403318ec06aa2c6cc00b8d24bec6e52b075fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=E1=B4=87=CA=80=C9=B4=E1=B4=85=20S=E1=B4=84=CA=9C?= =?UTF-8?q?=E1=B4=8F=CA=80=C9=A2=E1=B4=87=CA=80s?= Date: Fri, 6 Aug 2021 11:34:00 +0200 Subject: [PATCH] [unifi] Reimplement external MongoDB (#1113) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Reimplement external MongoDB * fix PVC mountPath for backwards compatibility Signed-off-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs --- charts/stable/unifi/Chart.yaml | 6 +++- charts/stable/unifi/README.md | 29 ++++++++++++++++++- .../stable/unifi/README_CHANGELOG.md.gotmpl | 10 +++++++ charts/stable/unifi/README_CONFIG.md.gotmpl | 15 ++++++++++ charts/stable/unifi/ci/ct-values.yaml | 0 charts/stable/unifi/ci/mongo-values.yaml | 2 ++ charts/stable/unifi/templates/common.yaml | 11 +++++++ charts/stable/unifi/values.yaml | 19 +++++++++++- 8 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 charts/stable/unifi/ci/ct-values.yaml create mode 100644 charts/stable/unifi/ci/mongo-values.yaml diff --git a/charts/stable/unifi/Chart.yaml b/charts/stable/unifi/Chart.yaml index 5b2f5c4b..52eee6f2 100644 --- a/charts/stable/unifi/Chart.yaml +++ b/charts/stable/unifi/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 appVersion: v6.2.26 description: Ubiquiti Network's Unifi Controller name: unifi -version: 3.0.0 +version: 3.1.0 keywords: - ubiquiti - unifi @@ -19,3 +19,7 @@ dependencies: - name: common repository: https://library-charts.k8s-at-home.com version: 3.3.0 +- name: mongodb + version: 10.23.9 + repository: https://charts.bitnami.com/bitnami + condition: mongodb.enabled diff --git a/charts/stable/unifi/README.md b/charts/stable/unifi/README.md index a00d8b6c..4cc975d4 100644 --- a/charts/stable/unifi/README.md +++ b/charts/stable/unifi/README.md @@ -1,6 +1,6 @@ # unifi -![Version: 3.0.0](https://img.shields.io/badge/Version-3.0.0-informational?style=flat-square) ![AppVersion: v6.2.26](https://img.shields.io/badge/AppVersion-v6.2.26-informational?style=flat-square) +![Version: 3.1.0](https://img.shields.io/badge/Version-3.1.0-informational?style=flat-square) ![AppVersion: v6.2.26](https://img.shields.io/badge/AppVersion-v6.2.26-informational?style=flat-square) Ubiquiti Network's Unifi Controller @@ -16,6 +16,7 @@ Ubiquiti Network's Unifi Controller | Repository | Name | Version | |------------|------|---------| +| https://charts.bitnami.com/bitnami | mongodb | 10.23.9 | | https://library-charts.k8s-at-home.com | common | 3.3.0 | ## TL;DR @@ -65,6 +66,21 @@ helm install unifi k8s-at-home/unifi -f values.yaml ## Custom configuration +### Running with separate MongoDB + +By default the Unifi controller runs an internal MongoDB. +If you wish to run the chart with a separate MongoDB instance our chart provides the option to enable a MongoDB instance by adding the following in your `values.yaml`: + +```yaml +mongodb: + enabled: true +``` + +(For more configuration options see the [mongodb chart documentation](https://github.com/bitnami/charts/tree/master/bitnami/mongodb).) + +If you do not specify any other configuration, the required environment variables will be inferred automatically. +It is also possible to override the environment variables to configure the image. See [here](https://github.com/jacobalberty/unifi-docker#external-mongodb-environment-variables) for more details. + ### Regarding the services By default it is not possible to combine TCP and UDP ports on a service with `type: LoadBalancer`. This can be solved in a number of ways: @@ -115,6 +131,7 @@ service: | image.tag | string | `"v6.2.26"` | image tag | | ingress.main | object | See values.yaml | Enable and configure ingress settings for the chart under this key. | | ingress.portal | object | See values.yaml | Enable and configure settings for the captive portal ingress under this key. | +| mongodb | object | See values.yaml | Enable and configure mongodb database subchart under this key. For more options see [mongodb chart documentation](https://github.com/bitnami/charts/tree/master/bitnami/mongodb) | | persistence | object | See values.yaml | Configure persistence settings for the chart under this key. | | service | object | See values.yaml | Configures service settings for the chart. | | service.main.ports.controller | object | See values.yaml | Configure Controller port used for device command/control | @@ -132,6 +149,16 @@ All notable changes to this application Helm chart will be documented in this fi The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +### [3.1.0] + +#### Added + +- Support for running with an external MongoDB instance has been reimplemented. + +#### Fixed + +- The chart is now compatible again with PVC's that were created with chart versions < 3.0.0. + ### [3.0.0] #### Changed diff --git a/charts/stable/unifi/README_CHANGELOG.md.gotmpl b/charts/stable/unifi/README_CHANGELOG.md.gotmpl index f0dea5da..6bb59f88 100644 --- a/charts/stable/unifi/README_CHANGELOG.md.gotmpl +++ b/charts/stable/unifi/README_CHANGELOG.md.gotmpl @@ -9,6 +9,16 @@ All notable changes to this application Helm chart will be documented in this fi The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +### [3.1.0] + +#### Added + +- Support for running with an external MongoDB instance has been reimplemented. + +#### Fixed + +- The chart is now compatible again with PVC's that were created with chart versions < 3.0.0. + ### [3.0.0] #### Changed diff --git a/charts/stable/unifi/README_CONFIG.md.gotmpl b/charts/stable/unifi/README_CONFIG.md.gotmpl index c2eae584..5b0aedee 100644 --- a/charts/stable/unifi/README_CONFIG.md.gotmpl +++ b/charts/stable/unifi/README_CONFIG.md.gotmpl @@ -5,6 +5,21 @@ {{- define "custom.custom.configuration" -}} {{ template "custom.custom.configuration.header" . }} +### Running with separate MongoDB + +By default the Unifi controller runs an internal MongoDB. +If you wish to run the chart with a separate MongoDB instance our chart provides the option to enable a MongoDB instance by adding the following in your `values.yaml`: + +```yaml +mongodb: + enabled: true +``` + +(For more configuration options see the [mongodb chart documentation](https://github.com/bitnami/charts/tree/master/bitnami/mongodb).) + +If you do not specify any other configuration, the required environment variables will be inferred automatically. +It is also possible to override the environment variables to configure the image. See [here](https://github.com/jacobalberty/unifi-docker#external-mongodb-environment-variables) for more details. + ### Regarding the services By default it is not possible to combine TCP and UDP ports on a service with `type: LoadBalancer`. This can be solved in a number of ways: diff --git a/charts/stable/unifi/ci/ct-values.yaml b/charts/stable/unifi/ci/ct-values.yaml new file mode 100644 index 00000000..e69de29b diff --git a/charts/stable/unifi/ci/mongo-values.yaml b/charts/stable/unifi/ci/mongo-values.yaml new file mode 100644 index 00000000..e05134b4 --- /dev/null +++ b/charts/stable/unifi/ci/mongo-values.yaml @@ -0,0 +1,2 @@ +mongodb: + enabled: true diff --git a/charts/stable/unifi/templates/common.yaml b/charts/stable/unifi/templates/common.yaml index e022719f..77229125 100644 --- a/charts/stable/unifi/templates/common.yaml +++ b/charts/stable/unifi/templates/common.yaml @@ -4,6 +4,17 @@ {{- define "unifi.harcodedValues" -}} env: UNIFI_STDOUT: "true" + {{- if .Values.mongodb.enabled }} + {{- if not .Values.env.DB_URI }} + DB_URI: mongodb://{{ .Release.Name }}-mongodb:27017/unifi + {{- end }} + {{- if not .Values.env.STATDB_URI }} + STATDB_URI: mongodb://{{ .Release.Name }}-mongodb:27017/unifi_stat + {{- end }} + {{- if not .Values.env.DB_NAME }} + DB_NAME: unifi + {{- end }} + {{- end }} {{- end -}} {{- $_ := mergeOverwrite .Values (include "unifi.harcodedValues" . | fromYaml) -}} diff --git a/charts/stable/unifi/values.yaml b/charts/stable/unifi/values.yaml index e0e978a6..568416f6 100644 --- a/charts/stable/unifi/values.yaml +++ b/charts/stable/unifi/values.yaml @@ -31,6 +31,10 @@ env: # For larger installations a larger value is recommended. # For memory constrained system this value can be lowered. JVM_MAX_HEAP_SIZE: 1024M + # # -- External MongoDB URI + # DB_URI: # mongodb://unifi-mongodb:27017/unifi + # STATDB_URI: # mongodb://unifi-mongodb:27017/unifi_stat + # DB_NAME: # unifi # -- Configures service settings for the chart. # @default -- See values.yaml @@ -123,4 +127,17 @@ ingress: persistence: data: enabled: false - mountPath: /unifi/data + mountPath: /unifi + +# -- Enable and configure mongodb database subchart under this key. +# For more options see [mongodb chart documentation](https://github.com/bitnami/charts/tree/master/bitnami/mongodb) +# @default -- See values.yaml +mongodb: + enabled: false + architecture: standalone + auth: + enabled: false + persistence: + enabled: false + # storageClass: "" + # size: 8Gi