English

View logs of running and crashed pods in Kubernetes

This tutorial will show you how to view logs of running and crashed pods in Kubernetes, also the ability to “tail” the log content.

First, find your pod’s name

Discover your pod’s name by running the following command, and picking the desired pod’s name from the list:

kubectl get pods
NAME                          READY     STATUS             RESTARTS   AGE
customer-96f4985b5-9h5pp      1/1       Running            7          11d
order-569b7f8f55-drd9t        1/1       Running            0          7d

View logs of a running pod

Just run:

kubectl logs <POD_NAME>

View and tail logs of a running pod

Add the -f parameter:

kubectl logs -f <POD_NAME>

View logs of a crashed pod

Use the --previous parameter:

kubectl logs <POD_NAME> --previous

I hope it helps. Cya!

bgasparotto

Recent Posts

Python function decorator

This guide will show you how to create a Python function decorator with a few…

2 years ago

Got permission denied while trying to connect to the Docker daemon socket

This guide will show you how to fix the error Got permission denied while trying…

2 years ago

Python virtual environment on Intellij IDEA

This guide will show you how to create a Python virtual environment on Intellij IDEA…

2 years ago

Find and kill processes on Linux and Mac by port number

This tutorial will quickly show you how to to find and kill processes on Linux,…

2 years ago

Python: Relocation R_X86_64_PC32 against symbol can not be used when making a shared object Error

This guide shows a possible solution for Python error Relocation R_X86_64_PC32 against symbol can not…

2 years ago

Kubernetes useful commands

I condensed below a cheat sheet of Kubernetes useful commands. I will keep updating this…

2 years ago