kubectl-node-logs
is a kubectl plugin for viewing and filtering node logs based on the
oc adm node-logs
implementation.
- Kubernetes cluster 1.27+
NodeLogQuery
feature gate is enabled on the node(s)- Kubelet configuration options
enableSystemLogHandler
andenableSystemLogQuery
are both set to true - Authorized to interact with node objects
- kubectl version 1.27+
- Go version 1.21
$ git clone https://github.com/aravindhp/kubectl-node-logs.git
$ cd kubectl-node-logs
$ go build -o kubectl-node_logs cmd/kubectl_node_logs.go
$ mv kubectl-node_logs /$USER/.local/bin # or any other directory in $PATH
Here is an example to retrieve the kubelet service logs from a node:
# Fetch kubelet logs from a node named node-1.example
$ kubectl node-logs node-1.example --query=kubelet
You can also fetch files, provided that the files are in a directory that the kubelet allows for log fetches. For example, you can fetch a log from /var/log/ on a node:
kubectl node-logs node-1.example --query /foo.log
For further options, please see kubectl node-logs --help
- Kubernetes Cluster Administration -> System Logs -> Log query
- Kubernetes 1.27 Blog post: Query Node Logs Using The Kubelet API