最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

View Kubernetes deployments - Stack Overflow

programmeradmin4浏览0评论

I would like to view Kubernetes deployments in the following format. Do I need to run a Json query.

kubectl get deployments -n admin2406 -o wide

I am quite new to Kubernetes. I couldnt find this format structure even on the Kubernetes.io documentation.

I would like to view Kubernetes deployments in the following format. Do I need to run a Json query.

kubectl get deployments -n admin2406 -o wide

I am quite new to Kubernetes. I couldnt find this format structure even on the Kubernetes.io documentation.

Share Improve this question edited Mar 17 at 16:38 Mr. Polywhirl 48.9k12 gold badges93 silver badges145 bronze badges asked Mar 17 at 16:23 jalsamanjalsaman 1 1
  • Yes, you can do this with the jsonpath output format, but any regular person will just pipe the output to jq. – Botje Commented Mar 17 at 17:13
Add a comment  | 

1 Answer 1

Reset to default 0

You can use jsonpath but custom-columns will is much simpler. Because you don't need to deal with handling foreach over all elements. In jsonpath you need to handle all pods in k get pods, via a kind of loop structure. Also remembering jsonpath syntax is not that easy. In custom-columns you think only for single row. Also It handles multiple items in a cell (like .containers[*].name) and no item in a cell <none> for you.

It's syntax is like below:


COLUMN_NAME     :       path.from.single.item

Examples:

NAMESPACE:.metadata.namespace

Name:.metadata.name

ContainerNames:.containers[*].name

...

To find what you need to select start with investigating fields:k get deployment deployment-name -o yaml you can give multiple columns via adding commas.

For sorting give the jsonpath what you want to sort. There's only ascending sort in kubectl.

Below is the command you need.


k get deployment --sort-by=.metadata.name -o custom-columns=DEPLOYMENT:.metadata.name,CONTAINER_IMAGE:.spec.template.spec.containers[*].image,READY_REPLICAS:.status.readyReplicas,NAMESPACE:.metadata.namespace

发布评论

评论列表(0)

  1. 暂无评论