---
kind: Deployment
apiVersion: apps/v1
metadata:
  labels:
    app: ceph
    daemon: mgr
  name: ceph-mgr
  namespace: ceph
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ceph
      daemon: mgr
  template:
    metadata:
      name: ceph-mgr
      namespace: ceph
      labels:
        app: ceph
        daemon: mgr
    spec:
      hostNetwork: true
      dnsPolicy: ClusterFirstWithHostNet
      serviceAccount: default
      tolerations:
        - key: CriticalAddonsOnly
          operator: Exists
        - key: node-role.kubernetes.io/master
          operator: Exists
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app
                operator: In
                values: ["ceph"]
              - key: daemon
                operator: In
                values: ["mgr"]
            topologyKey: kubernetes.io/hostname
      volumes:
        - name: ceph-conf
          secret:
            secretName: ceph-conf-combined
        - name: ceph-bootstrap-osd-keyring
          secret:
            secretName: ceph-bootstrap-osd-keyring
        - name: ceph-bootstrap-mds-keyring
          secret:
            secretName: ceph-bootstrap-mds-keyring
        - name: ceph-bootstrap-rgw-keyring
          secret:
            secretName: ceph-bootstrap-rgw-keyring
        - name: ceph-bootstrap-rbd-keyring
          secret:
            secretName: ceph-bootstrap-rbd-keyring
      containers:
        - name: ceph-mgr
          #image: slpcat/ceph-daemon:mimic
          image: slpcat/ceph-daemon:v3.1.0-mimic-centos7
          imagePullPolicy: Always
          lifecycle:
            postStart:
              exec:
                command:
                  - "sh"
                  - "-c"
                  - cp /tmp/ceph/* /etc/ceph/
          ports:
            - containerPort: 6800
            - containerPort: 8443
              name: dashboard
          env:
            - name: CEPH_DAEMON
              value: MGR
            - name: KV_TYPE
              value: k8s
            - name: NETWORK_AUTO_DETECT
              value: "4"
            - name: CLUSTER
              value: ceph
          volumeMounts:
            - name: ceph-conf
              mountPath: /tmp/ceph
            - name: ceph-bootstrap-osd-keyring
              mountPath: /var/lib/ceph/bootstrap-osd
            - name: ceph-bootstrap-mds-keyring
              mountPath: /var/lib/ceph/bootstrap-mds
            - name: ceph-bootstrap-rgw-keyring
              mountPath: /var/lib/ceph/bootstrap-rgw
            - name: ceph-bootstrap-rbd-keyring
              mountPath: /var/lib/ceph/bootstrap-rbd
          livenessProbe:
              tcpSocket:
                port: 6800
              initialDelaySeconds: 60
              timeoutSeconds: 5
          readinessProbe:
              tcpSocket:
                port: 6800
              timeoutSeconds: 5
          resources:
            requests:
              memory: "50Mi"
              cpu: "100m"
            limits:
              memory: "100Mi"
              cpu: "200m"
