Yash Bindlish
Yash Bindlish

Reputation: 600

How to get the custom attributes in Kubernetes?

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.

Upvotes: 0

Views: 1658

Answers (2)

Yash Bindlish
Yash Bindlish

Reputation: 600

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

Upvotes: 0

coderanger
coderanger

Reputation: 54247

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.

Upvotes: 1

Related Questions