---
kind: Deployment
apiVersion: apps/v1
metadata:
  labels:
    app: ceph
    daemon: rgw
  name: ceph-rgw
  namespace: ceph
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ceph
      daemon: rgw
  template:
    metadata:
      name: ceph-rgw
      namespace: ceph
      labels:
        app: ceph
        daemon: rgw
    spec:
      nodeSelector:
        node-type: storage
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app
                operator: In
                values: ["ceph"]
              - key: daemon
                operator: In
                values: ["rgw"]
            topologyKey: kubernetes.io/hostname
      hostNetwork: true
      dnsPolicy: ClusterFirstWithHostNet
      serviceAccount: default
      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-rgw
          #image: slpcat/ceph-daemon:mimic
          image: slpcat/ceph-daemon:v3.1.0-mimic-centos7
          lifecycle:
            postStart:
              exec:
                command:
                  - "sh"
                  - "-c"
                  - cp /tmp/ceph/* /etc/ceph/
          ports:
            - containerPort: 7480
          env:
            - name: CEPH_DAEMON
              value: RGW
            - name: RGW_CIVETWEB_PORT
              value: "7480"
            #- name: RGW_NAME
            #  value: myrgw
            #- name: RGW_ZONEGROUP
            #  value: ""
            #- name: RGW_ZONE
            #  value: ""
            - name: KV_TYPE
              value: k8s
            - name: CLUSTER
              value: ceph
            #- name: DEBUG
            #  value: verbos
          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:
              httpGet:
                path: /
                port: 7480
              initialDelaySeconds: 120
              timeoutSeconds: 5
          readinessProbe:
              httpGet:
                path: /
                port: 7480
              timeoutSeconds: 5
          resources:
            requests:
              memory: "128Mi"
              cpu: "100"
            limits:
              memory: "4Gi"
              cpu: "4"
