apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    run: prestop
  name: prestop
  namespace: default
spec:
  selector:
    matchLabels:
      run: prestop
  template:
    metadata:
      annotations:
        # XXX: value should be a json encoded list. That means, each string
        # should be enclosed with double-quote
        alpha.kinvolk.io/sidecar: '["sidecar-1"]'
      labels:
        run: prestop
    spec:
      containers:
      - name: sidecar-1
        image: debian
        command: ["/logs/logs.sh", "sleep"]
        env:
          - name: NAME
            value: "sidecar-1"
        readinessProbe:
          periodSeconds: 1
          failureThreshold: 1
          exec:
            command: ["/bin/sh", "-c", "test -f /tmp/ready && /logs/logs.sh Ready && exit 0 || /logs/logs.sh Not Ready && exit 1"]
        volumeMounts:
        - name: logs
          mountPath: /logs
      - name: debian-1
        image: debian
        command: ["/logs/logs.sh", "sleep"]
        env:
          - name: NAME
            value: "debian-1"
            #lifecycle:
            #  preStop:
            #    exec:
            #      #command: ["/bin/sh", "-c", "/logs/logs.sh PreStop Will-Sleep; sleep 10; /logs/logs.sh PreStop-After-Sleep; exit 0"]
        volumeMounts:
        - name: logs
          mountPath: /logs
      volumes:
      - name: logs
        hostPath:
          path: /tmp/logs/
