0

How to list the current deployments running in Kubernetes with custom columns displayed as mentioned below:

DEPLOYMENT CONTAINER_IMAGE READY_REPLICAS NAMESPACE

The data should be sorted by the increasing order of the deployment name.

Yash Bindlish
  • 560
  • 5
  • 15

2 Answers2

1

Look a the -o custom-columns feature. https://kubernetes.io/docs/reference/kubectl/overview/#custom-columns shows the basics. The hard one would be container_image, since a pod can contain more than one, but assuming you just want the first, something like .spec.template.containers[0].image? Give a shot and see how it goes.

coderanger
  • 52,400
  • 4
  • 52
  • 75
  • thank you for sharing the link. Yes, hardest part was something which i struggled a lot. in end able to work out with the query as kubectl get deployments -o custom-columns=DEPLOYMENT:.metadata.name,CONTAINER_IMAGE:..image,READY_REPLICAS:..replicas,NAMESPACE:..namespace – Yash Bindlish Mar 27 '20 at 09:08
0

Command to get the custom columns as per the question:

Kubectl get deployments -o custom-columns=DEPLOYMENT:.metadata.name,CONTAINER_IMAGE:..image,READY_REPLICAS:..replicas,NAMESPACE:..namespace

Yash Bindlish
  • 560
  • 5
  • 15