apiVersion: v1
kind: Namespace
metadata:
  name: openldap
---
apiVersion: v1
kind: Secret
metadata:
  name: openldap-admin
  namespace: openldap
  labels:
    app: gerrit
data:
  adminpassword: #TODO
---
apiVersion: v1
kind: Secret
metadata:
  name: openldap-users
  namespace: openldap
  labels:
    app: gerrit
data:
  users: gerrit-admin,gerrit-user
  passwords: #TODO
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: openldap
  namespace: openldap
  labels:
    app.kubernetes.io/name: openldap
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: openldap
  replicas: 1
  template:
    metadata:
      labels:
        app.kubernetes.io/name: openldap
    spec:
      containers:
      - name: openldap
        image: docker.io/bitnami/openldap:latest
        imagePullPolicy: "IfNotPresent"
        env:
          - name: LDAP_ADMIN_USERNAME
            value: "admin"
          - name: LDAP_ADMIN_PASSWORD
            valueFrom:
              secretKeyRef:
                key: adminpassword
                name: openldap-admin
          - name: LDAP_USERS
            valueFrom:
              secretKeyRef:
                key: users
                name: openldap-users
          - name: LDAP_PASSWORDS
            valueFrom:
              secretKeyRef:
                key: passwords
                name: openldap-users
        ports:
          - name: tcp-ldap
            containerPort: 1389
---
apiVersion: v1
kind: Service
metadata:
  name: openldap
  namespace: openldap
  labels:
    app.kubernetes.io/name: openldap
spec:
  type: ClusterIP
  ports:
    - name: tcp-ldap
      port: 1389
      targetPort: tcp-ldap
  selector:
    app.kubernetes.io/name: openldap

