# based on:
#
#   https://github.com/shelmangroup/coreos-gpu-installer/blob/master/daemonset.yaml
#
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: nvidia-driver-installer
  namespace: kube-system
  labels:
    application: nvidia-driver-installer
    version: 162d624
spec:
  updateStrategy:
    type: RollingUpdate
  selector:
    matchLabels:
      application: nvidia-driver-installer
  template:
    metadata:
      labels:
        application: nvidia-driver-installer
        version: 162d624
    spec:
      serviceAccountName: nvidia
      tolerations:
      - key: nvidia.com/gpu
        effect: NoSchedule
        operator: Exists
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: zalando.org/nvidia-gpu
                operator: Exists
              - key: node.kubernetes.io/distro
                operator: NotIn
                values:
                - ubuntu
      priorityClassName: system-node-critical
      hostNetwork: true
      hostPID: true
      volumes:
      - name: dev
        hostPath:
          path: /dev
      - name: nvidia-install-dir-host
        hostPath:
          path: /opt/nvidia
      - name: root-mount
        hostPath:
          path: /
      initContainers:
      - name: nvidia-driver-installer
        image: registry.opensource.zalan.do/teapot/coreos-nvidia-driver-installer:162d624
        resources:
          limits:
            cpu: 150m
            memory: 768Mi
          requests:
            cpu: 150m
            memory: 768Mi
        securityContext:
          privileged: true
        env:
        - name: NVIDIA_INSTALL_DIR_HOST
          value: /opt/nvidia
        - name: NVIDIA_INSTALL_DIR_CONTAINER
          value: /usr/local/nvidia
        - name: ROOT_MOUNT_DIR
          value: /root
        - name: NVIDIA_DRIVER_VERSION
          value: "410.78"
        volumeMounts:
        - name: nvidia-install-dir-host
          mountPath: /usr/local/nvidia
        - name: dev
          mountPath: /dev
        - name: root-mount
          mountPath: /root
      containers:
      - image: registry.opensource.zalan.do/teapot/pause-amd64:3.1
        name: pause
        # Needs to be the same as the init container, because CA doesn't pay any attention to init containers at all
        resources:
          limits:
            cpu: 150m
            memory: 768Mi
          requests:
            cpu: 150m
            memory: 768Mi
