Sunday, October 15, 2017

Tail logs from all Kubernetes pods at once

Unfortunately you cannot tail and at the same time use selectors:
$ kubectl logs -l 'role=nodejs' --tail=2 -f 
error: only one of follow (-f) or selector (-l) is allowed
See 'kubectl logs -h' for help and examples.
However there are alternatives. Here is a how to tail logs from all Kubernetes pods at once using just one Plain Old Bash (POB) script.

Wednesday, October 04, 2017

upgrading kubernetes - container pods stuck in state 'unknown'

I deleted an old pod that was sticking in our cluster without explanation and it turned into state 'unknown'. Getting logs from nodejs apps was impossible, in fact 'kubectl exec' hanged ssh sessions. I remember that I saw errors like these (pods reluctant to be deleted) when GKE was expecting a k8s upgrade. So I did and the issue got resolved.

Saturday, September 16, 2017

Auditing file changes in Linux

Audit the file by adding a watch, tail the audit log, remove the watch and list current watches in case you need to remove others.
sudo auditctl -w /path/to/file -p wa
sudo tail -f /var/log/audit/audit.log
sudo auditctl -W /path/to/file -p wa
sudo auditctl -l

Thursday, August 03, 2017

shortcut to get into a kubernetes pod shell

$ grep -B0 -F3 kbash ~/.bashrc
function kbash() {
  kubectl exec -ti $1 bash
}
Usage:
kbash some-pod-name-here

Friday, July 28, 2017

Followers