Skip to content

Commit

Permalink
feat: add support for OpenLDAP addon (#5097)
Browse files Browse the repository at this point in the history
  • Loading branch information
kissycn authored Sep 14, 2023
1 parent 07a4f6b commit 1d2f2eb
Show file tree
Hide file tree
Showing 15 changed files with 477 additions and 0 deletions.
23 changes: 23 additions & 0 deletions deploy/openldap-cluster/.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/
17 changes: 17 additions & 0 deletions deploy/openldap-cluster/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v2
name: openldap-cluster
description: A Helm chart for Openldap Cluster
type: application
version: 0.1.0-alpha.0
appVersion: "2.4.57"

home: https://kubeblocks.io/
icon: https://kubeblocks.io/img/logo.png
keywords:
- openldap
- ldap

maintainers:
- name: kissycn
url: https://github.com/kissycn

62 changes: 62 additions & 0 deletions deploy/openldap-cluster/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "openldap-cluster.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 "openldap-cluster.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 "openldap-cluster.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "openldap-cluster.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "openldap-cluster.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
46 changes: 46 additions & 0 deletions deploy/openldap-cluster/templates/cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: apps.kubeblocks.io/v1alpha1
kind: Cluster
metadata:
name: {{ include "openldap-cluster.name" . }}
labels:
{{- include "openldap-cluster.labels" . | nindent 4 }}
spec:
clusterDefinitionRef: openldap
clusterVersionRef: openldap-{{ default .Chart.AppVersion .Values.clusterVersionOverride }}
terminationPolicy: {{ .Values.terminationPolicy }}
affinity:
{{- with $.Values.topologyKeys }}
topologyKeys: {{ . | toYaml | nindent 6 }}
{{- end }}
{{- with $.Values.tolerations }}
tolerations: {{ . | toYaml | nindent 4 }}
{{- end }}
componentSpecs:
- name: openldap
componentDefRef: openldap-compdef
{{- if .Values.replication }}
replicas: 2
{{- else }}
replicas: 1
{{- end }}
serviceAccountName: {{ include "openldap-cluster.serviceAccountName" . }}
{{- with .Values.resources }}
resources:
limits:
cpu: {{ .limits.cpu | quote }}
memory: {{ .limits.memory | quote }}
requests:
cpu: {{ .requests.cpu | quote }}
memory: {{ .requests.memory | quote }}
{{- end }}
{{- if .Values.persistence.enabled }}
volumeClaimTemplates:
- name: data # ref clusterdefinition components.containers.volumeMounts.name
spec:
storageClassName: {{ .Values.persistence.data.storageClassName }}
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.persistence.data.size }}
{{- end }}
12 changes: 12 additions & 0 deletions deploy/openldap-cluster/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "openldap-cluster.serviceAccountName" . }}
labels:
{{- include "openldap-cluster.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
25 changes: 25 additions & 0 deletions deploy/openldap-cluster/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "openldap-cluster.fullname" . }}-test-connection"
labels:
{{- include "openldap-cluster.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: test-openldap-cluster
image: "{{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}"
command:
- "ldapsearch"
args:
- "-x"
- "-H"
- "ldap://openldap-cluster-openldap-0.openldap-cluster-openldap-headless.default.svc.cluster.local"
- "-b"
- "dc=kubeblocks,dc=io"
- "-D"
- "cn=admin,dc=kubeblocks,dc=io"
- "-w"
- "admin"
restartPolicy: Never
63 changes: 63 additions & 0 deletions deploy/openldap-cluster/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Default values for openldap-cluster.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replication: false
terminationPolicy: Halt

nameOverride: ""
fullnameOverride: ""

image:
repository: osixia/openldap
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "1.5.0"

serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""

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

topologyKeys:
- kubernetes.io/hostname

tolerations: []

## Enable persistence using Persistent Volume Claims
## ref: https://kubernetes.io/docs/user-guide/persistent-volumes/
##
persistence:
## @param shard[*].persistence.enabled Enable persistence using Persistent Volume Claims
##
enabled: false
## `data` volume settings
##
data:
## @param shard[*].persistence.data.storageClassName Storage class of backing PVC
## 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)
##
storageClassName:
## @param shard[*].persistence.size Size of data volume
##
size: 10Gi
23 changes: 23 additions & 0 deletions deploy/openldap/.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/
18 changes: 18 additions & 0 deletions deploy/openldap/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v2
name: openldap
type: application
description: |-
The OpenLDAP Project is a collaborative effort to develop a robust, commercial-grade, fully featured, and open source LDAP suite of applications and development tools.
This chart provides KubeBlocks'
version: 0.1.0-alpha.0
appVersion: "2.4.57"
home: https://kubeblocks.io/
icon: https://kubeblocks.io/img/logo.png
keywords:
- openldap
- ldap

maintainers:
- name: kissycn
url: https://github.com/kissycn
Empty file.
62 changes: 62 additions & 0 deletions deploy/openldap/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "openldap.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 "openldap.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 "openldap.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "openldap.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "openldap.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions deploy/openldap/templates/clusterVersion.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: apps.kubeblocks.io/v1alpha1
kind: ClusterVersion
metadata:
name: openldap-{{ default .Chart.AppVersion .Values.clusterVersionOverride }}
labels:
{{- include "openldap.labels" . | nindent 4 }}
spec:
clusterDefinitionRef: openldap
componentVersions:
- componentDefRef: openldap-compdef
versionsContext:
containers:
- name: openldap-container
image: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}
imagePullPolicy: {{ default .Values.image.pullPolicy "IfNotPresent" }}
Loading

0 comments on commit 1d2f2eb

Please sign in to comment.