0

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
  • 852
  • 3
  • 11
  • 25
  • have you looked at echoing to the terminationMessagePath? https://kubernetes.io/docs/tasks/debug-application-cluster/determine-reason-pod-failure/ Defaults: terminationMessagePath: /dev/termination-log terminationMessagePolicy: File – eamon1234 Jun 24 '19 at 08:05
  • I cannot get the pod's yaml after he was deleted. so writing to /dev/termination-log did not help in this case (i'm using k8s 1.11) – Lior Baber Jun 24 '19 at 12:39

1 Answers1

1

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

Michael Hausenblas
  • 13,162
  • 4
  • 52
  • 66
  • I cannot get the pod's yaml after he was deleted. so both `kubectl describe` and writing to /dev/termination-log did not help in this case (i'm using k8s 1.11) – Lior Baber Jun 24 '19 at 12:38
  • You have the pod name? Also, not writing to but reading from that location (within the pod). I wrote about it, here: https://blog.openshift.com/kubernetes-pods-life/ – Michael Hausenblas Jun 24 '19 at 12:47