apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: ${APP_NAME}-drbd
  labels:
      app: ${APP_NAME}-drbd
      ${NODE_LABEL}: ""
      ${LUSTRE_FSNAME}/server: "drbd"
spec:
  selector:
    matchLabels:
      name: ${APP_NAME}-drbd
  template:
    metadata:
      labels:
        name: ${APP_NAME}-drbd
        ${NODE_LABEL}: ""
        ${LUSTRE_FSNAME}/server: "drbd"
    spec:
      hostNetwork: true
      nodeSelector:
        ${NODE_LABEL}: ""
      tolerations:
      - key: node-role.kubernetes.io/master
        operator: Exists
        effect: NoSchedule
      initContainers:
      - name: drbd-install
        image: kvaps/drbd-install
        command: [ "/install-drbd.sh" ]
        env:
        - name: CHROOT
          value: "/host-root"
        - name: DEBUG
          value: "${DRBD_DEBUG:-0}"
        volumeMounts:
        - name: host-root
          mountPath: "/host-root"
      containers:
      - name: ${APP_NAME}-drbd
        image: kvaps/drbd
        securityContext:
          privileged: true
        env:
        - name: PROTOCOL
          value: "${DRBD_PROTOCOL}"
        - name: SYNCER_RATE
          value: "${DRBD_SYNCER_RATE}"
        - name: DEBUG
          value: "${DRBD_DEBUG:-0}"
        - name: CHROOT
          value: "/host-root"
        - name: RESOURCE_NAME
          value: "${APP_NAME}"
        - name: DEVICE
          value: "${DRBD_DEVICE}"
        - name: NODE1_NAME
          value: "${NODE1_NAME}"
        - name: NODE1_IP
          value: "${NODE1_IP}"
        - name: NODE1_DISK
          value: "${DRBD_NODE1_DISK}"
        - name: NODE1_PORT
          value: "${DRBD_PORT}"
        - name: NODE2_NAME
          value: "${NODE2_NAME}"
        - name: NODE2_IP
          value: "${NODE2_IP}"
        - name: NODE2_DISK
          value: "${DRBD_NODE2_DISK}"
        - name: NODE2_PORT
          value: "${DRBD_PORT}"
        - name: FORCE_CREATE
          value: "${DRBD_FORCE_CREATE:-0}"
        volumeMounts:
        - name: host-root
          mountPath: /host-root
      terminationGracePeriodSeconds: 10
      volumes:
      - name: host-root
        hostPath:
          path: /
