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

kubernetes - How to retrieve only the master node name using kubectl? - Stack Overflow

programmeradmin2浏览0评论

I am trying to get the name of the master (control-plane) node in my Kubernetes cluster using kubectl. I want the command to return only the name of the node without any additional information.

I have tried the following command:

kubectl get nodes --selector=node-role.kubernetes.io/master

However, this returns a table with additional details. I would like to extract only the node name.

What is the correct kubectl command to achieve this?

I am trying to get the name of the master (control-plane) node in my Kubernetes cluster using kubectl. I want the command to return only the name of the node without any additional information.

I have tried the following command:

kubectl get nodes --selector=node-role.kubernetes.io/master

However, this returns a table with additional details. I would like to extract only the node name.

What is the correct kubectl command to achieve this?

Share Improve this question asked Mar 18 at 9:41 Fabrice JammesFabrice Jammes 3,2253 gold badges35 silver badges53 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

With kubernetes-v1.31.0, this works:

kubectl get nodes --selector=node-role.kubernetes.io/master= --output=jsonpath='{.items[0].metadata.name}'
发布评论

评论列表(0)

  1. 暂无评论