There are various "production-ready" ways to do log gathering and viewing across a Kubernetes/OpenShift cluster. Many folks like some flavor of ELK or EFK.
The focus here is on stuff a developer needs to get access to do help understand the behavior of their application running inside of a pod.
Make sure you are running 3 replicas (3 pods/instances of your application)
$ kubectl scale --replicas=3 deployment/myboot
and you can see them with kubectl get pods
$ kubectl get pods NAME READY STATUS RESTARTS AGE myboot-68d666dd8d-cwtls 1/1 Running 0 3m myboot-68d666dd8d-n874b 1/1 Running 0 3m myboot-68d666dd8d-r8zpn 1/1 Running 0 11m
There is kubectl logs which is useful
$ kubectl logs myboot-68d666dd8d-r8zpn -f
or you can try stern, easily installable via homebrew on Mac https://github.com/wercker/stern
$ brew install stern
and use it like so
$ stern myboot
and in another terminal window, poll the various instances of the application
while true do curl $(minikube ip):$(kubectl get service/myboot -o jsonpath="{.spec.ports[*].nodePort}") sleep .5; done
and stern will let you see the logs across the 3 different pods.
This is more exciting when you might have 3 different microservices where the names are similiar enough to use stern.
stern also offers a --label selector
and if you are running Istio make sure to add the -c to specify your business logic container, instead of the sidecar…unless you wish to view the sidecar’s logs :-)
Another option is kail
$ brew tap boz/repo $ brew install boz/repo/kail $ kail
This will output the logs across your namespace, in our case, the 3 replicas of myboot are all in the same namespace
You can use use kail and isolate a specific deployment, specific container (a pod can have more than one container) and look back in time
$ kail --deploy=myboot -c myboot --since=1h