Skip to content

Admission webhook should not reject workloads with only resource limits set #4802

Closed
@nettoclaudio

Description

Report

I'm unable to create/update ScaleObjects with either CPU; memory; or both scalers, if the underlying workload assigns only resource limits and does not set any requests.

Expected Behavior

Based on Kubernetes documentation (I brought the quote below from here), users can assign only resource limits to their containers, so the ScaledObject admission webhook should also consider the resource limits during workload resources validation.

Note: If you specify a limit for a resource, but do not specify any request, and no admission-time mechanism has applied a default request for that resource, then Kubernetes copies the limit you specified and uses it as the requested value for the resource.

Actual Behavior

Workloads that only set resource limits are rejected by the admission webhook.

Steps to Reproduce the Problem

  1. Create a Deployment that assigns only resource limits (e.g CPU limits):
# Filename: deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
spec:
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
      - name: echo-server
        image: jmalloc/echo-server:latest
        resources:
          limits:
            cpu: 500m
kubectl apply -f ./deploy.yaml
  1. Create a ScaledObject with CPU scaler defined and points to the above Deployment:
# Filename: scaledobject.yaml
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
  name: my-app-so
spec:
  maxReplicaCount: 5
  minReplicaCount: 1
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: my-app
  triggers:
  - metadata:
      value: "80"
    metricType: Utilization
    type: cpu
kubectl apply -f ./scaledobject.yaml
  1. Got the message from Kubernetes API Server:
admission webhook \"vscaledobject.kb.io\" denied the request: the scaledobject has a cpu trigger but the container echo-server doesn't have the cpu request defined

Logs from KEDA operator

No response

KEDA Version

2.11.1

Kubernetes Version

None

Platform

Any

Scaler Details

CPU, memory

Anything else?

No response

Metadata

Assignees

Labels

bugSomething isn't workinghelp wantedLooking for support from community

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions