From 9798bb82cc1852f9f52163573612ebbff3bdc344 Mon Sep 17 00:00:00 2001 From: Marco Kilchhofer Date: Wed, 15 Jan 2020 13:51:31 +0100 Subject: [PATCH] Add ability to specify additional jvm options and config files (#20163) I use this to override the log4j config to see the logs also on stdout. Signed-off-by: Marco Kilchhofer --- charts/unifi/Chart.yaml | 2 +- charts/unifi/README.md | 2 ++ charts/unifi/templates/configmap.yaml | 13 +++++++++ charts/unifi/templates/deployment.yaml | 13 +++++++++ charts/unifi/values.yaml | 37 ++++++++++++++++++++++++++ 5 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 charts/unifi/templates/configmap.yaml diff --git a/charts/unifi/Chart.yaml b/charts/unifi/Chart.yaml index ed15f431..6f732c06 100644 --- a/charts/unifi/Chart.yaml +++ b/charts/unifi/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 appVersion: 5.11.50 description: Ubiquiti Network's Unifi Controller name: unifi -version: 0.5.2 +version: 0.6.0 keywords: - ubiquiti - unifi diff --git a/charts/unifi/README.md b/charts/unifi/README.md index 260dd6ef..e58015c6 100644 --- a/charts/unifi/README.md +++ b/charts/unifi/README.md @@ -94,6 +94,8 @@ The following tables lists the configurable parameters of the Unifi chart and th | `persistence.existingClaim` | Use an existing PVC to persist data | `nil` | | `persistence.storageClass` | Type of persistent volume claim | `-` | | `persistence.accessModes` | Persistence access modes | `[]` | +| `extraConfigFiles` | Dictionary containing files mounted to `/configmap` inside the pod (See [values.yaml](values.yaml) for examples) | `{}` | +| `extraJvmOpts` | List of additional JVM options, e.g. `["-Dlog4j.configurationFile=file:/configmap/log4j2.xml"]` | `[]` | | `resources` | CPU/Memory resource requests/limits | `{}` | | `nodeSelector` | Node labels for pod assignment | `{}` | | `tolerations` | Toleration labels for pod assignment | `[]` | diff --git a/charts/unifi/templates/configmap.yaml b/charts/unifi/templates/configmap.yaml new file mode 100644 index 00000000..463abb10 --- /dev/null +++ b/charts/unifi/templates/configmap.yaml @@ -0,0 +1,13 @@ +{{- if .Values.extraConfigFiles }} +kind: ConfigMap +apiVersion: v1 +metadata: + name: {{ template "unifi.fullname" . }} + labels: + app.kubernetes.io/name: {{ include "unifi.name" . }} + helm.sh/chart: {{ include "unifi.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +data: +{{ toYaml .Values.extraConfigFiles | indent 2 }} +{{- end }} diff --git a/charts/unifi/templates/deployment.yaml b/charts/unifi/templates/deployment.yaml index 96f1b0d6..890fe5d4 100644 --- a/charts/unifi/templates/deployment.yaml +++ b/charts/unifi/templates/deployment.yaml @@ -75,6 +75,10 @@ spec: value: "{{ .Values.UID }}" - name: UNIFI_GID value: "{{ .Values.GID }}" + {{- if .Values.extraJvmOpts }} + - name: JVM_EXTRA_OPTS + value: "{{- join " " .Values.extraJvmOpts }}" + {{- end }} {{- if .Values.mongodb.enabled }} - name: DB_URI value: "{{ .Values.mongodb.dbUri }}" @@ -96,6 +100,10 @@ spec: - mountPath: /unifi/init.d name: unifi-data subPath: init.d + {{- if .Values.extraConfigFiles }} + - name: extra-config + mountPath: /configmap + {{- end }} resources: {{ toYaml .Values.resources | indent 12 }} volumes: @@ -106,6 +114,11 @@ spec: {{- else }} emptyDir: {} {{ end }} + {{- if .Values.extraConfigFiles }} + - name: extra-config + configMap: + name: {{ template "unifi.fullname" . }} + {{- end }} {{- with .Values.nodeSelector }} nodeSelector: {{ toYaml . | indent 8 }} diff --git a/charts/unifi/values.yaml b/charts/unifi/values.yaml index eab78e15..88f64985 100644 --- a/charts/unifi/values.yaml +++ b/charts/unifi/values.yaml @@ -166,6 +166,43 @@ persistence: accessMode: ReadWriteOnce size: 5Gi +extraJvmOpts: [] + ## Extra java options + ## Here are some examples of valid JVM options: + ## + # - "-XX:MaxMetaspaceSize=256m" + # - "-Dlog4j.configurationFile=file:/configmap/log4j2.xml" + # - "-Dsystem_ip=1.2.3.4" + +extraConfigFiles: {} + ## Specify additional config files which are mounted to /configmap + ## Here is an example for a custom log4j config: + ## + # log4j2.xml: |- + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + # + resources: {} # We usually recommend not to specify default resources and to leave this as a conscious # choice for the user. This also increases chances charts run on environments with little