Kubernetes API - 在特定节点上获取 Pod [英] Kubernetes API - gets Pods on specific nodes

查看:34
本文介绍了Kubernetes API - 在特定节点上获取 Pod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://kubernetes.io/docs/user-guide/labels/#selecting-sets-of-nodes 看起来可以根据标签选择一定范围的 pod.但就我而言,我想选择一个节点上的所有 pod,但我不想在相应节点上标记每个 pod.

Looking at http://kubernetes.io/docs/user-guide/labels/#selecting-sets-of-nodes it looks to be possible to select a certain range of pods based on labels. But in my case I want to select all the pods on one node but I don't want to label each pod on their corresponding node.

我是否遗漏了文档中的某些内容,还是无法按节点进行选择?如果我这样做:

Am I missing something from the documentation or is it just not possible to select by node? If I do:

kubectl --server="<SERVER>" --namespace=<NS> get pods -o wide | head
    NAME   READY     STATUS             RESTARTS   AGE       NODE

这些标题中的任何一个都可以用作选择器吗?如果是,如何用 kubectl bust 来做最重要的,如何用 API 来做?

Can any of these header be used as selector? If yes how to do it with kubectl bust most importantly, how to do it with the API?

提前致谢

推荐答案

如已接受的答案中所述,PR 现在已合并,您可以按如下方式按节点获取 Pod:

As mentioned in the accepted answer the PR is now merged and you can get pods by node as follows:

kubectl get pods --all-namespaces -o wide --field-selector spec.nodeName=<node>

这篇关于Kubernetes API - 在特定节点上获取 Pod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆