Skip to content

Allow omitting the CPU limit (make container resource limits optional) #188

Description

@davidxia

Summary

There is currently no supported way to deploy the DaemonSet without a CPU
limit. CPU limits cause CFS throttling that degrades performance even when CPU
is available, so many operators prefer to set CPU/memory requests but omit the
CPU limit entirely. The chart does not allow this.

Current behavior

templates/daemonset.yaml renders the limit unconditionally:

resources:
  requests:
    memory: {{ .Values.image.request_mem }}
    cpu: {{ .Values.image.request_cpu }}
  limits:
    memory: {{ .Values.image.limit_mem }}
    cpu: {{ .Values.image.limit_cpu }}

and values.schema.json requires image.limit_cpu to be a present string.

This leaves no way to omit the CPU limit:

  • image.limit_cpu: "" renders cpu: "", which Kubernetes interprets as a
    limit of 0. The DaemonSet is then rejected because the request exceeds it:

    DaemonSet.apps "core-dump-handler" is invalid:
    spec.template.spec.containers[0].resources.requests:
    Invalid value: "250m": must be less than or equal to cpu limit of 0
    
  • image.limit_cpu: null (or omitting it) fails schema validation:

    values don't meet the specifications of the schema(s) ...
    - at '/image': missing property 'limit_cpu'
    

Verified against chart v9.0.0 and the current template on main.

Requested change

Allow each resource field to be omitted when unset, e.g. wrap the limit lines in
a conditional:

  {{- if or .Values.image.limit_mem .Values.image.limit_cpu }}
  limits:
    {{- with .Values.image.limit_mem }}
    memory: {{ . }}
    {{- end }}
    {{- with .Values.image.limit_cpu }}
    cpu: {{ . }}
    {{- end }}
  {{- end }}

and relax values.schema.json so limit_cpu (and ideally the other resource
fields) may be null/absent. A common alternative is to expose a single
resources: map rendered with {{- toYaml .Values.resources | nindent }}, which
lets operators specify exactly the requests/limits they want.

This would let users follow the widely recommended practice of setting CPU
requests without a CPU limit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions