Monday, January 25, 2021

Kill sidecar container

 apiVersionbatch/v1

kindJob
metadata:
  namelifecycle-check1
spec:
  ttlSecondsAfterFinished1
  template:
    spec:
      containers:
      - nameapp1
        imageartifactory.<URL>:5000/location/alpine:latest
        command: ["sh""-c"]
        args:
        - |
          echo Start.
          sleep 10
          touch /message/processDone
          exit 0
        volumeMounts:
          - mountPath/message
            nametest-volume
      - nameapp2
        imageartifactory.<URL>:5000/location/alpine:latest
        command: ["sh""-c"]
        lifecycle:
          typeSidecar
        args:
        - |
          trap 'echo "Trapped SIGTERM"; sleep 3; echo "See you!!"; exit 0' TERM
          echo Start.
          while true
          do
              date
              # sleep 20
              if [ -f /message/processDone ]; then
                echo "File found, exiting"
                exit 0
              else
                echo "file not found yet"
              fi
          done
        volumeMounts:
          - mountPath/message
            nametest-volume
      volumes:
      - nametest-volume
        emptyDir: {}
      restartPolicyNever
    backoffLimit4
      # terminationGracePeriodSeconds: 30