How to view the storage path of k8s logs?

There are several ways to view the storage path of logs in Kubernetes.

  1. Use the kubectl command to view the logs of a Pod.
  2. Show the logs for the specified pod.
  3. Viewing logs of a specific container using the kubectl command:
  4. Retrieve the logs of a specific container within a pod using the command “kubectl logs -c “.
  5. Use the kubectl command to view the logs and output them in real-time.
  6. Show the continuous logs of a specific pod using kubectl.
  7. Retrieve the log path of a Pod using the kubectl command:
  8. Provide a detailed description of the pod with the specified name using kubectl.
  9. Look for the “Mounts” field in the output, which lists the mounting paths of the containers. You can find log files in the corresponding mounting paths.
  10. Login to the node host, and search for the log files of the container:
    Begin by using the kubectl command to obtain the IP address of the node host where the Pod is located.
  11. Display the details of the specified pod and filter the output to only show the Node information.
  12. Next, log in to the corresponding node host and locate the path to the container’s log files. By default, the logs for pods are stored in the /var/log/containers directory, named in the format of “.log”.

In addition to the methods mentioned above, visual tools such as Kibana and ELK can also be used to view and analyze logs in a Kubernetes cluster.

bannerAds