apiVersion: v1
kind: ReplicationController
metadata:
  name: ldap-controller
  labels:
    app: ldap
spec:
  replicas: 1
  selector:
    app: ldap
  template:
    metadata:
      labels:
        app: ldap
    spec:
      containers:
        - name: ldap
          image: osixia/openldap:1.1.7
          args: ["--copy-service"]
          volumeMounts:
            - name: ldap-data
              mountPath: /var/lib/ldap
            - name: ldap-config
              mountPath: /etc/ldap/slapd.d
            - name: ldap-certs
              mountPath: /container/service/slapd/assets/certs
            - name: secret-volume
              mountPath: /container/environment/01-custom
            - name: container-run
              mountPath: /container/run
          ports:
            - containerPort: 389
              name: openldap
        - name: ldap-backup
          image: osixia/openldap-backup:0.1.11
          volumeMounts:
            - name: ldap-data
              mountPath: /var/lib/ldap
            - name: ldap-config
              mountPath: /etc/ldap/slapd.d
            - name: ldap-backup
              mountPath: /data/backup
          env:
            - name: LDAP_BACKUP_CONFIG_CRON_EXP
              value: "15 1 * * *"
            - name: LDAP_BACKUP_DATA_CRON_EXP
              value: "20 1 * * *"
            - name: LDAP_BACKUP_TTL
              value: "15"
      volumes:
        - name: ldap-data
          hostPath:
            path: "/data/ldap/db"
        - name: ldap-config
          hostPath:
            path: "/data/ldap/config"
        - name: ldap-backup
          hostPath:
            path: "/data/ldap/backup"
        - name: ldap-certs
          hostPath:
            path: "/data/ldap/certs"
        - name: "secret-volume"
          secret:
            secretName: "ldap-secret"
        - name: container-run
          emptyDir: {}
