I suggest https://github.com/wercker/stern tool instead, which is much more mature and does the same thing.
I use kubectl logs -f {pod-name} [container-name]
heavily when developing/debugging applications in Kubernetes. It's quite difficult if I have multiple replicas though. kubectl logs -l key=value
works to some extent but not with the -f
flag. I just wish I could do something like:
$ kubectl logs -f {service-name} [container-name]
or
$ kubectl logs -f {deployment-name} [container-name]
This simple wrapper tool does exactly just that.
$ go get -u -v github.com/flowerinthenight/klf
# General usage:
$ klf tail <svc|dep> <svc-name|deployment-name> [container-name] [--add-prefix]
# Tail a service `svc1` with only one container in the pod:
$ klf tail svc svc1
# Tail a deployment `deploy1` with only one container in the pod:
$ klf tail dep deploy1
# Tail a service `svc1`'s sidecar container:
$ klf tail svc svc1 git-sync
# Tail a deployment `deploy1` with pod name as prefix:
$ klf tail dep deploy1 --add-prefix