---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: gke-zpool-init
  labels:
    app: gke-zpool-init
  annotations:
    command: &cmd apt-get update && apt-get install -y zfsutils-linux && umount -f /dev/sdd && wipefs -af /dev/sdd && zpool create zfspv-pool /dev/sdd
spec:
  selector:
    matchLabels:
      app: gke-zpool-init
  template:
    metadata:
      labels:
        app: gke-zpool-init
    spec:
      hostNetwork: true
      initContainers:
      - name: init-node
        command:
          - nsenter
          - --mount=/proc/1/ns/mnt
          - --
          - sh
          - -c
          - *cmd
        image: ubuntu
        securityContext:
          privileged: true
      hostPID: true
      containers:
      - name: wait
        image: k8s.gcr.io/pause:3.1
      hostPID: true
      hostNetwork: true
      tolerations:
      - effect: NoSchedule
        key: node-role.kubernetes.io/master
  updateStrategy:
    type: RollingUpdate
