apiVersion: v1
kind: Pod
metadata:
  name: mount-by-sidecar
  labels:
    app: myapp
spec:
  containers:
  - name: app-main
    image: busybox
    imagePullPolicy: IfNotPresent
    command: ['sh', '-c', 'sleep 5; cat /tmp/hello/hello']
    volumeMounts:
      - mountPath: /tmp/hello
        name: hello-dir
  - name: app-mounter
    image: fuse-hello:latest
    imagePullPolicy: IfNotPresent
    command: ['sh', '-c', 'sleep 1 ; cat /tmp/hello/hello ; sleep 5']
    lifecycle:
      postStart:
        exec:
          command: ['sh', '-c', './hello /tmp/hello']
      preStop:
        exec:
          command: ['sh', '-c', 'fusemount -u /tmp/hello']
    volumeMounts:
      - mountPath: /tmp/hello
        name: hello-dir
    securityContext:
      privileged: true
      capabilities:
        add:
          - SYS_ADMIN
  volumes:
    - name: hello-dir
      emptyDir: {}
