From 28f2ac6361a3e42f84f49b115305d40406a5669f Mon Sep 17 00:00:00 2001 From: "aysenur.akpinar" Date: Tue, 21 Oct 2025 14:03:32 +0200 Subject: [PATCH] add Netbox backup Helm chart --- .../netboxbackup /chart-template.yaml.j2 | 7 ++ .../netboxbackup /templates/configmap.yaml | 10 ++ .../netboxbackup /templates/deployment.yaml | 102 ++++++++++++++++++ .../netboxbackup /templates/service.yaml | 17 +++ .../templates/servicemonitor.yaml | 23 ++++ .../netboxbackup /values-template.yaml.j2 | 34 ++++++ 6 files changed, 193 insertions(+) create mode 100644 yaook/helm_builder/Charts/netboxbackup /chart-template.yaml.j2 create mode 100644 yaook/helm_builder/Charts/netboxbackup /templates/configmap.yaml create mode 100644 yaook/helm_builder/Charts/netboxbackup /templates/deployment.yaml create mode 100644 yaook/helm_builder/Charts/netboxbackup /templates/service.yaml create mode 100644 yaook/helm_builder/Charts/netboxbackup /templates/servicemonitor.yaml create mode 100644 yaook/helm_builder/Charts/netboxbackup /values-template.yaml.j2 diff --git a/yaook/helm_builder/Charts/netboxbackup /chart-template.yaml.j2 b/yaook/helm_builder/Charts/netboxbackup /chart-template.yaml.j2 new file mode 100644 index 000000000..7a704888a --- /dev/null +++ b/yaook/helm_builder/Charts/netboxbackup /chart-template.yaml.j2 @@ -0,0 +1,7 @@ +apiVersion: v2 +description: Creates Netbox database backup from kubernetes master and stores it remotely via s3 +type: application +name: netboxbackup +version: {{ version }} +appVersion: {{ version }} +kubeVersion: ">=1.16.0-0" diff --git a/yaook/helm_builder/Charts/netboxbackup /templates/configmap.yaml b/yaook/helm_builder/Charts/netboxbackup /templates/configmap.yaml new file mode 100644 index 000000000..8d7a173c8 --- /dev/null +++ b/yaook/helm_builder/Charts/netboxbackup /templates/configmap.yaml @@ -0,0 +1,10 @@ +{{ if .Values.certRef }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: shifter-certificates + namespace: {{.Values.namespace}} +data: + ca-bundle.crt: +{{ toYaml .Values.certRef | indent 6 }} +{{ end }} diff --git a/yaook/helm_builder/Charts/netboxbackup /templates/deployment.yaml b/yaook/helm_builder/Charts/netboxbackup /templates/deployment.yaml new file mode 100644 index 000000000..bdd7abad8 --- /dev/null +++ b/yaook/helm_builder/Charts/netboxbackup /templates/deployment.yaml @@ -0,0 +1,102 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: netbox-backup + namespace: {{ .Values.namespace }} +spec: + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + yaook.cloud/component: netbox-backup + template: + metadata: + labels: + yaook.cloud/component: netbox-backup + spec: +{{- if .Values.priorityClassName }} + priorityClassName: {{ .Values.priorityClassName | toString }} +{{- end }} + automountServiceAccountToken: false + enableServiceLinks: false + tolerations: + - key: "" + operator: "Exists" + nodeSelector: + node-role.kubernetes.io/control-plane: "" + containers: + - name: backup-creator + image: {{ .Values.backup_creator.imageRef }} + imagePullPolicy: IfNotPresent + volumeMounts: + - name: backup-scratch + mountPath: /backup + env: + - name: BACKUP_CREATOR_BACKUP_CLASS_NAME + value: netbox + - name: YAOOK_BACKUP_CREATOR_NETBOX_DB_HOST + value: "netbox-postgresql" + - name: YAOOK_BACKUP_CREATOR_NETBOX_DB_NAME + value: "netbox" + - name: YAOOK_BACKUP_CREATOR_NETBOX_NAMESPACE + value: {{ .Values.namespace }} + - name: YAOOK_BACKUP_CREATOR_BACKUP_MODULE_NAME + value: backup_creator.services.netbox + - name: YAOOK_BACKUP_CREATOR_OUT_PATH + value: /backup/new + - name: YAOOK_BACKUP_CREATOR_SCHEDULE + value: {{ .Values.schedule | quote }} + + - name: backup-shifter + image: {{ .Values.backup_shifter.imageRef }} + imagePullPolicy: IfNotPresent + env: + - name: AWS_REQUEST_CHECKSUM_CALCULATION + value: {{ .Values.targets.s3.checksumValidation }} + - name: AWS_RESPONSE_CHECKSUM_VALIDATION + value: {{ .Values.targets.s3.checksumValidation }} + - name: YAOOK_BACKUP_SHIFTER_WORK_DIR + value: /backup + - name: YAOOK_BACKUP_SHIFTER_S3_FILE_PREFIX + value: {{ .Values.targets.s3.filePrefix | default "netboxbackup" }} + - name: YAOOK_BACKUP_SHIFTER_SHIFTERS + value: dumpinfo{{- if .Values.encryption.enabled }},encrypt{{- end }},s3_upload + - name: YAOOK_BACKUP_SHIFTER_S3_URL + value: {{ .Values.targets.s3.endpoint }} + - name: YAOOK_BACKUP_SHIFTER_S3_BUCKET + value: {{ .Values.targets.s3.bucket }} + - name: YAOOK_BACKUP_SHIFTER_S3_ADDRESSING_STYLE + value: {{ .Values.targets.s3.addressingStyle }} + - name: YAOOK_BACKUP_SHIFTER_METRICS_PORT + value: '{{ .Values.metrics_port }}' + - name: YAOOK_BACKUP_SHIFTER_S3_ACCESS_KEY_FILE + value: /etc/s3/access + - name: YAOOK_BACKUP_SHIFTER_S3_SECRET_KEY_FILE + value: /etc/s3/secret +{{- if .Values.encryption.enabled }} + - name: YAOOK_BACKUP_SHIFTER_ENCRYPTION_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.encryption.passwordEncryptionRef.name }} + key: password +{{- end }} + ports: + - containerPort: {{ .Values.metrics_port }} + name: backup-metrics + protocol: TCP + volumeMounts: + - name: backup-scratch + mountPath: /backup + - name: s3-credentials + mountPath: /etc/s3 + readOnly: true + + volumes: + - name: backup-scratch + emptyDir: {} + - name: s3-credentials + secret: + secretName: {{ .Values.targets.s3.credentialRef.name }} + dnsPolicy: ClusterFirst diff --git a/yaook/helm_builder/Charts/netboxbackup /templates/service.yaml b/yaook/helm_builder/Charts/netboxbackup /templates/service.yaml new file mode 100644 index 000000000..3312b6c8c --- /dev/null +++ b/yaook/helm_builder/Charts/netboxbackup /templates/service.yaml @@ -0,0 +1,17 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: netbox-backup + labels: + yaook.cloud/component: netbox-backup + namespace: {{.Values.namespace}} +spec: + type: ClusterIP + selector: + yaook.cloud/component: netbox-backup + ports: + - name: backup-metrics + port: {{.Values.metrics_port}} + protocol: TCP + targetPort: {{.Values.metrics_port}} diff --git a/yaook/helm_builder/Charts/netboxbackup /templates/servicemonitor.yaml b/yaook/helm_builder/Charts/netboxbackup /templates/servicemonitor.yaml new file mode 100644 index 000000000..8c90474c4 --- /dev/null +++ b/yaook/helm_builder/Charts/netboxbackup /templates/servicemonitor.yaml @@ -0,0 +1,23 @@ +--- +{{- if .Values.serviceMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: netbox-backup + labels: + yaook.cloud/component: netbox-backup + {{- if .Values.serviceMonitor.additionalLabels }} +{{ toYaml .Values.serviceMonitor.additionalLabels | indent 4 }} + {{- end }} + namespace: {{.Values.namespace}} +spec: + endpoints: + - interval: 15s + port: backup-metrics + namespaceSelector: + matchNames: + - {{.Values.namespace}} + selector: + matchLabels: + yaook.cloud/component: netbox-backup +{{- end }} diff --git a/yaook/helm_builder/Charts/netboxbackup /values-template.yaml.j2 b/yaook/helm_builder/Charts/netboxbackup /values-template.yaml.j2 new file mode 100644 index 000000000..33fb9598e --- /dev/null +++ b/yaook/helm_builder/Charts/netboxbackup /values-template.yaml.j2 @@ -0,0 +1,34 @@ +# Default values + +backup_shifter: + imageRef: {{ images["registry.yaook.cloud/yaook/backup-shifter"] }} + +backup_creator: + imageRef: {{ images["registry.yaook.cloud/yaook/backup-creator"] }} + +schedule: 21 */12 * * * + +namespace: default + +metrics_port: 9100 + +serviceMonitor: + enabled: true + additionalLabels: {} + +priorityClassName: "" + +targets: + s3: + checksumValidation: "when_required" + endpoint: https://cool.s3.endpoint + bucket: mybucket + addressingStyle: path + filePrefix: "netboxbackup" + credentialRef: + name: backup-s3-password + +encryption: + enabled: false + passwordEncryptionRef: + name: encryption-password -- GitLab