From afbb940694496b90faa2b7f30b93850def9c6b51 Mon Sep 17 00:00:00 2001 From: Thumbscrew Date: Tue, 14 Mar 2023 21:26:55 +0000 Subject: [PATCH] add persistence and service annotations --- .../templates/deployment.yaml | 11 +++++++ charts/unifi-controller/templates/pvc.yaml | 32 +++++++++++++++++++ .../unifi-controller/templates/service.yaml | 4 +++ charts/unifi-controller/values.yaml | 9 ++++++ 4 files changed, 56 insertions(+) create mode 100644 charts/unifi-controller/templates/pvc.yaml diff --git a/charts/unifi-controller/templates/deployment.yaml b/charts/unifi-controller/templates/deployment.yaml index 2a8fef6..8aa1e77 100644 --- a/charts/unifi-controller/templates/deployment.yaml +++ b/charts/unifi-controller/templates/deployment.yaml @@ -66,6 +66,17 @@ spec: value: {{ .Values.config.jvmMemory.limit }} resources: {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - name: unifi-config + mountPath: /config + volumes: + - name: unifi-config + {{- if .Values.persistence.enabled }} + persistentVolumeClaim: + claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "unifi-controller.fullname" . }}-pvc{{- end }} + {{- else }} + emptyDir: {} + {{- end }} {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} diff --git a/charts/unifi-controller/templates/pvc.yaml b/charts/unifi-controller/templates/pvc.yaml new file mode 100644 index 0000000..2559551 --- /dev/null +++ b/charts/unifi-controller/templates/pvc.yaml @@ -0,0 +1,32 @@ +{{- if .Values.persistence.enabled -}} +{{- if not .Values.persistence.existingClaim -}} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ template "unifi-controller.fullname" . }}-pvc + labels: + {{- include "unifi-controller.labels" . | nindent 4 }} + # app.kubernetes.io/name: {{ include "unifi-controller.name" . }} + # helm.sh/chart: {{ include "unifi-controller.chart" . }} + # app.kubernetes.io/instance: {{ .Release.Name }} + # app.kubernetes.io/managed-by: {{ .Release.Service }} + # app.kubernetes.io/component: app +{{- if .Values.persistence.annotations }} + annotations: +{{ toYaml .Values.persistence.annotations | indent 4 }} +{{- end }} +spec: + accessModes: + - {{ .Values.persistence.accessMode | quote }} + resources: + requests: + storage: {{ .Values.persistence.size | quote }} +{{- if .Values.persistence.storageClass }} +{{- if (eq "-" .Values.persistence.storageClass) }} + storageClassName: "" +{{- else }} + storageClassName: "{{ .Values.persistence.storageClass }}" +{{- end }} +{{- end }} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/charts/unifi-controller/templates/service.yaml b/charts/unifi-controller/templates/service.yaml index b04887b..a70ce26 100644 --- a/charts/unifi-controller/templates/service.yaml +++ b/charts/unifi-controller/templates/service.yaml @@ -2,6 +2,10 @@ apiVersion: v1 kind: Service metadata: name: {{ include "unifi-controller.fullname" . }} + {{- with .Values.service.annotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} labels: {{- include "unifi-controller.labels" . | nindent 4 }} spec: diff --git a/charts/unifi-controller/values.yaml b/charts/unifi-controller/values.yaml index e8c69c5..32e84fa 100644 --- a/charts/unifi-controller/values.yaml +++ b/charts/unifi-controller/values.yaml @@ -18,6 +18,14 @@ config: startup: default limit: default +persistence: + enabled: false + existingClaim: "" + annotations: {} + accessMode: ReadWriteOnce + storageClass: "" + size: 1Gi + serviceAccount: # Specifies whether a service account should be created create: true @@ -42,6 +50,7 @@ securityContext: {} service: type: ClusterIP + annotations: {} ingress: enabled: false