kubectl-logs

Read Kubernetes pod logs with kubectl logs, including streaming and filtering options.

Updated Mar 2, 2019
One-click install
npx skills add https://github.com/trmaphi/dotfiles --skill kubectl-logs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kubectl-logs
Source: https://github.com/trmaphi/dotfiles/tree/main/.claude/skills/kubectl-logs
Command: npx skills add https://github.com/trmaphi/dotfiles --skill kubectl-logs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Read container logs from Kubernetes pods using kubectl logs to diagnose issues and monitor applications.

Core Features & Use Cases

  • Streaming logs in real time with -f, viewing previous logs with --previous, and selecting specific containers with -c when pods contain multiple containers.
  • Filter, search, and monitor logs across single or multiple pods using label selectors and time-based filters like --since or --since-time.
  • Use case: Debug a crashing pod, troubleshoot restarts, or monitor live application output during deployments.

Quick Start

Run kubectl logs <pod-name> to view live and historical logs for debugging.

Frequently Asked Questions about kubectl-logs

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I view logs from a specific container in a multi-container Kubernetes pod?

To view logs from a specific container in a multi-container Kubernetes pod, use kubectl logs with the -c flag followed by the container name to isolate the output for troubleshooting.

Can I stream Kubernetes pod logs in real time to monitor application output?

You can stream Kubernetes pod logs in real time by running kubectl logs with the -f flag, which provides live output to monitor application behavior during deployments.

How do I retrieve logs from a crashed Kubernetes pod that has restarted?

To retrieve logs from a crashed Kubernetes pod that has restarted, use kubectl logs with the --previous flag to access the output from the crashed container instance.

What is the best way to filter Kubernetes pod logs by time or labels?

The best way to filter Kubernetes pod logs is using label selectors for pod targeting and time-based filters like --since or --since-time to narrow down the output.

Does kubectl logs work for troubleshooting deployments across multiple pods?

Yes, kubectl logs works for troubleshooting deployments across multiple pods by using label selectors to fetch and aggregate output from all pods matching the deployment label.

Why am I not seeing timestamps when reading container logs with kubectl?

If you are not seeing timestamps when reading container logs, you need to add the --timestamps flag to your kubectl logs command to prepend timestamps to each log line.