k8s-logs
Prerequisites
sternCLI installed (brew install stern)kubectlCLI installed- K8s bootstrap completed (shared with k8s-steampipe)
Usage
# List configured clusters
~/.dataops-assistant/bin/k8s-logs.sh clusters
# List namespaces in a cluster
~/.dataops-assistant/bin/k8s-logs.sh <cluster> namespaces
# List pods in a namespace
~/.dataops-assistant/bin/k8s-logs.sh <cluster> pods <namespace>
# Fetch logs (stern query)
~/.dataops-assistant/bin/k8s-logs.sh <cluster> <namespace> <pod-query> [options]
Options
| Option | Description | Default |
|---|---|---|
--since <duration> |
Show logs since (e.g., 5m, 1h) | 5m |
--tail <lines> |
Number of lines to tail | 100 |
--container <name> |
Container name (multi-container pods) | all |
--timestamps |
Include timestamps | off |
--previous |
Show logs from previous instance | off |
Cluster Selection
CRITICAL: You MUST ask the user which cluster to query. Never assume or default.
Available clusters (run clusters command to get current list):
- EKS: dss-eks-platform-dev, dss-eks-platform-prod
- AKS: datascience-primary-cluster, mathom-primary-cluster, dev-experiment-cluster, stage-experiment-cluster
Instructions
- Ask the user which cluster to query (show available options)
- List namespaces to help them identify the right one
- List pods to identify the query pattern
- Fetch logs with appropriate options
Examples
# Flyte workflow logs (last 5 min)
~/.dataops-assistant/bin/k8s-logs.sh datascience-primary-cluster flyte "workflow-*"
# CoreDNS logs with timestamps
~/.dataops-assistant/bin/k8s-logs.sh dss-eks-platform-dev kube-system "coredns-*" --timestamps
# Previous container instance logs
~/.dataops-assistant/bin/k8s-logs.sh mathom-primary-cluster default my-pod --previous
# Last hour of logs
~/.dataops-assistant/bin/k8s-logs.sh dss-eks-platform-prod app "api-*" --since 1h --tail 500
Notes
- Pod query uses stern's regex matching (e.g.,
api-.*matches api-abc, api-xyz) - Use
--containerfor pods with sidecars to filter specific container - The
--no-followflag is used automatically (no streaming)