How can I get logs in io.fabric8.kubernetes.client?

11/7/2019

I am using this kubernetes client API in my java code, but I am with problems to get the logs. The namespace is "cloudlab-namespace", podname is "mylambda" and the label is "app=mylambda". When I performed the necessary command on Terminal is working perfectly, but using the kubernetes client is not working.

This command is working perfectly:

kubectl -n cloudlab-namespace logs -l app=mylambda -c mylambda --tail=50

I tried creating an object watch but this way it doesn't return anything:

LogWatch watch = client.pods()
.inNamespace("cloudlab-namespace")
.withName("mylambda")
.tailingLines(10)
.watchLog(System.out);

I expected the same result when I performed the following command on Terminal:

kubectl -n cloudlab-namespace logs -l app=mylambda -c mylambda --tail=50
-- Marcelo
java
kubernetes

0 Answers