From 517a9ccf622961b8fbf5549b68063f32d6f125ec Mon Sep 17 00:00:00 2001 From: Alexander Olofsson Date: Fri, 17 Sep 2021 15:59:25 +0200 Subject: [PATCH] netbox: Add support for Netbox 3.0 housekeeping --- .../templates/deployment-housekeeping.yaml | 72 +++++++++++++++++++ charts/netbox/values.yaml | 19 +++++ 2 files changed, 91 insertions(+) create mode 100644 charts/netbox/templates/deployment-housekeeping.yaml diff --git a/charts/netbox/templates/deployment-housekeeping.yaml b/charts/netbox/templates/deployment-housekeeping.yaml new file mode 100644 index 0000000..9a8d06f --- /dev/null +++ b/charts/netbox/templates/deployment-housekeeping.yaml @@ -0,0 +1,72 @@ +{{- if or .Values.housekeeping.enabled (semverCompare ">3.0.0" (include "netbox.imageTag" .)) -}} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "netbox.fullname" . }}-housekeeping + labels: + app.kubernetes.io/name: {{ include "netbox.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + helm.sh/chart: {{ include "netbox.chart" . }} +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/name: {{ include "netbox.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + component: housekeeping + template: + metadata: + annotations: + checksum/config: {{ include (print $.Template.BasePath "/configuration.yaml") . | sha256sum }} + checksum/secrets: {{ include (print $.Template.BasePath "/secrets.yaml") . | sha256sum }} + labels: + app.kubernetes.io/name: {{ include "netbox.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + component: housekeeping + spec: + containers: + - name: {{ .Chart.Name }}-housekeeping + command: + - /opt/netbox/housekeeping.sh + image: "{{ .Values.image.repository }}:{{ include "netbox.imageTag" . }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: REDIS_PASSWORD + valueFrom: + secretKeyRef: + name: {{ include "netbox.redis.fullname" . }} + key: redis-password + {{- if .Values.postgresql.enabled }} + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + {{- if .Values.postgresql.existingSecret }} + name: {{ .Values.postgresql.existingSecret }} + key: {{ .Values.postgresql.existingSecretKey }} + {{- else }} + name: {{ include "netbox.postgresql.fullname" . }} + key: postgresql-password + {{- end }} + {{- end }} + envFrom: + - configMapRef: + name: {{ include "netbox.fullname" . }} + - secretRef: + name: {{ include "netbox.fullname" . }} + resources: + {{- toYaml .Values.housekeeping.resources | nindent 12 }} + {{- with .Values.housekeeping.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.housekeeping.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.housekeeping.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} +{{- end -}} diff --git a/charts/netbox/values.yaml b/charts/netbox/values.yaml index a05de71..50ea44f 100644 --- a/charts/netbox/values.yaml +++ b/charts/netbox/values.yaml @@ -138,3 +138,22 @@ worker: affinity: {} +housekeeping: + ## Netbox 3.0.0 and upwards need housekeeping to be ran, if you're not using + ## a versioned tag then you may need to set this parameter + # enabled: true + + resources: {} + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + + nodeSelector: {} + + tolerations: [] + + affinity: {} +