---
apiVersion: v1
kind: Pod
metadata:
  name: test-restarted
spec:
  # We write a file to an empty-dir volume to remember if the container has
  # started or not before, and ensure to crash on first startup.
  volumes:
    - name: empty-dir
      emptyDir: {}
  containers:
    - name: busybox
      image: busybox
      volumeMounts:
        - mountPath: /tmp/mount
          name: empty-dir
      command:
        - sh
        - -c
        - >
            if [ -f "/tmp/mount/here" ]; then
                printf "This is logged \nafter the container has restarted \nand is about to sleep...\n";
                sleep infinity;
            else
                touch /tmp/mount/here;
                printf "This is logged \njust before the container \nis about to crash!\n";
                exit 123;
            fi;
