Skip to content

Commit

Permalink
add new helm chart for backup georchestra ldap
Browse files Browse the repository at this point in the history
  • Loading branch information
edevosc2c committed Dec 1, 2023
1 parent 1506f15 commit 7822e1d
Show file tree
Hide file tree
Showing 6 changed files with 269 additions and 0 deletions.
23 changes: 23 additions & 0 deletions georchestra-backup-ldap/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions georchestra-backup-ldap/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: georchestra-backup-ldap
description: A Helm chart for backup ldap

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.0.0"
62 changes: 62 additions & 0 deletions georchestra-backup-ldap/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "georchestra-backup-ldap.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "georchestra-backup-ldap.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "georchestra-backup-ldap.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "georchestra-backup-ldap.labels" -}}
helm.sh/chart: {{ include "georchestra-backup-ldap.chart" . }}
{{ include "georchestra-backup-ldap.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "georchestra-backup-ldap.selectorLabels" -}}
app.kubernetes.io/name: {{ include "georchestra-backup-ldap.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "georchestra-backup-ldap.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "georchestra-backup-ldap.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
63 changes: 63 additions & 0 deletions georchestra-backup-ldap/templates/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{{- $job := .Values.job -}}
{{- $ldapTargetConfiguration := .Values.configuration.ldapTarget -}}
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "georchestra-backup-ldap.fullname" . }}
labels:
{{- include "georchestra-backup-ldap.labels" . | nindent 4 }}
spec:
schedule: {{ $job.schedule | quote }}
successfulJobsHistoryLimit: {{ $job.successfulJobsHistoryLimit }}
jobTemplate:
spec:
metadata:
labels:
{{- include "georchestra-backup-ldap.labels" . | nindent 12 }}
template:
spec:
{{- with $job.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with $job.securityContext }}
securityContext:
{{ toYaml . | indent 12 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ $job.image.repository }}:{{ $job.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ $job.image.pullPolicy }}
volumeMounts:
- mountPath: /backup
name: backup
command: ["/bin/bash"]
args:
- -c
- /usr/bin/ldapsearch -H {{ $ldapTargetConfiguration.service }} -xLLL -D "cn=admin,{{ $ldapTargetConfiguration.baseDC }}" -w {{ $ldapTargetConfiguration.secret }} -b "ou=users,{{ $ldapTargetConfiguration.baseDC }}" > /backup/ldap-$(date +"%s").ldif
- /usr/bin/ldapsearch -H {{ $ldapTargetConfiguration.service }} -xLLL -D "cn=admin,{{ $ldapTargetConfiguration.baseDC }}" -w {{ $ldapTargetConfiguration.secret }} -b "ou=pendingusers,{{ $ldapTargetConfiguration.baseDC }}" >> /backup/ldap-$(date +"%s").ldif
- /usr/bin/ldapsearch -H {{ $ldapTargetConfiguration.service }} -xLLL -D "cn=admin,{{ $ldapTargetConfiguration.baseDC }}" -w {{ $ldapTargetConfiguration.secret }} -b "ou=orgs,{{ $ldapTargetConfiguration.baseDC }}" >> /backup/ldap-$(date +"%s").ldif
- /usr/bin/ldapsearch -H {{ $ldapTargetConfiguration.service }} -xLLL -D "cn=admin,{{ $ldapTargetConfiguration.baseDC }}" -w {{ $ldapTargetConfiguration.secret }} -b "ou=pendingorgs,{{ $ldapTargetConfiguration.baseDC }}" >> /backup/ldap-$(date +"%s").ldif
- /usr/bin/ldapsearch -H {{ $ldapTargetConfiguration.service }} -xLLL -D "cn=admin,{{ $ldapTargetConfiguration.baseDC }}" -w {{ $ldapTargetConfiguration.secret }} -b "ou=roles,{{ $ldapTargetConfiguration.baseDC }}" >> /backup/ldap-$(date +"%s").ldif
- rm `ls -t /backup | awk 'NR>{{ .Values.configuration.keepLastBackups }}'`
{{- with $job.resources }}
resources:
{{ toYaml . | indent 14 }}
{{- end }}
restartPolicy: {{ $job.restartPolicy }}
volumes:
- name: "backup"
persistentVolumeClaim:
claimName: {{ include "georchestra-backup-ldap.fullname" . }}-pvc
{{- with $job.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 12 }}
{{- end }}
{{- with $job.affinity }}
affinity:
{{ toYaml . | indent 12 }}
{{- end }}
{{- with $job.tolerations }}
tolerations:
{{ toYaml . | indent 12 }}
{{- end }}
30 changes: 30 additions & 0 deletions georchestra-backup-ldap/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ include "georchestra-backup-ldap.fullname" . }}-pvc
labels:
{{- include "georchestra-backup-ldap.labels" . | nindent 4 }}
annotations:
helm.sh/resource-policy: keep
spec:
accessModes:
{{- range .Values.persistence.accessModes }}
- {{ . | quote }}
{{- end }}
storageClassName: ""
selector:
matchLabels:
{{- include "georchestra-backup-ldap.selectorLabels" . | nindent 6 }}
resources:
requests:
storage: {{ .Values.persistence.size }}
{{- if .Values.persistence.existingPV }}
volumeName: {{ .Values.persistence.existingPV }}
{{- end }}
{{- if .Values.persistence.storageClass }}
{{- if eq "-" .Values.persistence.storageClass }}
storageClassName: ""
{{- else }}
storageClassName: {{ .Values.persistence.storageClass }}
{{- end }}
{{- end }}
67 changes: 67 additions & 0 deletions georchestra-backup-ldap/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
nameOverride: ""
fullnameOverride: ""

job:
image:
repository: georchestra/ldap
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
tag: "latest"
schedule: "0 6 * * *"
successfulJobsHistoryLimit: 3
restartPolicy: OnFailure
nodeSelector: {}
tolerations: []
affinity: {}
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
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
imagePullSecrets: []

configuration:
keepLastBackups: "10"
ldapTarget:
service: "ldap://georchestra-ldap-svc:389"
secret: "secret"
baseDC: "dc=georchestra,dc=org"

persistence:
## Persistent Volume Storage Class
## If defined, storageClassName: <storageClass>
## If set to "-", storageClassName: "", which disables dynamic provisioning
## If undefined (the default) or set to null, no storageClassName spec is
## set, choosing the default provisioner. (gp2 on AWS, standard on
## GKE, AWS & OpenStack)
##
# storageClass: "-"
## PVC annotations
#
# If you need this annotation include it under values.yml file and pvc.yml template will add it.
# This is not maintained at Helm v3 anymore.
# https://github.com/8gears/n8n-helm-chart/issues/8
#
## Persistent Volume Access Mode
##
accessModes:
- ReadWriteOnce
## Persistent Volume size
##
size: 5Gi
## Use an existing PV
##
# existingPV:

0 comments on commit 7822e1d

Please sign in to comment.