Basavraj Nilkanthe:
and another one – what should be my kubectl comand to identify pod consuming highest cpu and storing output file…
Find pods running high CPU workloads and write the name of the pod consuming most CPU to the file.
Basavraj Nilkanthe:
and another one – what should be my kubectl comand to identify pod consuming highest cpu and storing output file…
Find pods running high CPU workloads and write the name of the pod consuming most CPU to the file.
Gennway:
kubectl top pods -n namespace
Malayamanas Panda:
kubectl top pods --labels=“key=value”
Gennway:
also use --sort-by= with “cpu” or “memory”
Narendra Singh:
@Gennway I think we can not use --sort-by= , this options is not there in kubectl command options. Have you tried it?
Narendra Singh:
It is available with get command.
new_day:
kubectl top pods -n default --sort-by='~memory~' | head -2 | awk '{print $1}'
Basavraj Nilkanthe:
Thanks
Basavraj Nilkanthe:
This is working
Basavraj Nilkanthe:
kubectl top pods -A --sort-by=‘cpu’ | head -2 | awk ‘{print $1}’
NAMESPACE
kube-system
Basavraj Nilkanthe:
kubectl top pods -A --sort-by='cpu' | head -2 | awk '{print $2}'
NAME
kube-apiserver-controlplane
Basavraj Nilkanthe:
works
Basavraj Nilkanthe:
root@controlplane:~# kubectl top pods -A --sort-by='cpu'
NAMESPACE NAME CPU(cores) MEMORY(bytes)
kube-system kube-apiserver-controlplane 95m 252Mi
kube-system kube-controller-manager-controlplane 32m 57Mi
kube-system etcd-controlplane 29m 39Mi
kube-system coredns-74ff55c5b-5zvsc 10m 18Mi
kube-system kube-scheduler-controlplane 6m 24Mi
kube-system coredns-74ff55c5b-2bf7f 5m 18Mi
kube-system kube-flannel-ds-ht8rx 3m 35Mi
kube-system metrics-server-774b56d589-9fv9r 2m 20Mi
kube-system kube-proxy-qh49c 1m 34Mi
default red-c898cbdc6-bhxcr 0m 1Mi
blue blue-app 0m 2Mi
default red-c898cbdc6-z5vld 0m 1Mi
blue dark-blue-app 0m 1Mi
Basavraj Nilkanthe:
seems specific version of k8s doesnt support
Basavraj Nilkanthe:
it might be 1.18
Basavraj Nilkanthe:
I have tested same command on 1.18
Basavraj Nilkanthe:
it doesnt worked
Basavraj Nilkanthe:
so no need to worry as exam will be on 1.20
Basavraj Nilkanthe:
where I have tested successfully