Skip to content
This repository was archived by the owner on Jun 24, 2020. It is now read-only.

Conversation

@jcrossley3
Copy link
Contributor

@jcrossley3 jcrossley3 commented Mar 14, 2020

Fixes #161
Related #302 #329

Proposed Changes

  • Introduce resources field in the KnativeServing spec, which is a list of ResourceRequirementsOverrides, enabling users to override the resources consumed by any of the containers listed in the embedded manifest.

This exposes a "knob" in the KnativeServing CR that would enable users to workaround issues like knative/serving#7195

apiVersion: operator.knative.dev/v1alpha1
kind: KnativeServing
metadata:
  name: knative-serving
spec:
  resources:
  - container: webhook
    requests:
      cpu: 20m
      memory: 20Mi
    limits:
      cpu: 400m
      memory: 800Mi

Release Note

Resource limits for any knative deployment containers can now be configured in the `KnativeServing` custom resource using the new `resources` field.

@googlebot googlebot added the cla: yes Author(s) signed a CLA. label Mar 14, 2020
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jcrossley3

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcrossley3: 1 warning.

Details

In response to this:

Fixes #161
Related #302 #329

Proposed Changes

  • Introduce resources field in the KnativeServing spec, which is a mapping of deployment names to a list of ResourceRequirements
  • This will override the containers' resources specified in the deployment's spec
  • If not specified in KnativeServing, the resource requests will be removed from the deployment's spec.

The effect of this is that all of the resource limits specified in the embedded manifest will be removed by default. This is arguably the correct behavior anyway, as the limits are platform-specific and often lead to OOMErrors that frustrate new users.

To prevent their removal, the following KnativeServing example would be required:

apiVersion: operator.knative.dev/v1alpha1
kind: KnativeServing
metadata:
 name: knative-serving
spec:
 resources:
   activator:
   - requests:
       cpu: 300m
       memory: 60Mi
     limits:
       cpu: 1000m
       memory: 600Mi
   autoscaler:
   - requests:
       cpu: 30m
       memory: 40Mi
     limits:
       cpu: 300m
       memory: 400Mi
   controller:
   - requests:
       cpu: 100m
       memory: 100Mi
     limits:
       cpu: 1000m
       memory: 1000Mi
   webhook:
   - requests:
       cpu: 20m
       memory: 20Mi
     limits:
       cpu: 200m
       memory: 200Mi
   autoscaler-hpa:
   - requests:
       cpu: 30m
       memory: 40Mi
     limits:
       cpu: 300m
       memory: 400Mi
   networking-istio:
   - requests:
       cpu: 30m
       memory: 40Mi
     limits:
       cpu: 300m
       memory: 400Mi

Release Note

By default, no resource limits will be specified for any knative deployment containers. You must specify them in the `KnativeServing` custom resource using the new `resources` field.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

It's a map of deployment names to a []v1.ResourceRequirement. The
array corresponds to the order of the containers in the deployment
spec.
Added a dummy container to the webhook just to show that capability,
even if yet unused
This removes any assumption of container order in the deploy spec,
with the minor trade-off of container names expected to be unique
within the manifest.
@markusthoemmes
Copy link
Contributor

By default, no resource limits will be specified for any knative deployment containers.

I think this bit should be discussed and implemented upstream first 🤔. It doesn't feel right to have the defaults of both installation modes differ that vastly.

Copy link
Contributor

@markusthoemmes markusthoemmes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM modulo the requests thing.

@jcrossley3
Copy link
Contributor Author

I'm going to change the logic to not delete the upstream config, by default, so...
/hold

We now merge the resource overrides with the existing specs, so that
the upstream defaults remain intact if there are no overrides in the
KnativeServing CR.

We also converted the map to an array to abide by k8s conventions.
@knative-metrics-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-knative-serving-operator-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/knativeserving/common/resources.go Do not exist 90.9%

@jcrossley3
Copy link
Contributor Author

/hold cancel

@houshengbo
Copy link

/lgtm

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

support to tweak resource limits and requests for knative deployments

7 participants