apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: ${APP_NAME}
  labels:
      app: ${APP_NAME}
      ${NODE_LABEL}: ""
      ${LUSTRE_FSNAME}/server: "lustre"
spec:
  selector:
    matchLabels:
      name: ${APP_NAME}
  serviceName: ${APP_NAME}
  replicas: 1
  updateStrategy:
    type: OnDelete
  template:
    metadata:
      labels:
        name: ${APP_NAME}
        ${NODE_LABEL}: ""
        ${LUSTRE_FSNAME}/server: "lustre"
    spec:
      hostNetwork: true
      nodeSelector:
        ${NODE_LABEL}: ""
      tolerations:
      - key: node-role.kubernetes.io/master
        operator: Exists
        effect: NoSchedule
      initContainers:
      - name: lustre-install
        image: kvaps/lustre-install
        env:
        - name: CHROOT
          value: "/host-root"
        - name: DEBUG
          value: "${LUSTRE_DEBUG:-0}"
        volumeMounts:
        - name: host-root
          mountPath: "/host-root"
      containers:
      - name: ${APP_NAME}
        image: kvaps/lustre
        securityContext:
          privileged: true
        env:
        - name: KUBE_NOTIFY
          value: "1"
        - name: DEBUG
          value: "${LUSTRE_DEBUG:-0}"
        - name: CHROOT
          value: "/host-root"
        - name: HA_BACKEND
          value: "${LUSTRE_HA_BACKEND}"
        - name: RESOURCE_NAME
          value: "${APP_NAME}"
        - name: DEVICE
          value: "${LUSTRE_DEVICE}"
        - name: FSNAME
          value: "${LUSTRE_FSNAME}"
        - name: INDEX
          value: "${LUSTRE_INDEX}"
        - name: TYPE
          value: "${LUSTRE_TYPE}"
        - name: MGSNODE
          value: "${LUSTRE_MGSNODE}"
        - name: SERVICENODE
          value: "${LUSTRE_SERVICENODE}"
        - name: FORCE_CREATE
          value: "${LUSTRE_FORCE_CREATE:-0}"
        volumeMounts:
        - name: host-root
          mountPath: /host-root
      terminationGracePeriodSeconds: 60
      volumes:
      - name: host-root
        hostPath:
          path: /
