Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes log location in pod

I am just trying to find the log location in the pod.

I just logged into the pod as below.

kubectl exec -it POD_NAME bash

But, the logs are not available under /var/logs. Not sure what is the actual log location and how to change that.

like image 950
user1578872 Avatar asked Jun 15 '18 03:06

user1578872


People also ask

Where are logs stored in pods?

For Kubernetes cluster components that run in pods, these write to files inside the /var/log directory, bypassing the default logging mechanism (the components do not write to the systemd journal). You can use Kubernetes' storage mechanisms to map persistent storage into the container that runs the component.

How do I find Kubernetes pod logs?

Kubectl Logs Command References With Examples. You can view the pods on your cluster using the kubectl get pods command. Add the --namespace <namespace name> flag if your pods are running outside of the default namespace. You can also use labels to filter the results as required by adding <my-label>=<my-value> .

How do I check container logs in pod?

To get Kubectl pod logs, you can access them by adding the -p flag. Kubectl will then get all of the logs stored for the pod. This includes lines that were emitted by containers that were terminated.


1 Answers

If your application is writing logs to file, then the location of that log file within the container depends on your application. The location of the log file on the host depends on whether you've mounted the log directory on the host.


If your application is writing logs to stdout, then your container runtime would capture each line and store it on the host. For Docker, this is stored in the /var/lib/docker/containers directory.

But Kubernetes also makes it easier for you to find the log files on the Kubernetes node, by symlinking the relevant log file to /var/log/pods/<namespace>_<pod_name>_<pod_id>/<container_name>/.

like image 195
d4nyll Avatar answered Sep 21 '22 11:09

d4nyll