Closed dmitry-mightydevops closed 2 years ago
I have added the --show-node flag to print the node name in the column output
this took some doing... I have node labels working on my minikube setup but I'm unable to test with multiple nodes so would appreciate some feedback.
I have added --node-label and --pod-label flags they take a single label name and output the label as a new column (see output below)
currently you can't use the sort and match flags with the node-labels and pod-labels though
kubectl-ice status -A --show-node --node-label "minikube.k8s.io/version"
T NAMESPACE NODE PODNAME CONTAINER minikube.k8s.io/version READY STARTED RESTARTS STATE REASON EXIT-CODE SIGNAL AGE
S kube-system minikube coredns-78fcd69978-gtg8c coredns v1.24.0 true true 26 Running - - - 4d9h
S kube-system minikube etcd-minikube etcd v1.24.0 true true 26 Running - - - 4d9h
S kube-system minikube kube-apiserver-minikube kube-apiserver v1.24.0 true true 6 Running - - - 4d9h
S kube-system minikube kube-controller-manager-minikube kube-controller-manager v1.24.0 true true 6 Running - - - 4d9h
S kube-system minikube kube-proxy-4p6q8 kube-proxy v1.24.0 true true 26 Running - - - 4d9h
S kube-system minikube kube-scheduler-minikube kube-scheduler v1.24.0 true true 6 Running - - - 4d9h
S kube-system minikube metrics-server-77c99ccb96-z86xc metrics-server v1.24.0 true true 33 Running - - - 4d9h
S kube-system minikube storage-provisioner storage-provisioner v1.24.0 true true 43 Running - - - 4d9h
$ kubectl-ice status -A --show-node --node-label "beta.kubernetes.io/os" --pod-label "component"
T NAMESPACE NODE PODNAME CONTAINER beta.kubernetes.io/os component READY STARTED RESTARTS STATE REASON EXIT-CODE SIGNAL AGE
S kube-system minikube coredns-78fcd69978-gtg8c coredns linux - true true 26 Running - - - 4d9h
S kube-system minikube etcd-minikube etcd linux etcd true true 26 Running - - - 4d9h
S kube-system minikube kube-apiserver-minikube kube-apiserver linux kube-apiserver true true 6 Running - - - 4d9h
S kube-system minikube kube-controller-manager-minikube kube-controller-manager linux kube-controller-manager true true 6 Running - - - 4d9h
S kube-system minikube kube-proxy-4p6q8 kube-proxy linux - true true 26 Running - - - 4d9h
S kube-system minikube kube-scheduler-minikube kube-scheduler linux kube-scheduler true true 6 Running - - - 4d9h
S kube-system minikube metrics-server-77c99ccb96-z86xc metrics-server linux - true true 33 Running - - - 4d9h
S kube-system minikube storage-provisioner storage-provisioner linux - true true 43 Running - - - 4d9h
$ kubectl-ice status -A --show-node --node-label "beta.kubernetes.io/os" --pod-label "component" --tree --details
NAMESPACE NODE beta.kubernetes.io/os component NAME READY STARTED RESTARTS STATE REASON EXIT-CODE SIGNAL TIMESTAMP MESSAGE
kube-system minikube linux - Pod/coredns-78fcd69978-gtg8c - - 0 Running - - - 2022-05-20 09:40:06 -
kube-system minikube linux - └─Container/coredns true true 26 Running - - - 2022-06-20 08:55:56 -
kube-system minikube linux etcd Pod/etcd-minikube - - 0 Running - - - 2022-06-06 09:10:17 -
kube-system minikube linux etcd └─Container/etcd true true 26 Running - - - 2022-06-20 08:55:50 -
kube-system minikube linux kube-apiserver Pod/kube-apiserver-minikube - - 0 Running - - - 2022-05-23 10:52:33 -
kube-system minikube linux kube-apiserver └─Container/kube-apiserver true true 6 Running - - - 2022-06-20 08:55:50 -
kube-system minikube linux kube-controller-manager Pod/kube-controller-manager-minikube - - 0 Running - - - 2022-06-06 09:11:58 -
kube-system minikube linux kube-controller-manager └─Container/kube-controller-manager true true 6 Running - - - 2022-06-20 08:55:50 -
kube-system minikube linux - Pod/kube-proxy-4p6q8 - - 0 Running - - - 2022-05-20 09:40:06 -
kube-system minikube linux - └─Container/kube-proxy true true 26 Running - - - 2022-06-20 08:55:56 -
kube-system minikube linux kube-scheduler Pod/kube-scheduler-minikube - - 0 Running - - - 2022-06-18 10:25:00 -
kube-system minikube linux kube-scheduler └─Container/kube-scheduler true true 6 Running - - - 2022-06-20 08:55:50 -
kube-system minikube linux - Pod/metrics-server-77c99ccb96-z86xc - - 0 Running - - - 2022-05-20 09:40:17 -
kube-system minikube linux - └─Container/metrics-server true true 33 Running - - - 2022-06-20 08:55:56 -
kube-system minikube linux - Pod/storage-provisioner - - 0 Running - - - 2022-05-20 09:40:06 -
kube-system minikube linux - └─Container/storage-provisioner true true 43 Running - - - 2022-06-20 08:56:38 -
@NimbleArchitect it would be nice to skip "I" containers in the same way you did with cpu/memory output (i.e. -i arg to the cli)
➜ kubectl-ice status --show-node --node-label "workload" --pod-label "app.kubernetes.io/component"
T NODE PODNAME CONTAINER workload app.kubernetes.io/component READY STARTED RESTARTS STATE REASON EXIT-CODE SIGNAL AGE
S ip-10-120-3-53.ec2.internal prod-backend-v1-7bb984f4d4-jk9df backend apps backend true true 0 Running - - - 10h
I ip-10-120-3-53.ec2.internal prod-backend-v1-7bb984f4d4-jk9df install apps backend true - 0 Terminated Completed 0 0 10h
S ip-10-120-3-53.ec2.internal prod-frontend-v1-5696b46985-nv7vd frontend apps frontend true true 0 Running - - - 10h
is that just removing the T column or removing init containers from the table output?
if you just want to remove the init containers from the output you can use --match "T!=I"
which means only output the line if the "T" column does not equal "I" (uppercase i).
edit: the match flag doesn't work correctly atm, I'll work on a fix soon.
didn't work for me
➜ kubectl-ice status --show-node --node-label "workload" --pod-label "app.kubernetes.io/component" --match "T!=I"
T NODE PODNAME CONTAINER workload app.kubernetes.io/component READY STARTED RESTARTS STATE REASON EXIT-CODE SIGNAL AGE
S ip-10-110-4-28.ec2.internal staging-backend-v1-57dd8d95f4-lpnf2 backend apps backend true true 0 Running - - - 11d
I ip-10-110-4-28.ec2.internal staging-backend-v1-57dd8d95f4-lpnf2 get-config-template apps backend true - 0 Terminated Completed 0 0 11d
I ip-10-110-4-28.ec2.internal staging-backend-v1-57dd8d95f4-lpnf2 install apps backend true - 0 Terminated Completed 0 0 11d
so I expect this in outcome to skip terminated init containers:
➜ kubectl-ice status --show-node --node-label "workload" --pod-label "app.kubernetes.io/component" --tree | sed -n '/Terminated/!p'
NODE workload app.kubernetes.io/component NAME READY STARTED RESTARTS STATE REASON EXIT-CODE SIGNAL AGE
ip-10-110-4-28.ec2.internal apps backend Pod/staging-backend-v1-57dd8d95f4-lpnf2 - - 0 Running - - - 11d
ip-10-110-4-28.ec2.internal apps backend └─Container/backend true true 0 Running - - - 11d
@dmitry-mightydevops first let me say a massive thank you for your donation. Thank you I really appreciate it.
Also I have just pushed a large update that fixes the match flag and hides the Type column, if it's needed again -T will show the container type.
let me know if you have any issues or problems
you're very welcome!
confirmed that it worked as expected:
➜ kubectl-ice status --show-node --node-label "workload" --pod-label "app.kubernetes.io/component" --match "STATE!=Terminated"
NODE PODNAME CONTAINER workload app.kubernetes.io/component READY STARTED RESTARTS STATE REASON EXIT-CODE SIGNAL AGE
ip-10-110-4-28.ec2.internal staging-backend-v1-57dd8d95f4-lpnf2 backend apps backend true true 0 Running - - - 17d
it would be nice to include the node name the pod is scheduled on OR the label's value of the node the pod is placed on.
the reason: when I change affinity or nodeSelector (especially in the case of complex affinity/antiaffinity rules) I have to double check that the pod was placed in a correct node. Typically by doing:
Which is kinda time consuming. It would be great if we can
which will output the name of the node and the value of the label
eks.amazonaws.com/nodegroup
associated with the node the pod is placed on. So we will get 2 new columns:current output