---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: local-ssd-startup-cos
  namespace: kube-system
  labels:
    app: local-ssd-startup-cos
spec:
  template:
    metadata:
      labels:
        app: local-ssd-startup-cos
    spec:
      hostPID: true
      nodeSelector:
        cloud.google.com/gke-os-distribution: cos
        cloud.google.com/gke-local-ssd: "true"
      containers:
        - name: local-ssd-startup
          image: gcr.io/google-containers/startup-script:v1
          securityContext:
            privileged: true
          resources:
            requests:
              cpu: 100m
              memory: 100Mi
            limits:
              cpu: 100m
              memory: 100Mi
          env:
          - name: STARTUP_SCRIPT
            value: |
              #!/usr/bin/env bash
              set -euo pipefail
              mount | grep -v nobarrier | awk '/ssd/{print $1}' | xargs -i mount {} -o remount,nobarrier
          volumeMounts:
          - mountPath: /mnt/disks
            name: local-ssd
            mountPropagation: Bidirectional
      tolerations:
      - effect: NoSchedule
        operator: Exists
      volumes:
      - name: local-ssd
        hostPath:
          path: /mnt/disks
