gpt4 book ai didi

kubernetes - 每个节点的CPU/内存请求和限制

转载 作者:行者123 更新时间:2023-12-02 12:06:49 26 4
gpt4 key购买 nike

kubectl describe nodes提供有关请求和资源限制(例如CPU和内存)的信息。但是,api端点api/v1/nodes不提供此信息。

另外,我也可以点击api/v1/pods端点以获取每个Pod的信息,这些信息可以在节点之间累积。但是是否已经有一个kubernetes API端点提供有关cpu /内存请求和每个节点限制的信息?

最佳答案

根据我在文档中找到的内容,负责该工作的端点是Kubernetes API Server。

CPU and memory are each a resource type. A resource type has a base unit. CPU is specified in units of cores, and memory is specified in units of bytes.

CPU and memory are collectively referred to as compute resources, or just resources. Compute resources are measurable quantities that can be requested, allocated, and consumed. They are distinct from API resources. API resources, such as Pods and Services are objects that can be read and modified through the Kubernetes API server.



进一步讲什么是节点:

Unlike pods and services, a node is not inherently created by Kubernetes: it is created externally by cloud providers like Google Compute Engine, or exists in your pool of physical or virtual machines. What this means is that when Kubernetes creates a node, it is really just creating an object that represents the node. After creation, Kubernetes will check whether the node is valid or not. [...] Currently, there are three components that interact with the Kubernetes node interface: node controller, kubelet, and kubectl. [...] The capacity of the node (number of cpus and amount of memory) is part of the node object. Normally, nodes register themselves and report their capacity when creating the node object. If you are doing manual node administration, then you need to set node capacity when adding a node.

The Kubernetes scheduler ensures that there are enough resources for all the pods on a node. It checks that the sum of the requests of containers on the node is no greater than the node capacity. It includes all containers started by the kubelet, but not containers started directly by Docker nor processes not in containers.



编辑:

Alternatively, I could also hit the api/v1/pods endpoint to get this information per pod which I can accumulate across nodes.



这是按其工作顺序的实际说明。

But is there already a kubernetes API endpoint which provides the information pertaining to cpu/memory requests and limits per node? Answer to this question is no, there is not.



不幸的是,没有端点可以直接获取该信息。 Kubectl使用多个请求来显示节点描述。您可以通过 kubectl -v 8 describe nodes检查它们:

运行 kubectl -v=8 describe nodes时,您可以按以下顺序看到GET调用:
/api/v1/nodes?includeUninitialized=true    
/api/v1/nodes/minikube
/api/v1/pods
/api/v1/events?fieldSelector

关于kubernetes - 每个节点的CPU/内存请求和限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51624036/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com