Life ConnectLife Connect
Table of contents
Architecture
Services
Swagger Docs
GitHub
Table of contents
Architecture
Services
Swagger Docs
GitHub

Kubernetes Logs Retrieval Documentation


Accessing Pod Logs

Access remote env

Connect to VPS using

ssh <user>@<host> -o PreferredAuthentications=password -o PubkeyAuthentication=no 

Basic Log Retrieval

To retrieve logs from a specific pod, use the following command:

kubectl logs <pod-name> -n <namespace>

This command retrieves the logs for the pod. Replace <pod-name> with the name of the pod you want to inspect.

Follow Logs in Real-time

To stream the logs in real-time, use the -f flag:

kubectl logs -f <pod-name>

Viewing Previous Logs

To view logs from a previously terminated pod, add the --previous flag:

kubectl logs <pod-name> --previous

Logs from Multiple Pods

To retrieve logs from multiple pods that share the same label, you can use:

kubectl logs -l <label-selector>

Filter Logs by time

To filter logs from specific pods or applications based on their labels:

kubectl logs --since=<time>

Example:

kubectl logs <pod-name> --since=1h

Useful Tips

  • List existing pods:

    kubectl get pods -n <namespace>
    
  • Multiple Lines: If logs are too long, limit them with the --tail flag:

    kubectl logs <pod-name> --tail=100
    

Edit this page
Last Updated:
Contributors: gregory