We have a deep love for Kubernetes and have built all our infrastructure on top of it.
Editor's Note: for the full tutorial, please visit the Kuberenetes Blog.
When deploying anything you need to have visibility to what's going on and logs are a first view into the inner workings of your application. Good old tail -f has been around for a long time, and Kubernetes has this too, built right into kubectl.
For all the good reasons to use tail (like the ease of debugging), there are some issues. For example, by using Kubernetes Replication Controllers, you're faced with multiple pods with multiple unique IDs, so you'll need to know the exact pod ID (kubectl get pods) for debugging but that changes every time a pod is created so you'll be forever changing this. Another consideration is the fact that Kubernetes load balances the traffic, so you won't know at which pod a request ends, so if you're tailing pod A but the traffic ends up at pod B you'll miss what happened.
To get around this and other issues, we built Stern. It's a simple utility that allows you to specify both the pod id and the container id as regular expressions. Any match will be followed, and the output is multiplexed together, prefixed with the pod and container id, and color-coded for human consumption (colors are stripped if piping to a file).
Besides, if a pod is killed and recreated during a deployment Stern will stop listening to the old pod and automatically hook into the new one. There's no more need to figure out what the id of that newly created pod is.
Updates and user contributions
In cases where logs have a number of irrelevant lines (such as Kubernetes "liveness" checks), being able to filter out these lines can make logs far more readable.
This PR adds an
--exclude flag, which takes a regex as its value; any line that matches the regex will not be printed. Multiples can be specified as
--exclude rex1 --exclude rex2
Why not join our early access club (you've seen the impact they have). We’ll invite you to try our beta products and treat you nice.
As usual, if you want to stay in the loop follow us on twitter @wercker or hop on our public slack channel. If it’s your first time using Wercker, be sure to tweet out your #greenbuilds, and we’ll send you some swag!