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 <marco@kilchhofer.info>
This commit is contained in:
Marco Kilchhofer 2020-01-15 13:51:31 +01:00 committed by Jeff Billimek
parent 0322acc6fe
commit 9798bb82cc
No known key found for this signature in database
GPG Key ID: 214B3EF39B4956B7
5 changed files with 66 additions and 1 deletions

View File

@ -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

View File

@ -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 | `[]` |

View File

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

View File

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

View File

@ -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: |-
# <?xml version="1.0" encoding="UTF-8"?>
# <Configuration>
# <Appenders>
# <InMemoryAppender name="InMemoryAppender" activatedLogging="false">
# <PatternLayout pattern="[%d{ISO8601}] &lt;%t&gt; %-5p %-6c{1} - %m%n" />
# </InMemoryAppender>
# <RollingFile name="server_log" fileName="logs/server.log" filePattern="logs/server.log.%i">
# <PatternLayout pattern="[%d{ISO8601}] &lt;%t&gt; %-5p %-6c{1} - %m%n" />
# <SizeBasedTriggeringPolicy size="10 MB"/>
# <DefaultRolloverStrategy max="3" fileIndex="min" />
# </RollingFile>
# <Console name="STDOUT" target="SYSTEM_OUT">
# <PatternLayout pattern="&lt;%t&gt; %-5p %-6c{1} - %m%n"/>
# </Console>
# </Appenders>
# <Loggers>
# <Root level="INFO">
# <AppenderRef ref="InMemoryAppender" />
# <AppenderRef ref="server_log" />
# <AppenderRef ref="STDOUT" />
# </Root>
# </Loggers>
# </Configuration>
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