如果我将ssh转换为Kubernetes节点,如何计算出该节点的UUID,以便查询主API以获取特定于该节点的信息?
到目前为止已经试过了
root 13020 2.5 1.0 410112 41660 ? Ssl Jan25 26:04 /usr/bin/kubelet --logtostderr=true --v=0 --api_servers=http://10.32.140.181:8080 --address=0.0.0.0 --port=10250 --allow_privileged=false --maximum-dead-containers=1 --max-pods=14
[achang@p3dlwsbkn50d51 ~]$ curl -Gs http://localhost:10255/pods/
404 page not found发布于 2016-01-26 19:28:22
有许多不同的it和名称绑定到kubernetes节点,这取决于您要寻找的是什么。如果要查询API服务器中的节点信息,则很可能要查找节点名称。节点名通常与主机名相同,但如果不是最简单的方法,则是查询kubelet以获取运行的豆荚,并查看它们在哪个节点上运行:
$ curl -Gs http://localhost:10255/pods/ | grep -o '"nodeName":"[^"]*"' | head -n 1
"nodeName":"e2e-test-stclair-minion-8o3b"通过查询节点规范可以找到其他ID:
$ curl -Gs http://localhost:10255/spec/ | grep -oE '(machine_|system_uu|boot_)id":.*'
machine_id": "",
system_uuid": "CB7FAAA0-3A53-5FE4-4285-D33D03FEBA6C",
boot_id": "8b89b8f5-5fbb-4cc0-82e4-7c57ec11f656",最后,可以从API服务器查询externalID和providerID:
$ kubectl get nodes e2e-test-stclair-minion-8o3b -o=jsonpath="externalID:{.spec.externalID}; providerID:{.spec.providerID}"编辑:
如果上述操作失败,并且您可以访问api服务器,则只需查找与所需节点的主机名匹配的节点:
$ NODEHOST="your-host"
$ kubectl get nodes | grep "hostname=$NODEHOST"发布于 2018-04-12 22:53:07
我发现当前的kubernetes节点(我检查minikube,gke节点池)有文件/etc/machine-id,对于每个kubernetes节点,cat /etc/machine-id是唯一的,并且与对应的kubectl get nodes -o json | jq -r .items[].status.nodeInfo.machineID匹配。
因为它不需要API调用,所以我认为这种方式更容易与shell或容器结合。
发布于 2017-03-19 08:39:40
您可以获得节点名,将wide output选项添加到kubectl:
// List all pods in plain-text output format and includes additional information (such as node name). $ kubectl get pods -o wide
更多选项:https://kubernetes.io/docs/user-guide/kubectl-overview/
https://stackoverflow.com/questions/35008011
复制相似问题