Fargate 将自动增加内存请求增加约 200Mi

Fargate will increase auto increase memory request by about 200Mi

我将 AWS EKS 与 fargate 一起使用,在我的部署中,我将 resources.requests.memory 设置为 512 Mi,但 fargate 节点仍会请求 1Gi。所以我查看了那个 pod 的 prometheus kube 状态,它显示 pod 请求 762 Mi。 因为762-512=250,所以又查了下其他的deployments,发现总是申请内存比我定义的多200米左右。 这是 k8s 问题,还是 fargate 规则?

resources:
limits:
  memory: 512Mi
  cpu: "0.25"
requests:
  memory: 512Mi
  cpu: "0.25"
Annotations:          CapacityProvisioned: 0.25vCPU 1GB
Memory Request: 762 Mi

更新请求到 250 Mi 后:

resources:
limits:
  memory: 500Mi
  cpu: "0.25"
requests:
  memory: 250Mi
  cpu: "0.25"
Annotations:          CapacityProvisioned: 0.25vCPU 0.5GB

我在 Monitoring Amazon EKS on AWS Fargate using Prometheus and Grafana

中找到了解释

The current version of the dashboard doesn’t consider initContainers’ requests. This is because kube-state-metrics doesn’t expose resources requested by initContainers.

The requests metric in the graph will be absent if none of the long-running containers request any resources. The request metric should not be confused with the total CPU and memory the pod has at its disposal. The pod’s CPU and memory is determined by the calculated Fargate configuration of the pod, as explained above.

sum(kube_pod_container_resource_requests{resource="memory"}+262144000)

如果我请求 512 Mi,fargate 节点会为 init 容器再请求 250 Mi, 我的最终内存请求将是 762 Mi。 所以如果我想保持配置的 fargate 容量为 0.5GB,我的请求内存不应大于 262 Mi。

我觉得不合理

额外的 256m 用于 kubelet 和其他守护进程,而不是您的 init 容器。

Fargate adds 256 MB to each pod’s memory reservation for the required Kubernetes components (kubelet, kube-proxy, and containerd).