Copy Logs From K8s
Quick Start
- •Ensure
kubectlpoints to the target cluster. - •Run from the analysis directory so logs are saved there:
code
python3 .codex/copy-logs-from-k8s/scripts/copy_logs_from_k8s.py
- •Download specific sources:
code
python3 scripts/copy_logs_from_k8s.py --sources tikv python3 scripts/copy_logs_from_k8s.py --sources tikv,tiflash
- •Or specify sources directly from the analysis directory:
code
python3 .codex/copy-logs-from-k8s/scripts/copy_logs_from_k8s.py --sources tiflash
Outputs
- •Logs are saved under
./<pod-name>/...in the current working directory. - •tikv:
/var/lib/tikv/log - •tiflash:
/data0/logs(uses containerserverlog) - •s3clean:
/tmp/s3clean.log->./<pod>/s3clean.log
Notes
- •tiflash logs use
kubectl exec ... catbecause filenames can include:which breakskubectl cp. - •Large log sets can take time to copy; re-run safely if interrupted.
Extend To Other Pods
- •Edit
scripts/copy_logs_from_k8s.py. - •Add the new source name to
AVAILABLE_SOURCES. - •Add a
LogSource(...)entry insourceswithinmain():- •Set
pod_predicateto match pod names. - •Use
log_dirto copy a directory orsingle_filefor one file. - •Set
containerif the pod requires a specific container. - •Set
use_exec_copy=Trueifkubectl cpfails or filenames include:.
- •Set