Knative: Operator’s Handbook

Assign CPU/memory

Knative uses the regular Kubernetes requests & limits to specify CPU and memory resources to a container.

For example:

apiVersion: serving.knative.dev/v1alpha1
kind: Service
metadata:
  name: hello
spec:
  template:
    spec:
      containers:
      - image: gcr.io/google-samples/hello-app:1.0
        resources:
          requests:
            cpu: 200m
            memory: 512M # container may be killed if reaches this value
          limits:
            cpu: 500m
            memory: 1Gi # container is killed if reaches this value

It's recommended to at least specify requests as it informs Kubernetes the scheduling.

Read this article or this article to understand Kubernetes CPU/memory assignments better.