I've seen questions like below and I've been a bit stuck. Does it require me to . . .

Deirdre Rodgers:
I’ve seen questions like below and I’ve been a bit stuck. Does it require me to just find that information out and echo the value to that file (kubectl top pods and the echo podname > /path/cpu.txt)? or do something fancy with jsonpath or something else?

"Determine the pod with the highest CPU and output the value to /path/cpu.txt"

Mrudul Palvankar:
you are right, you just have to - kubectl top pods and the echo podname > /path/cpu.txt

Deirdre Rodgers:
great thank you :slightly_smiling_face:

Santiago Scalzadonna:
Hey, I did this practice on ACG, and the solution involved getting only the one with most CPU, so I guess it should be sorted by CPU usage --sort-by cpu or the like… and remember to get only the line you are interested, not the entire list :wink:

AnasGoaln:
so it should be kubectl top pods --sort-by-cpu > /path/cpu.txt

AnasGoaln:
right ??

Mrudul Palvankar:
This will write the whole list to /path/cpu.txt. You can manually copy the pod with highest cpu and write to /path/cpu.txt

AnasGoaln:
–sort-by=cpu

Santiago Scalzadonna:
Yes, I agree with Mrudul Palvankar, you should copy only the name of the pod in the text file

Raj:
Yes this is but confusing , does it need to be just a pod name in the file or complete row (with headers ? ) for pod with highest cpu ?

Basavraj Nilkanthe:
It is better to copy complete row until this is explicitly asked

Basavraj Nilkanthe:
Kubectl top pods --sort-by=cpu | head - 2 and just vim file name and press double “d” to delete first row…

Basavraj Nilkanthe:
There are some commands to skips first header row… need to find out that

Mrudul Palvankar:
Try with --no-headers

Mohit Pandey:
is it ok to manually copy incase we only need to add the podname as stated in query "Determine the pod "?
or is there a way to filter it out to only get the pod name?

Raj:
You can try this way

Mohit Pandey:
Thanks @Raj