Use this when the node is part of the cluster and the API server answers, but you cannot SSH in. The log collector runs as a short-lived privileged Job, and you read the file back from its logs.
For example: a node is NotReady or keeps restarting, but port 100 is blocked by a firewall policy or you do not have the SSH key.
The Job writes the bundle to its stdout as base64 between BEGIN/END markers.
apiVersion: batch/v1
kind: Job
metadata:
name: log-collector
namespace: kube-system
spec:
backoffLimit: 0
template:
spec:
restartPolicy: Never
hostPID: true
nodeName: <node-name> # the node you want the bundle from
containers:
- name: collect
image: busybox
securityContext:
privileged: true
command:
[
"chroot",
"/host",
"/usr/bin/syself-log-collector",
"--stdout",
"--stdout-encoding=base64"
]
volumeMounts:
- name: host
mountPath: /host
volumes:
- name: host
hostPath:
path: /
Apply it, wait for it to finish, then decode the bundle out of the logs:
$ kubectl apply -f log-collector-job.yaml
$ kubectl -n kube-system wait --for=condition=complete job/log-collector --timeout=120s
$ kubectl -n kube-system logs job/log-collector \
| sed -n '/BEGIN SYSELF BUNDLE/,/END SYSELF BUNDLE/p' | sed '1d;$d' \
| base64 -d > report.tar.gz
$ kubectl -n kube-system delete job/log-collector
kubectl cp does not work here, because it cannot read from a finished pod.