Make cluster ignore CPU requests?

31 views Asked by At

I have a single-node cluster where I would like to ignore any requests for CPU. I am aware that it's usually not the way to go about handling resources but it's necessary in this case. An alternative would be to override any CPU request to a specific value.

How can be this accomplished?

1

There are 1 answers

0
user7610 On

Use a mutating webhook admission controller. Here is configuration for Gatekeeper that rewrites the resource requests on pods to a small amount of CPU and memory. This works even for pods created by deployments, or by OpenShift operators.

apiVersion: operator.gatekeeper.sh/v1alpha1
kind: Gatekeeper
metadata:
  name: gatekeeper
spec:
  mutatingWebhook: Enabled
  validatingWebhook: Disabled
apiVersion: mutations.gatekeeper.sh/v1
kind: Assign
metadata:
  name: relieve-resource-pressure
spec:
  applyTo:
  - groups: [""]
    kinds: ["Pod"]
    versions: ["v1"]
  match:
    scope: Namespaced
    kinds:
      - apiGroups: [ "*" ]
        kinds: [ "Pod" ]
  location: "spec.containers[name:*].resources.requests"
  parameters:
    assign:
      value:
        cpu: "1m"
        memory: "1Mi"

See Gatekeeper docs at https://open-policy-agent.github.io/gatekeeper/website/docs/mutation/