apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: nginx
  labels:
    kubernetes.courselabs.co: daemonsets
spec:
  updateStrategy:
    type: OnDelete
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        kubernetes.courselabs.co: daemonsets
        app: nginx
    spec:
      initContainers:
        - name: init-html
          image: kiamol/ch03-sleep
          command: ['sh', '-c', "echo '<!DOCTYPE html><html><body><h1>I will only be replaced if you delete me</h1></body></html>' > /html/index.html"]
          volumeMounts:
            - name: html
              mountPath: /html
      containers:
        - image: nginx:1.18-alpine
          name: nginx
          volumeMounts:
            - name: html
              mountPath: /usr/share/nginx/html
      volumes:
        - name: html
          emptyDir: {}