# The deployment for cstor-pool and cstor-pool-mgmt.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: cstor-pool-deploy
  labels:
    app: cstor-pool
spec:
  replicas: 1
  selector:
    matchLabels:
      app: cstor-pool
  template:
    metadata:
      labels:
        app: cstor-pool
    spec:
      serviceAccountName: openebs-maya-operator
        #nodeSelector:
        #  kubernetes.io/hostname: "gke-test-default-pool-9cb32f2f-1jc1"
      containers:
      - name: cstor-pool
        # The image name here will be changed to openebs once the business logic pr is reviewed and merged in openebs/maya.
        image: openebs/cstor-pool:ci
        imagePullPolicy: Always
        ports:
        - containerPort: 12000
          protocol: TCP
        - containerPort: 3233
          protocol: TCP
        - containerPort: 3232
          protocol: TCP
        securityContext: 
          privileged: true

        volumeMounts:
        - name: device
          mountPath: /dev     
        - name: tmp
          mountPath: /tmp
          # To avoid clash between terminating and restarting pod in case older zrepl gets deleted faster, we keep initial delay.
        lifecycle:
          postStart:
             exec:
                command: ["/bin/sh", "-c", "sleep 2"]

      - name:    cstor-pool-mgmt
        # The image name here will be changed to openebs once the business logic pr is reviewed and merged in openebs/maya.
        image: gkganeshr/cstor-pool-mgmt:v2.7
        imagePullPolicy: Always
        ports:
        - containerPort: 9500
          protocol: TCP
        securityContext: 
          privileged: true
        volumeMounts:
        - name: device
          mountPath: /dev
        - name: tmp
          mountPath: /tmp
        - mountPath: /run/udev
          name: udev
        env:
          # OPENEBS_IO_CSTOR_ID env has UID of cStorPool CR.
        - name: OPENEBS_IO_CSTOR_ID
          value: "ec0d620f-89c4-11e8-9b1a-54e1ad4a9dd4"      

      volumes:
      - name: device
        hostPath:
          # directory location on host
          path: /dev
          # this field is optional
          type: Directory
      - name: tmp
        hostPath:
          # From host, dir called /var/openebs/shared-<uid> is created to avoid clash if two replicas run on same node.
          path: /var/openebs/shared-a2b
      - name: udev
        hostPath:
          path: /run/udev
          type: Directory

