harryg
harryg

Reputation: 24107

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

I have a container running in a GKE autopilot K8s cluster. I have the following in my deployment manifest (only relevant parts included):

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

So I've requested the minimum resources that GKE autopilot allows for normal pods. Note that I have not specified a limits.

However, having applied the manifest and looking at the yaml I see that it does not match what's in the manifest I applied:

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

Any idea what's going on here? Why has GKE scaled up the resources. This is costing me more money unnecessarily?

Interestingly it was working as intended until recently. This behaviour only seemed to start in the past few days.

Upvotes: 7

Views: 3796

Answers (1)

Dawid Kruk
Dawid Kruk

Reputation: 9905

If the resources that you've requested are following:

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

Then they are not compliant with the minimal amount of resources that GKE Autopilot will assign. Please take a look on the documentation:

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

-- Cloud.google.com: Kubernetes Engine: Docs: Guides: Resource requests in Autopilot: Allowable resource ranges

As you can see the amount of memory you've requested was too small and that's why you saw the following message (and the manifest was modified to increate the requests/limits):

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

To fix that you will need to assign resources that are within the limits of the documentation, I've included in the link above.

Upvotes: 12

Related Questions