apiVersion: apps/v1
kind: DaemonSet
metadata:
  namespace: mayastor
  name: mayastor
  labels:
    openebs/engine: mayastor
spec:
  selector:
    matchLabels:
      app: mayastor
  updateStrategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1
  minReadySeconds: 10
  template:
    metadata:
      labels:
        app: mayastor
    spec:
      hostNetwork: true
      # To resolve services from mayastor namespace
      dnsPolicy: ClusterFirstWithHostNet
      nodeSelector:
        openebs.io/engine: mayastor
        kubernetes.io/arch: amd64
      # NOTE: Each container must have mem/cpu limits defined in order to
      # belong to Guaranteed QoS class, hence can never get evicted in case of
      # pressure unless they exceed those limits. limits and requests must be
      # the same.
      containers:
      - name: mayastor
        image: mayadata/mayastor:v0.3.0
        imagePullPolicy: Always
        env:
        - name: MY_NODE_NAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
        - name: MY_POD_IP
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
        - name: IMPORT_NEXUSES
          value: "false"
        args:
        - "-N$(MY_NODE_NAME)"
        - "-g$(MY_POD_IP)"
        - "-nnats"
        - "-y/var/local/mayastor/config.yaml"
        securityContext:
          privileged: true
        volumeMounts:
        - name: device
          mountPath: /dev
        - name: dshm
          mountPath: /dev/shm
        - name: configlocation
          mountPath: /var/local/mayastor/
        - name: config
          mountPath: /var/local/mayastor/config.yaml
        resources:
          limits:
            cpu: "1"
            memory: "500Mi"
            hugepages-2Mi: "1Gi"
          requests:
            cpu: "1"
            memory: "500Mi"
            hugepages-2Mi: "1Gi"
        ports:
        - containerPort: 10124
          protocol: TCP
          name: mayastor
      volumes:
      - name: device
        hostPath:
          path: /dev
          type: Directory
      - name: dshm
        emptyDir:
          medium: Memory
          sizeLimit: "1Gi"
      - name: hugepage
        emptyDir:
          medium: HugePages
      - name: configlocation
        hostPath:
          path: /var/local/mayastor/
          type: DirectoryOrCreate
      - name: config
        hostPath:
          path: /var/local/mayastor/config.yaml
          type: FileOrCreate
