Search code examples
kuberneteskubernetes-pod

determine the Reason for Pod Failure


I have a broken pod in default namespace. I want to store associated error events to a file error.txt. I need to use the -o wide output specifier with my command. I saw command like this

- kubectl get pod termination-demo -o go-template="{{range
   .status.containerStatuses}}{{.lastState.terminated.message}}{{end}}"

but i need to use -o wide command.


Solution

  • If you want to achieve the pod state :

    kubectl get pod -n <NAMESPACE> <POD> --output=wide -o go-template="{{range.status.containerStatuses}}{{.lastState.terminated.message}}{{end}}" > pod.err
    

    Verify by :

    $ cat pod.err