GKE autopilot 根据资源请求扩展了我的容器资源

GKE autopilot has scaled up my container resources contary to resource requests

我在 GKE autopilot K8s 集群中有一个容器 运行。我的部署清单中有以下内容(仅包括相关部分):

apiVersion: apps/v1
kind: Deployment
spec:
  template:
    spec:
      containers:
          resources:
            requests:
              memory: "250Mi"
              cpu: "512m"

所以我请求了 GKE autopilot allows for normal pods 的最少资源。请注意,我没有指定 limits.

但是,在应用清单并查看 yaml 后,我发现它与我应用的清单中的内容不匹配:

    resources:
      limits:
        cpu: 750m
        ephemeral-storage: 1Gi
        memory: 768Mi
      requests:
        cpu: 750m
        ephemeral-storage: 1Gi
        memory: 768Mi

知道这里发生了什么吗?为什么 GKE 扩展了资源。这是在不必要地多花我钱吗?

有趣的是,它直到最近才按预期工作。这种行为似乎是最近几天才开始的。

如果您请求的资源如下:

              memory: "250Mi"
              cpu: "512m"

然后他们不符合 GKE Autopilot 将分配的最小资源量。请查看文档:

NAME Normal Pods
CPU 250 mCPU
Memory 512 MiB
Ephemeral storage 10 MiB (per container)

-- Cloud.google.com: Kubernetes Engine: Docs: Concepts: Autopilot overview: Allowable resource ranges

如您所见,您请求的内存量太小,这就是您看到以下消息的原因(清单已修改以创建 requests/limits):

Warning: Autopilot increased resource requests for Deployment default/XYZ to meet requirements. See http://g.co/gke/autopilot-resources.

为了解决这个问题,您需要在文档的限制范围内分配资源,我已经在上面的 link 中包含了。