This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a scripts repository maintained by Mattox Engineering, containing diagnostic and troubleshooting tools for Kubernetes environments. The primary tool is a logs collector supporting various Kubernetes distributions (RKE2, RKE1, K3s, kubeadm).
scripts/
├── logs-collector/
│ ├── rancher2_logs_collector.sh # Main logs collection script (~1800 lines)
│ ├── README.md # Usage documentation
│ └── collection-details.md # Details on what data is collected
└── LICENSE # Apache 2.0
# Basic usage (must be run as root)
sudo bash logs-collector/rancher2_logs_collector.sh
# With custom output directory
sudo bash logs-collector/rancher2_logs_collector.sh -d /var/tmp
# Override auto-detected k8s distribution
sudo bash logs-collector/rancher2_logs_collector.sh -r rke2
# Custom RKE2 data directory
sudo bash logs-collector/rancher2_logs_collector.sh -c /opt/rke2
# Filter logs by date range
sudo bash logs-collector/rancher2_logs_collector.sh -s 7 -e 5 # relative days
sudo bash logs-collector/rancher2_logs_collector.sh -S 2024-01-01 -E 2024-01-07 # absolute dates
# Obfuscate IPs and hostnames
sudo bash logs-collector/rancher2_logs_collector.sh -oSYSTEM_NAMESPACES: Kubernetes namespaces to collect pod logs fromKUBE_CONTAINERS: Container names to collect logs from (etcd, kube-apiserver, etc.)JOURNALD_LOGS: Services to collect journald logs forVAR_LOG_FILES: Log files to collect from /var/logSPACE: Minimum disk space required (MB)TIMEOUT: Command timeout in seconds
The script follows a sequential collection pattern:
setup()- Creates temp directory, sets up pathsdisk-space()- Validates available disk spacesherlock()- Auto-detects OS, k8s distribution (rke/rke2/k3s), and init systemsystem-all()- Collects OS-level info (disk, processes, sysctl)networking()- Comprehensive network data collection (see below)- Distribution-specific functions (
rke(),rke2(),k3s(), etc.) archive()- Creates tar.gz output in /tmp (or custom directory)
The networking() function collects comprehensive network diagnostics:
- Firewall: iptables (all tables including raw), ip6tables, nftables, firewalld
- IP/Routing: addresses, routes, rules, neighbors, multicast groups
- Sockets: ss/netstat for TCP, UDP, Unix, raw sockets
- Namespaces: network namespace list
- Bridge/VLAN: bridge links, FDB entries, VLAN config
- DNS: systemd-resolved status and configuration
- systemd-networkd: networkctl status and configs
- Interface details: ethtool for all interfaces (driver, features)
- Kernel tunables: filtered sysctl net.* parameters
- CNI-specific: Calico (calicoctl), Cilium (cilium CLI) when available
- RKE2 (auto-detected via
rke2binary) - K3s (auto-detected via
k3sbinary) - RKE1 (auto-detected via
dockerbinary) - Kubeadm (manual override required:
-r kubeadm)
- Script is designed to run on production nodes with minimal resource impact
- Uses
nice/ionicewith lowest priority by default (override with-p) - Output is sanitized where possible, but
-oflag adds IP/hostname obfuscation - Collection is intentionally limited to avoid sensitive data