How to adjust the output of kubectl get pods in kubernetes to watch pods status

S Andrew

I have a kubernetes cluster perfectly working fine. I use below command to get the status of all the pods running in my namespace dataspace

kubectl get pods -n dataspace -o wide | sort -k7

Above command gives me the output with below columns.

NAME               READY     STATUS              RESTARTS   AGE       IP            NODE
deployment-qw3ed   3/3       Running             3          3d        10.38.0.10    MACHINE01

Can we adjust above command so that the output looks like below. NODE column should come after the STATUS:

NAME               READY     STATUS     NODE         RESTARTS   AGE       IP            
deployment-qw3ed   3/3       Running    MACHINE01    3          3d        10.38.0.10    
Ryan Dawson

You can re-arrange the output with awk which loses the pretty column separation but you can then make it pretty again with column:

kubectl get pods -n dataspace -o wide | sort -k7 | awk '{ print $1, $2, $3, $7, $4, $5, $6}' | column -t

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to parse json format output of : kubectl get pods using jsonpath

kubectl get pods ErrImagePull

How to get status of a particular pod or container : kubectl get pods using jsonpath

Kubectl get pods that have ready 1/1 and status running

kubectl get pods shows CrashLoopBackoff

kubectl get pods: Field Selectors

How to get history of Pods run on Kubernetes Node?

How to get the traffic between pods in Kubernetes

How to get number of pods (available or terminating) in kubernetes?

Kubernetes Pods status is always pending

Kubernetes kubectl shows pods restarts as zero but pods age has changed

Kubernetes/kubectl: unable to connect to a server to handle "pods"

Kubectl command to list pods of a deployment in Kubernetes

display failed pods from kubectl output

Kubectl get pods does not return control plane pods

Get logs of Kubernetes pods in a loop

kubectl get pods by container environment variable

Why does `kubectl get pods` suddenly fail?

kubectl - get names of pods with specific label

kubectl get services with count of actively running pods

Script to continuously follow kubectl get pods

For what reasons kubectl get pods fail

Get pods in Kubernetes where all containers are "ready" in one line using kubectl

Debugging kubernetes pods in Completed status forever but not ready

how to use Kubernetes DNS for pods?

How to identify static pods via kubectl command?

How can I view pods with kubectl and filter based on having a status of ImagePullBackOff?

How to get CPU Utilization ,Memory Utilization of namespaces,pods ,services in kubernetes?

How to get log and describe of pods in kubernetes by python client