Skip to content

Commit

Permalink
Merge pull request #70 from it-at-m/refactor-helm-chart-ldap-sync
Browse files Browse the repository at this point in the history
refactoring chart zammad-ldap-sync
  • Loading branch information
markostreich authored Dec 18, 2024
2 parents 7376164 + 7c1f3a7 commit 62b1281
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 57 deletions.
2 changes: 1 addition & 1 deletion charts/zammad-ldap-sync/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: zammad-ldap-sync
version: 0.4.1
version: 0.5.0
maintainers:
- name: klml
email: [email protected]
Expand Down
62 changes: 62 additions & 0 deletions charts/zammad-ldap-sync/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "zammad-ldap-sync.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 "zammad-ldap-sync.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 "zammad-ldap-sync.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "zammad-ldap-sync.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "zammad-ldap-sync.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
6 changes: 4 additions & 2 deletions charts/zammad-ldap-sync/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
kind: ConfigMap
apiVersion: v1
metadata:
name: {{ .Values.ldapSync.configMap.name }}
name: {{ include "zammad-ldap-sync.name" . }}
labels:
{{- include "zammad-ldap-sync.labels" . | nindent 4 }}
data:
{{- with .Values.ldapSync.configMap.yaml }}
{{- with .Values.ldapSync.applicationYML }}
application.yaml: |
{{- toYaml . | nindent 4 }}
{{- end }}
6 changes: 4 additions & 2 deletions charts/zammad-ldap-sync/templates/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: zammad-ldap-sync
name: {{ include "zammad-ldap-sync.name" . }}
labels:
{{- include "zammad-ldap-sync.labels" . | nindent 4 }}
spec:
schedule: {{ .Values.ldapSync.cronjob.schedule | quote }}
jobTemplate:
Expand Down Expand Up @@ -34,7 +36,7 @@ spec:
path: cacerts
- name: properties-volume
configMap:
name: {{ .Values.ldapSync.configMap.name }}
name: {{ include "zammad-ldap-sync.name" . }}
items:
- key: application.yaml
path: application.yaml
Expand Down
87 changes: 35 additions & 52 deletions charts/zammad-ldap-sync/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,39 @@ ldapSync:
tag: dev
cronjob:
schedule: "0 2 * * *"
# Must be present.
# Must be present.
secret: kubernetes-secret
configMap:
# Created by helm.
name: kubernets-configmap
yaml:
spring:
main:
web-application-type: none
profiles:
# Profile influences log output. May be you don't want to write ldap entries in your log files.
active: default,prod
# Send email in caseof invalid distinguished-names.
mail:
host: mail.example.com
port: 1
username: email-user
password: email-password
ldap:
url: ldaps://...
sync:
# If necessary, set different distinguished-names with their own ldap-search-bases.
organizational-units:
identifier-1:
distinguished-names:
# - dn-identifier-1
user-search-base: user-dn-search-base-dent-1
ou-search-base: ou-dn-search-base-dent-1
identifier-2:
distinguished-names:
# - dn-identifier-2
user-search-base: user-dn-search-base-dent-2
ou-search-base: ou-dn-search-base-dent-2
message:
from: [email protected]
to: [email protected]
subject: Ooopps..
subject:
zammad:
# Zammad roles which must exist. Register role with correct role id.
assignment:
role:
# Default zammad role. Is created by zammad.
name-agent: Agent
# Zammad role with permission ticket.agent. Must be created.
name-erstellen: Erstellen
# Zammad role with permission ticket.agent. Must be created.
name-vollzugriff: Vollzugriff
url:
base: http://zammad-nginx:8080/api/v1/
groups: groups
users: users
roles: roles

applicationYML:
spring:
profiles:
# Profile influences log output. May be you don't want to write ldap entries in your log files.
active: default,prod
# Send email in caseof invalid distinguished-names.
mail:
host: mail.example.com
port: 1
username: email-user
password: email-password
ldap:
url: ldaps://...
sync:
# If necessary, set different distinguished-names with their own ldap-search-bases.
organizational-units:
identifier-1:
distinguished-names:
# - dn-identifier-1
user-search-base: user-dn-search-base-dent-1
ou-search-base: ou-dn-search-base-dent-1
identifier-2:
distinguished-names:
# - dn-identifier-2
user-search-base: user-dn-search-base-dent-2
ou-search-base: ou-dn-search-base-dent-2
message:
from: [email protected]
to: [email protected]
subject: Ooopps..
zammad:
url:
base: http://zammad-nginx:8080/api/v1/

0 comments on commit 62b1281

Please sign in to comment.