Reputation: 1309
How to get resources (CPU and Memory) consumed by a kubernetes job at the end of job's lifecycle? Is this out of kubernetes job implementation's scope?
Notes:
kubectl describe job
provides only the limit/request specified.Upvotes: 2
Views: 2162
Reputation: 22058
If you're not using an external tool, the only option which I can think of is running a sidecar container that logs the CPU and Memory usage at each time period.
When the tasks that were executed via the Job resource have finished there work, K8S will not delete the corresponding pods (you will see READY 0/1
and STATUS Completed
) so you can view those logs and the status of the each pod.
(*) If you want to log resources usage compared to the given resources request and limit - you can use the Downward API and this information will be available to containers through environment variables.
Upvotes: 0
Reputation: 1651
I would not encourage you to only restrict yourself to kubectl top pod
. This is only good for quick troubleshoot and sneak peek only.
In production, you must have a more concrete framework for resource usage monitoring and I have found Prometheus very useful. Of course, when you are working on GCP, you may choose native monitoring toolsets also.
Upvotes: 2
Reputation: 853
we can get resource consumption of pods which are created by job using "kubectl top pod" command but pod must be live at that time.
But Once pods dies we don't have any way to collect resource consumption.
Upvotes: 0