# DaemonSet resource
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: random-refresher
spec:
  selector:
    matchLabels:
      app: random-refresher
  template:
    metadata:
      labels:
        app: random-refresher
    spec:
      # Also run on the the master even it's tainted
      tolerations:
      - key: node-role.kubernetes.io/master
        operator: Exists
      containers:
      - image: k8spatterns/random-generator:1.0
        name: random-generator
        # A somewhat useless command to demonstrate the concept running
        # on every node. This commands writes 10000 entries to /dev/random every 30s
        command:
        - sh
        - -c
        - >-
          while true; do
            java RandomRunner /host_dev/random 100000;
            sleep 30;
          done
        # Mount host's /dev directory
        volumeMounts:
        - mountPath: /host_dev
          name: devices
      volumes:
      # Expose devices into this daemon set
      - name: devices
        hostPath:
          path: /dev
