$ oadm prune <object_type> <options>
Over time, API objects created in OpenShift Enterprise can accumulate in the etcd data store through normal user operations, such as when building and deploying applications.
As an administrator, you can periodically prune older versions of objects from your OpenShift Enterprise instance that are no longer needed. For example, by pruning images you can delete older images and layers that are no longer in use, but are still taking up disk space.
The cli groups prune operations under a common parent command.
$ oadm prune <object_type> <options>
This specifies:
The <object_type>
to perform the action on, such as builds
,
deployments
, or images
.
The <options>
supported to prune that object type.
In order to prune deployments that are no longer required by the system due to age and status, administrators may run the following command:
$ oadm prune deployments [<options>]
Option | Description |
---|---|
|
Indicate that pruning should occur, instead of performing a dry-run. |
|
Prune all deployments whose deployment config no longer exists, status is complete or failed, and replica count is zero. |
|
Per deployment config, keep the last N deployments whose status is complete and
replica count is zero. (default |
|
Per deployment config, keep the last N deployments whose status is failed and
replica count is zero. (default |
|
Do not prune any object that is younger than |
To see what a pruning operation would delete:
$ oadm prune deployments --orphans --keep-complete=5 --keep-failed=1 \ --keep-younger-than=60m
To actually perform the prune operation:
$ oadm prune deployments --orphans --keep-complete=5 --keep-failed=1 \ --keep-younger-than=60m --confirm
In order to prune builds that are no longer required by the system due to age and status, administrators may run the following command:
$ oadm prune builds [<options>]
Option | Description |
---|---|
|
Indicate that pruning should occur, instead of performing a dry-run. |
|
Prune all builds whose build config no longer exists, status is complete, failed, error, or canceled. |
|
Per build config, keep the last N builds whose status is complete. (default
|
|
Per build config, keep the last N builds whose status is failed, error, or
canceled (default |
|
Do not prune any object that is younger than |
To see what a pruning operation would delete:
$ oadm prune builds --orphans --keep-complete=5 --keep-failed=1 \ --keep-younger-than=60m
To actually perform the prune operation:
$ oadm prune builds --orphans --keep-complete=5 --keep-failed=1 \ --keep-younger-than=60m --confirm
In order to prune images that are no longer required by the system due to age and status, administrators may run the following command:
$ oadm prune images [<options>]
Currently, to prune images you must first log in to the cli as a user with an access token. The user must also have the cluster role system:image-pruner or greater (for example, cluster-admin). |
Pruning images removes data from the integrated registry. For this operation to work
properly, ensure your
registry is configured with |
Option | Description |
---|---|
|
The path to a certificate authority file to use when communicating with the OpenShift Enterprise-managed registries. Defaults to the certificate authority data from the current user’s config file. |
|
Indicate that pruning should occur, instead of performing a dry-run. |
|
For each image stream, keep up to at most N image revisions per tag. (default
|
|
Do not prune any image that is younger than |
OpenShift Enterprise uses the following logic to determine which images and layers to prune:
Remove any image "managed by OpenShift Enterprise" (i.e., images with the annotation
openshift.io/image.managed
) that was created at least
--keep-younger-than
minutes ago and is not currently referenced by:
any pod created less than --keep-younger-than
minutes ago.
any image stream created less than --keep-younger-than
minutes ago.
any running pods.
any pending pods.
any replication controllers.
any deployment configurations.
any build configurations.
any builds.
the --keep-tag-revisions
most recent items in
stream.status.tags[].items
.
There is no support for pruning from external registries.
When an image is pruned, all references to the image are removed from all
image streams that have a reference to the image in status.tags
.
Image layers that are no longer referenced by any images are removed as well.
To see what a pruning operation would delete:
$ oadm prune images --keep-tag-revisions=3 --keep-younger-than=60m
To actually perform the prune operation:
$ oadm prune images --keep-tag-revisions=3 --keep-younger-than=60m --confirm