Administrator configuration options

If you have cluster administrator permissions for your Knative installation, you can modify ConfigMaps to change the global default configuration options for Revisions of Knative Services on the cluster.

Garbage collection

When Revisions of a Knative Service are inactive, they are automatically cleaned up and cluster resources are reclaimed after a set time period. This is known as garbage collection.

You can configure garbage collection parameters a specific Revision if you are a developer. You can also configure default, cluster-wide garbage collection parameters for all the Revisions of all the Services on a cluster if you have cluster administrator permissions.

You can set cluster-wide garbage collection configurations for your cluster by modifying the config-gc ConfigMap.

The following garbage collection settings can be modified:

NameDescription
retain-since-create-timeThe time that must have elapsed since a Revision was created before a Revision is considered for garbage collection.
retain-since-last-active-timeThe time that must have elapsed since a Revision was last active before a Revision is considered for garbage collection.
min-non-active-revisionsThe minimum number of inactive Revisions to retain.
max-non-active-revisionsThe maximum number of inactive Revisions to retain.

Revisions are always retained if they belong to any one of the following categories:

  • The Revision is active and is being reference by a Route.
  • The Revision was created within the time specified by the retain-since-create-time setting.
  • The Revision was last referenced by a Route within the time specified by the retain-since-last-active-time setting.
  • There are fewer existing Revisions than the number specified by the min-non-active-revisions setting.

Examples

  • Immediately clean up any inactive Revisions:

    1. apiVersion: v1
    2. kind: ConfigMap
    3. metadata:
    4. name: config-gc
    5. namespace: knative-serving
    6. data:
    7. min-non-active-revisions: "0"
    8. max-non-active-revisions: "0"
    9. retain-since-create-time: "disabled"
    10. retain-since-last-active-time: "disabled"
    11. ...
  • Retain the last ten inactive revisions:

    1. apiVersion: v1
    2. kind: ConfigMap
    3. metadata:
    4. name: config-gc
    5. namespace: knative-serving
    6. data:
    7. retain-since-create-time: "disabled"
    8. retain-since-last-active-time: "disabled"
    9. max-non-active-revisions: "10"
    10. ...
  • Disable garbage collection on the cluster:

    1. apiVersion: v1
    2. kind: ConfigMap
    3. metadata:
    4. name: config-gc
    5. namespace: knative-serving
    6. data:
    7. retain-since-create-time: "disabled"
    8. retain-since-last-active-time: "disabled"
    9. max-non-active-revisions: "disabled"
    10. ...