Kubectl get event --field-selector involvedObject.name=<pod> --sort-by='.lastTimestamp'

Hi KK friends, in the mocks exam for CKA, you have used a lot the kubectl get event command to diagnostics. In mock 4 for example for this command : #kubectl get event --field-selector involvedObject.name=web-dp-cka06-trb-xxxx --sort-by=‘.lastTimestamp’ we are expected to see this answer :

Warning FailedPostStartHook pod/web-dp-cka06-trb-67dccb7487-2bjgf Exec lifecycle hook ([/bin -c echo ‘Test Page’ > /usr/local/apache2/htdocs/index.html]) for Container “web-container” in Pod “web-dp-cka06-trb-67dccb7487-2bjgf_default(4dd6565e-7f1a-4407-b3d9-ca595e6d4e95)” failed - error: rpc error: code = Unknown desc = failed to exec in container: failed to start exec “c980799567c8176db5931daa2fd56de09e84977ecd527a1d1f723a862604bd7c”: OCI runtime exec failed: exec failed: unable to start container process: exec: “/bin”: permission denied: unknown, message: “”

But I didn’t see all these details. I just saw :

Warning BackOff pod/web-dp-cka06-trb-67dccb7487-2bjgf Back-off restarting failed container web-container in pod web-dp-cka06-trb-67dccb7487-2bjgf_default(d43dd73d-37ca-4c72-a771-61a1fe583f6c)

This is not the only example. The Answer’s output to Kubectl get event generally has a more verbose output in the answers that I get when issue the command (copy/paste ok?) on the Mock CLI. So my question is how did you get that output? In my case, I didn’t see the difference on the output between Kubectl get event and kubectl describe commands. Maybe in previous versions the output was more verbose or something like. But now if both commands get the same results, what’s the point to use kubectl get events ? And if there are some details of the answers output that if I can’t see, turns the diagnostics of the problem a liitle harder. I Mean, as I didn’t see that /bin failure, it took more time to get there. Eventually I would, but it takes some time to do so. Could give any thoughts about this ? Tks.

Not sure why the output would be different, assuming that the pod that generated the error had the same configuration as expected, i.e., the container is trying to run

/bin -c echo ‘Test Page’ > /usr/local/apache2/htdocs/index.html

That’s obviously an error, and you’d expect the an error like " OCI runtime exec failed: exec failed". If you did create a pod like that, it would also not restart (as in your error). Without trying the problem myself (I’d need to know the question number for that) it’s hard to say more than that.

Hi Rob, it was Q.10 of Mock4. But they are all over the place, Q1, Q5,Q6, Q9. My problem is the the output of this command.

I suspect that the output of k get event varies by kubernetes version, and in Q10, it’s not really that useful for the problem. I did not get the OCI related error either (it wasn’t in the describe output either). But you do get output that postStartHook failed:

10m         Warning   FailedPostStartHook   pod/web-dp-cka06-trb-74b489f8f-xhq2g         PostStartHook failed

I would not expect the content of events to be “constant”. But in this case, it is still extremely useful, because it draws your attention to exactly the block where the error occurs. Change /bin to /bin/sh, and things work.

Thanks, Rob. yes I suspect the same either. I also got the PostStartHook which led me to the solution. I just asked to confirm because the answers were more clear than what I had, so it could be something else which I was not getting. But you just confirmed that it was different. I wouldn’t remove it from the answers, but the KK could make a salvo that the output could be different. Brgds…