postgres-operator icon indicating copy to clipboard operation
postgres-operator copied to clipboard

Allow setting null resource requests / limits

Open bootc opened this issue 3 years ago β€’ 1 comments

We've removed the required flag for resources in the CRD schema starting from v1.8.0.

Originally posted by @FxKu in https://github.com/zalando/postgres-operator/issues/2028#issuecomment-1234071399

This isn't enough to not have any CPU/memory limits for containers. If the value isn't set in the CRD then the configured default or minimum value takes effect. If those are set to 0 then Kubernetes can't create pods because the limit would be lower than the requests.

We need some way of not setting a CPU limit at all in order to avoid unnecessary throttling. Please see https://home.robusta.dev/blog/stop-using-cpu-limits/ for a discussion about this.

bootc avatar Sep 21 '22 23:09 bootc

In our K8s setup CPU limits are ignored πŸ˜ƒ The operator should indeed allow to not define any resources when defaults are 0. Or we just remove the CPU limit default.

FxKu avatar Sep 27 '22 10:09 FxKu

Yeah, this is a big problem. CPU limits cause throttling, and we can't unset them.

snarlysodboxer avatar Dec 07 '22 23:12 snarlysodboxer

Is there any update? Also had issues with this setting the last days.

dcardellino avatar Jan 24 '23 13:01 dcardellino

https://opensource.zalando.com/postgres-operator/docs/reference/operator_parameters.html#kubernetes-resource-requests

default_cpu_limit CPU limits for the Postgres containers, unless overridden by cluster-specific settings. The default is 1.

So, if I set the cpu request > 1 and no set cpu limit, I get an error

  Warning  FailedCreate      78s (x15 over 2m40s)  statefulset-controller  create Pod pg-test-0 in StatefulSet pg-test failed error: Pod "pg-test-0" is invalid: spec.containers[0].resources.requests: Invalid value: "8": must be less than or equal to cpu limit
    Limits:
      cpu:     1
      memory:  16Gi
    Requests:
      cpu:     8
      memory:  16Gi

yolkov avatar Aug 03 '23 16:08 yolkov

@yolkov Yes, this is another manifestation of the same problem. The problem is that if you don't set CPU limits in your postgresql object, the operator will default the CPU limit to "1", which is less than your "8" requested, which is not allowed because it doesn't make sense.

snarlysodboxer avatar Sep 06 '23 03:09 snarlysodboxer

I just found another related issue. If we don't set cpu limits at all (in our case we don't use CPU limits at least for most apps, we only use memory limits) by default it's set to:

          limits:
            cpu: "1"
            memory: 500Mi
          requests:
            cpu: 100m
            memory: 100Mi 

We solved that by setting cpu limits to 1 but if it's not set then it should not be used at all now we have this:

          limits:
            cpu: "1"
            memory: 500Mi
          requests:
            cpu: "1"
            memory: 100Mi 

version: v1.11.0

mesiu84 avatar Apr 02 '24 09:04 mesiu84

So the issue is not resolved. I have version 1.11.0. And either I try to set β€˜0’, or don’t set the limit, it still makes me β€œ1”

antverpp avatar Apr 24 '24 16:04 antverpp