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
1 Like
Marco Tony:
I guess:
- kubectl top pods
- parsing the output through the jsonpath or jq creating a kind of csv like: consumption,pod_name
- sort the output through the sort utility
- get last line through the tail -1
samith perera:
kubectl top pods -l name=pod
Kubs:
kubectl top pod --sort-by cpu -l name=pod
Hải Đông:
@sharan and write manually in the specified file ?
k top pods -A --sort-by cpu --no-headers | head -1 > file.txt
kubectl top pod -A --selector=name=pod --all-namespaces
1 Like
k top nodes --sort-by cpu --no-headers | head -1 | awk ‘{print $1 }’ > output.txt