求大神们指导,kubernetes 有没有提供集群中调度的节点的API?API的调用方式?


如果不指定节点, kubernetes每次拉docker容器时会根据调度自动分配一个节点拉容器, 请问有没有可以返回这个节点的API?
已邀请:

darker - 80后IT男

赞同来自:


真像你那样做就本末倒置了。

徐新坤 - 京东商城-TIG-JDOS团队

赞同来自:


根据pod的name,可以直接从api中获取pod的相关信息。(http://kubernetes.io/third_par ... cedPod)

返回的结果类似于这样

<pre>
{
"kind": "Pod",
"apiVersion": "v1",
"metadata": {
"name": "mysql-controller-liy2x",
"generateName": "mysql-controller-",
"namespace": "default",
"selfLink": "/api/v1/namespaces/default/pods/mysql-controller-liy2x",
"uid": "24c7a488-b93c-11e5-b87b-fa163eb417f5",
"resourceVersion": "588627",
"creationTimestamp": "2016-01-12T14:52:47Z",
"labels": {
"name": "mysql",
"role": "master"
},
"annotations": {
"kubernetes.io/created-by": "{\"kind\":\"SerializedReference\",\"apiVersion\":\"v1\",\"reference\":{\"kind\":\"ReplicationController\",\"namespace\":\"default\",\"name\":\"mysql-controller\",\"uid\":\"13588e34-b5ed-11e5-b87b-fa163eb417f5\",\"apiVersion\":\"v1\",\"resourceVersion\":\"588604\"}}"
}
},
"spec": {
"containers": <span>,
"restartPolicy": "Always",
"dnsPolicy": "ClusterFirst",
"nodeName": "k8-zm2nu7qqpn-0-tvmjzr6rwf53-kube-minion-vl5v5vrm4z7"
},
"status": {
"phase": "Running",
"conditions": ,
"hostIP": "172.18.141.195",
"podIP": "10.100.25.15",
"startTime": "2016-01-12T14:52:46Z",
"containerStatuses":
}
}
</pre>

其中的nodeName就是节点名称。如果想获取节点的详细信息,可以再通过api查看node的信息。

要回复问题请先登录注册