Checking pod logs
When kubectl describe pod
does not show any information about an error, we can use another kubectl
command, that is, logs
. The kubectl logs
command allows us to print container logs, and we can also view them in real time as well.
Tip
You can use kubectl logs
with a flag to print the logs for the previous instance of the container in a pod if it exists:
$ kubectl logs -p some_pod
Now, let's check out this command on the crashing postgresql
pod and try to find out what is going on with it – why it is failing. To get the pods list and check the pod logs, run the following commands:
$ kubectl get pods $ kubectl logs postgresql-56dcb95567-njsp6
The output for the preceding commands is shown in the following screenshot:
Aha! As you can see from the preceding screenshot, the postgresql
pod is failing as it needs the POSTGRESQL_PASSWORD
environment variable...