kubectl-node-logs
is a kubectl plugin for viewing and filtering node logs based on the
oc adm node-logs
implementation.
NodeLogQuery
feature gate is
enabled on the node(s)enableSystemLogHandler
and enableSystemLogQuery
are both set to true$ 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