All guides Rune

How to view Kubernetes pod logs in the right namespace

Choose the Kubernetes context, namespace, pod and container before reading logs. If a container just restarted, request the previous container instance. These examples use fictional cluster and workload names.

Read logs with kubectl

List contexts, then use the context and namespace explicitly in your commands. Replace the example names with your own. Use the pod list to confirm the pod name and Restart Count in your client or the RESTARTS column in the terminal.

kubectl config get-contexts
          kubectl --context example-dev -n example-app get pods
          kubectl --context example-dev -n example-app logs pod/example-api -c app --tail=100

Append --follow to stream new messages. For a restarted container, use --previous to request the previous instance when its logs are still available. The -c app flag selects the application container if the pod also has a sidecar. Kubernetes documentation for kubectl logs.

Open the same logs in Rune

  1. Select your kubeconfig context and the namespace, then open the pod in Rune.
  2. Open its Logs view and choose the container. Search for the first error or a request ID.
  3. For a restart, open the log actions and use Include Previous Container. Check the pod's events alongside the logs if the container failed to start or was killed.

Rune keeps the selected workload, log view and events together. Export the log if you need a local copy for comparison.

Diagnose a Forbidden or connection error

Run this read-only permission check. Kubernetes grants access to pod logs separately from access to the pod itself.

kubectl --context example-dev -n example-app auth can-i get pods --subresource=log

If it returns no, share the context, namespace and failed operation with whoever manages access. If the request times out or reports that credentials are missing or expired, open Auth Doctor in Rune to check the API connection, sign-in and access separately. Kubernetes documentation for kubectl auth can-i.