---
kind: Template
apiVersion: v1
metadata:
  name: glusterfs
  labels:
    glusterfs: template
  annotations:
    description: GlusterFS DaemonSet template
    tags: glusterfs
objects:
- kind: DaemonSet
  apiVersion: extensions/v1beta1
  metadata:
    name: glusterfs
    labels:
      glusterfs: daemonset
    annotations:
      description: GlusterFS DaemonSet
      tags: glusterfs
  spec:
    selector:
      matchLabels:
        glusterfs-node: pod
    template:
      metadata:
        name: glusterfs
        labels:
          glusterfs: pod
          glusterfs-node: pod
      spec:
        nodeSelector:
          storagenode: ${NODE_LABEL}
        hostNetwork: true
        containers:
        - image: gluster/gluster-centos:latest
          imagePullPolicy: IfNotPresent
          name: glusterfs
          env:
          - name: HOST_DEV_DIR
            value: "${HOST_DEV_DIR}"
          - name: GLUSTER_BLOCKD_STATUS_PROBE_ENABLE
            value: "${GLUSTER_BLOCKD_STATUS_PROBE_ENABLE}"
          - name: GB_GLFS_LRU_COUNT
            value: "${GB_GLFS_LRU_COUNT}"
          - name: TCMU_LOGDIR
            value: "${TCMU_LOGDIR}"
          resources:
            requests:
              memory: 100Mi
              cpu: 100m
          volumeMounts:
          - name: glusterfs-heketi
            mountPath: "/var/lib/heketi"
          - name: glusterfs-run
            mountPath: "/run"
          - name: glusterfs-lvm
            mountPath: "/run/lvm"
          - name: glusterfs-etc
            mountPath: "/etc/glusterfs"
          - name: glusterfs-logs
            mountPath: "/var/log/glusterfs"
          - name: glusterfs-config
            mountPath: "/var/lib/glusterd"
          - name: glusterfs-host-dev
            mountPath: "${HOST_DEV_DIR}"
          - name: glusterfs-misc
            mountPath: "/var/lib/misc/glusterfsd"
          - name: glusterfs-block-sys-class
            mountPath: "/sys/class"
          - name: glusterfs-block-sys-module
            mountPath: "/sys/module"
          - name: glusterfs-cgroup
            mountPath: "/sys/fs/cgroup"
            readOnly: true
          - name: glusterfs-ssl
            mountPath: "/etc/ssl"
            readOnly: true
          - name: kernel-modules
            mountPath: "/lib/modules"
            readOnly: true
          securityContext:
            capabilities: {}
            privileged: true
          readinessProbe:
            timeoutSeconds: 3
            initialDelaySeconds: 40
            exec:
              command:
              - "/bin/bash"
              - "-c"
              - "if command -v /usr/local/bin/status-probe.sh; then /usr/local/bin/status-probe.sh readiness; else systemctl status glusterd.service; fi"
            periodSeconds: 25
            successThreshold: 1
            failureThreshold: 50
          livenessProbe:
            timeoutSeconds: 3
            initialDelaySeconds: 40
            exec:
              command:
              - "/bin/bash"
              - "-c"
              - "if command -v /usr/local/bin/status-probe.sh; then /usr/local/bin/status-probe.sh liveness; else systemctl status glusterd.service; fi"
            periodSeconds: 25
            successThreshold: 1
            failureThreshold: 50
          terminationMessagePath: "/var/log/termination.log"
        volumes:
        - name: glusterfs-heketi
          hostPath:
            path: "/var/lib/heketi"
        - name: glusterfs-run
          emptyDir: {}
        - name: glusterfs-lvm
          hostPath:
            path: "/run/lvm"
        - name: glusterfs-etc
          hostPath:
            path: "/etc/glusterfs"
        - name: glusterfs-logs
          hostPath:
            path: "/var/log/glusterfs"
        - name: glusterfs-config
          hostPath:
            path: "/var/lib/glusterd"
        - name: glusterfs-host-dev
          hostPath:
            path: "/dev"
        - name: glusterfs-misc
          hostPath:
            path: "/var/lib/misc/glusterfsd"
        - name: glusterfs-block-sys-class
          hostPath:
            path: "/sys/class"
        - name: glusterfs-block-sys-module
          hostPath:
            path: "/sys/module"
        - name: glusterfs-cgroup
          hostPath:
            path: "/sys/fs/cgroup"
        - name: glusterfs-ssl
          hostPath:
            path: "/etc/ssl"
        - name: kernel-modules
          hostPath:
            path: "/lib/modules"
        restartPolicy: Always
        terminationGracePeriodSeconds: 30
        dnsPolicy: ClusterFirst
        securityContext: {}
parameters:
- name: NODE_LABEL
  displayName: Daemonset Storage Node Label
  description: This is the value that will be used for the storagenode label in the daemonset node selector.
  value: glusterfs
- name: GLUSTER_BLOCKD_STATUS_PROBE_ENABLE
  displayName: Enable readiness/liveness probe for gluster-blockd
  description: Setting the value to "1" enables the readiness/liveness probe for gluster-blockd.
  value: "1"
  required: false
- name: GB_GLFS_LRU_COUNT
  displayName: Maximum number of block hosting volumes
  description: This value is to set maximum number of block hosting volumes.
  value: "15"
  required: true
- name: TCMU_LOGDIR
  displayName: Tcmu runner log directory
  description: This value is to set tcmu runner log directory
  value: "/var/log/glusterfs/gluster-block"
  required: true
- name: HOST_DEV_DIR
  displayName: Alternative path to /dev in the container
  description: Volume mount point of /dev from the host so that the container can access all devices.
  value: "/mnt/host-dev"
  required: true
