Configuring gradual rollout of traffic to Revisions

If your traffic configuration points to a Configuration target instead of a Revision target, when a new Revision is created and ready, 100% of the traffic from the target is immediately shifted to the new Revision.

This might make the request queue too long, either at the QP or Activator, and cause the requests to expire or be rejected by the QP.

Knative provides a rollout-duration parameter, which can be used to gradually shift traffic to the latest Revision, preventing requests from being queued or rejected. Affected Configuration targets are rolled out to 1% of traffic first, and then in equal incremental steps for the rest of the assigned traffic.

Note

rollout-duration is time-based, and does not interact with the autoscaling subsystem.

This feature is available for tagged and untagged traffic targets, configured for either Knative Services or Routes without a service.

Procedure

You can configure the rollout-duration parameter by modifying the config-network ConfigMap, or by using the Operator.

ConfigMap configuration

  1. apiVersion: v1
  2. kind: ConfigMap
  3. metadata:
  4. name: config-network
  5. namespace: knative-serving
  6. data:
  7. rolloutDuration: "380s" # Value in seconds.

Operator configuration

  1. apiVersion: operator.knative.dev/v1alpha1
  2. kind: KnativeServing
  3. metadata:
  4. name: knative-serving
  5. spec:
  6. config:
  7. network:
  8. rolloutDuration: "380s"

Route status updates

During a rollout, the system updates the Route and Knative Service status conditions. Both the traffic and conditions status parameters are affected.

For example, for the following traffic configuration:

  1. apiVersion: serving.knative.dev/v1
  2. kind: Service
  3. metadata:
  4. ...
  5. spec:
  6. ...
  7. traffic:
  8. - percent: 55
  9. configurationName: config # Pinned to latest ready Revision
  10. - percent: 45
  11. revisionName: config-00005 # Pinned to a specific Revision.

Initially 1% of the traffic is rolled out to the Revisions:

  1. apiVersion: serving.knative.dev/v1
  2. kind: Service
  3. metadata:
  4. ...
  5. spec:
  6. ...
  7. traffic:
  8. - percent: 54
  9. revisionName: config-00008
  10. - percent: 1
  11. revisionName: config-00009
  12. - percent: 45
  13. revisionName: config-00005 # Pinned to a specific Revision.

Then the rest of the traffic is rolled out in increments of 18%:

  1. apiVersion: serving.knative.dev/v1
  2. kind: Service
  3. metadata:
  4. ...
  5. spec:
  6. ...
  7. traffic:
  8. - percent: 36
  9. revisionName: config-00008
  10. - percent: 19
  11. revisionName: config-00009
  12. - percent: 45
  13. revisionName: config-00005 # Pinned to a specific Revision.

The rollout continues until the target traffic configuration is reached:

  1. apiVersion: serving.knative.dev/v1
  2. kind: Service
  3. metadata:
  4. ...
  5. spec:
  6. ...
  7. traffic:
  8. - percent: 55
  9. revisionName: config-00009
  10. - percent: 45
  11. revisionName: config-00005 # Pinned to a specific Revision.

During the rollout, the Route and Knative Service status conditions are as follows:

  1. apiVersion: serving.knative.dev/v1
  2. kind: Service
  3. metadata:
  4. ...
  5. spec:
  6. ...
  7. status:
  8. conditions:
  9. ...
  10. - lastTransitionTime: "..."
  11. message: A gradual rollout of the latest revision(s) is in progress.
  12. reason: RolloutInProgress
  13. status: Unknown
  14. type: Ready

Multiple rollouts

If a new revision is created while a rollout is in progress, the system begins to shift traffic immediately to the newest Revision, and drains the incomplete rollouts from newest to oldest.