From the pod lable name=pod, find pods running high CPU workloads and write the . . .

Venkat:
From the pod lable name=pod, find pods running high CPU workloads and write the name of the pod consuming most to the file. how to solve this?

Hải Đông:
i do it manually
k top po | grep label. Check the most consuming pod and write in the file. not sure its correct

Marco Tony:
I guess:

  1. kubectl top pods
  2. parsing the output through the jsonpath or jq creating a kind of csv like: consumption,pod_name
  3. sort the output through the sort utility
  4. get last line through the tail -1

samith perera:
kubectl top pods -l name=pod

Venkat:
@Tej_Singh_Rana is it right?

sharan:
@Venkat kubectl top pod --sort-by cpu name=pod

Kubs:
kubectl top pod --sort-by cpu -l name=pod

Hải Đông:
@sharan and write manually in the specified file ?