maclof/kubernetes-client

How do I access the pod logs?

theallseingeye opened this issue · 1 comments

Could you give an example of how to access the pod logs?

Thanks

@theallseingeye for example if you have a pod with the metadata name as "mcrouter-vfmtx" and a container with the name "mcrouter" you can find the last 100 log lines like this:

$pod = $kubernetesClient->pods()->setFieldSelector([
	'metadata.name' => 'mcrouter-vfmtx',
])->find()->first();

$logs = $kubernetesClient->pods()->logs($pod, [
	'timestamps' => true,
	'tailLines'  => 100,
	'container'  => 'mcrouter',
]);

You could also use setLabelSelector() instead of setFieldSelector, or both if you wish to have really fine grained control over the search.