get PreStop lifecycle hook execution results

6/24/2019

i'm trying to find out how to get preStop execution result for debugging purposes.

I'm creating a pod (not part of a deployment) with the following lifecycle definition:

   terminationGracePeriodSeconds: 60
   lifecycle:
      preStop:
        exec:
          command:
          - /bin/sh
          - -c
          - "echo trying post_stop;sleep 60"

when I ran it I can see it waiting 60 seconds but I cannot see any events for preStop hook being triggers not when I run kubectl get events and not when I run kubectl describe pod <my-pod> more then that I would love to know where the logs of the hook is being written, I tried to run kubectl logs <my-pod> -f but I did not see any logs there

-- Lior Baber
kubernetes
kubernetes-pod
lifecycle-hook

1 Answer

6/24/2019

You were on the right path with kubectl describe, check out the following location: /dev/termination-log see also the docs.

-- Michael Hausenblas
Source: StackOverflow