This project shows how you can tail all the PODs logs you want leveraging the API offered by fabric8io/kubernetes-client;
Basically it showcases you can do in Java the same thin stern achieves using GO;
To see it in action, download minikube and run:
minikube start
mvn test
This command starts test PodLogsTestCase
and this is what happens:
- the test has the custom annotation
@PodLog
- the custom annotation
@PodLog
has the JUnit 5 annotation@ExtendWith(PodLogExtension.class)
: this annotation tells JUnit to register thePodLogExtension
custom extension - the
PodLogExtension
custom extension startswatchLog
for every newly running POD
Loggable#watchLog is an API offered by fabric8io/kubernetes-client which tails a POD's log and redirects it to an OutputStream;