如何计算Kubernetes集群的节点可分配资源? [英] How to calculate Node Allocatable Resources for Kubernetes cluster?

查看:410
本文介绍了如何计算Kubernetes集群的节点可分配资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个集群,其中的节点资源不足,导致运行缓慢和过量提交问题.这迫使我们频繁地重新启动节点.我们计划实施节点可分配资源策略,以在系统,kubelet和应用程序容器之间分配可用的CPU,内存和临时存储.

We have a cluster where nodes are out of resources leading to slowness and over-committing issues. This is forcing us to restart the nodes frequently. We are planning to enforce a node allocatable resource policy to split the available CPU, Memory and Ephemeral Storage between system, kubelet, and application pods.

在可分配资源计算的一些准则中找到问题,请此处 .

Came across some guidelines on allocatable resource calculation here.

它没有指定系统资源和kubelet资源之间的分配量.另外,我们正在进行开放式上班,因此不确定其中有多少适用.

It does not specify how much is the split between system and kubelet resources. Also, we are on open shift and so not sure how much of this is applicable.

推荐答案

正如您所提到的,您正在使用OpenShift,而您提供的文档则来自GCP.默认要求,参数可能会因云提供商的规范而有所不同.

As you mentioned you are using OpenShift and docs you provided are from GCP. Default requirements, parameters might be differnt due to Cloud Provider specs.

很遗憾,我不是OpenShift用户,但是您可以在操作系统中找到文档:

Unfortunately I am not OpenShift user, but you can find in OS documentation that:

为节点组件保留的资源基于两个节点设置:kube-reservedsystem-reserved.

Resources reserved for node components are based on two node settings: kube-reserved and system-reserved.

您可以在一组节点配置文件(默认为/etc/origin/node/node-config.yaml 文件)的kubeletArguments部分中进行设置(例如, cpu = 200m,内存= 512Mi).

You can set these in the kubeletArguments section of the node configuration file (the /etc/origin/node/node-config.yaml file by default) using a set of = pairs (e.g., cpu=200m,memory=512Mi).

如何计算分配的资源?

根据以下公式计算资源的分配量:

An allocated amount of a resource is computed based on the following formula:

[Allocatable] = [Node Capacity] - [kube-reserved] - [system-reserved]

如果[Allocatable]为负,则设置为0.

If [Allocatable] is negative, it is set to 0.

请检查以下OpenShift文档:分配节点资源容量管理

Please check below OpenShift docs: Allocating node resources, Capacity management, Cluster Limits, Resource Limits

许多因素取决于您要使用什么类型的豆荚/图像.有些图像可能需要0.1 CPU,但其他图像可能需要1 CPU才能启动.

Many factors depends on what exactly pods/images you want to use. Some images might requested 0.1 CPU but others might need 1CPU to start.

您可以通过创建配额并将其设置为Pod来对其进行限制. 请求和限制.

You can limit it by create a Quota, set Pod requests and limits.

请记住,您始终可以在Containers.containerName.Requests下检查每个Pod中的当前Requests/Limits:

Please keep in mind that you can always check current Requests/Limits in each Pod, under the Containers.containerName.Requests:

$ os describe pod <pod-name>

或请求的资源/节点上的限制

Or requested resources / limits on node

$ os describe node <node-name>

在此描述的底部,您应该获得所有吊舱的要求和限制

On the bottom of this description you should get All pods reqyest and limits

Non-terminated Pods:         (6 in total)
  Namespace                  Name                                              CPU Requests  CPU Limits  Memory Requests  Memory Limits  AGE
  ---------                  ----                                              ------------  ----------  ---------------  -------------  ---
  default                    nginx-7cdbd8cdc9-b94r9                            100m (10%)    0 (0%)      0 (0%)           0 (0%)         6m2s
  default                    nginx-7cdbd8cdc9-nlsw7                            100m (10%)    0 (0%)      0 (0%)           0 (0%)         6m2s
  kube-system                fluentd-gcp-v3.2.0-lwnqn                          100m (10%)    1 (106%)    200Mi (7%)       500Mi (18%)    5h22m
  kube-system                kube-proxy-gke-stc1-default-pool-094e5c74-4dzj    100m (10%)    0 (0%)      0 (0%)           0 (0%)         5h22m
  kube-system                prometheus-to-sd-lbj57                            1m (0%)       3m (0%)     20Mi (0%)        20Mi (0%)      5h22m
  kube-system                traefik-749d86f748-frs7q                          0 (0%)        0 (0%)      0 (0%)           0 (0%)         158m
Allocated resources:
  (Total limits may be over 100 percent, i.e., overcommitted.)
  Resource                   Requests    Limits
  --------                   --------    ------
  cpu                        401m (42%)  1003m (106%)
  memory                     220Mi (8%)  520Mi (19%)
  ephemeral-storage          0 (0%)      0 (0%)
  attachable-volumes-gce-pd  0           0

希望这会有所帮助.

这篇关于如何计算Kubernetes集群的节点可分配资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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