apiVersion: apps/v1
kind: Deployment
metadata:
  name: benji-maint
  namespace: rook-ceph
  labels:
    app.kubernetes.io/name: benji
  annotations:
    configmap.reloader.stakater.com/reload: "benji-configs,rook-ceph-mon-endpoints,benji-ceph-config"
    secret.reloader.stakater.com/reload: "rook-ceph-mon"
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: benji
  template:
    metadata:
      labels:
        app.kubernetes.io/name: benji
    spec:
      serviceAccountName: benji
      dnsPolicy: ClusterFirstWithHostNet
      initContainers:
        - name: generate-ceph-files
          image: rook/ceph:v1.8.2
          imagePullPolicy: IfNotPresent
          command:
            - /usr/bin/bash
          args:
            - -c
            - bash /script/generate-ceph.sh
          volumeMounts:
            - name: mon-endpoint-volume
              mountPath: /etc/rook
            - name: ceph-data
              mountPath: /etc/ceph
            - name: benji-ceph-config
              mountPath: /script/generate-ceph.sh
              subPath: generate-ceph.sh
          env:
            - name: ROOK_CEPH_USERNAME
              valueFrom:
                secretKeyRef:
                  name: rook-ceph-mon
                  key: ceph-username
            - name: ROOK_CEPH_SECRET
              valueFrom:
                secretKeyRef:
                  name: rook-ceph-mon
                  key: ceph-secret
      containers:
        - name: benji
          image: "ghcr.io/elemental-lf/benji-k8s:0.15.0"
          imagePullPolicy: IfNotPresent
          securityContext:
            privileged: true
          env:
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          volumeMounts:
            - name: benji-data
              mountPath: /data
            - name: benji-configs
              mountPath: /benji/etc
            - name: tz-config
              mountPath: /etc/localtime
            - name: benji-nfs-backup
              mountPath: /benji-nfs-backup
            - name: ceph-data
              mountPath: /etc/ceph
          resources:
            requests:
              cpu: 100m
              memory: 100Mi
            limits:
              cpu: 200m
              memory: 200Mi
      volumes:
        - name: benji-data
          persistentVolumeClaim:
            claimName: benji-data
        - name: benji-configs
          configMap:
            name: benji-configs
        - name: tz-config
          hostPath:
            path: /usr/share/zoneinfo/Asia/Jakarta
        - name: benji-nfs-backup
          persistentVolumeClaim:
            claimName: benji-nfs-backup
        - name: mon-endpoint-volume
          configMap:
            name: rook-ceph-mon-endpoints
            items:
              - key: data
                path: mon-endpoints
        - name: ceph-data
          emptyDir: {}
        - name: benji-ceph-config
          configMap:
            name: benji-ceph-config
