Find the pod that consumes the most CPU and store the result to the file /opt/high_cpu_pod in the following format cluster_name,namespace,pod_name.
The pod could be in any namespace in any of the clusters that are currently configured on the student-node.
data stored in /opt/high_cpu_pod?
Below was the Solution provided by me: It was marked as Wrong while verification
student-node ~ ➜ kubectl top pods -A --context cluster1 --no-headers | sort -nr -k3 | head -1
kube-system kube-apiserver-cluster1-controlplane 55m 308Mi
student-node ~ ➜ kubectl top pods -A --context cluster2 --no-headers | sort -nr -k3 | head -1
kube-system kube-apiserver-cluster2-controlplane 36m 311Mi
student-node ~ ➜ kubectl top pods -A --context cluster3 --no-headers | sort -nr -k3 | head -1
default frontend-stable-cka05-arch 301m 2Mi
student-node ~ ➜ kubectl top pods -A --context cluster4 --no-headers | sort -nr -k3 | head -1
kube-system kube-apiserver-cluster4-controlplane 44m 309Mi
student-node ~ ➜ echo cluster1,kube-system,kube-apiserver-cluster1-controlplane > /opt/high_cpu_pod
student-node ~ ➜ vi /opt/high_cpu_pod
Solution provided by KodeCloud LABs:
student-node ~ ➜ kubectl top pods -A --context cluster1 --no-headers | sort -nr -k3 | head -1
kube-system kube-apiserver-cluster1-controlplane 30m 258Mi
student-node ~ ➜ kubectl top pods -A --context cluster2 --no-headers | sort -nr -k3 | head -1
kube-system metrics-server-7cd5fcb6b7-fhdrl 5m 18Mi
student-node ~ ➜ kubectl top pods -A --context cluster3 --no-headers | sort -nr -k3 | head -1
kube-system metrics-server-7cd5fcb6b7-zvfrg 5m 18Mi
student-node ~ ➜ kubectl top pods -A --context cluster4 --no-headers | sort -nr -k3 | head -1
kube-system metrics-server-7cd5fcb6b7-zvfrg 5m 18Mi
student-node ~ ➜
why it was marked Incorrect for me ?
I think you have stored static solution for verification.
Kindly verify it, If anything wrong at my end please let me know.
Thank you,
Swapnil