// Module included in the following assemblies:
//
// * applications/pruning-objects.adoc

[id="pruning-deployments_{context}"]
= Pruning deployments

In order to prune deployments that are no longer required by the system due to
age and status, administrators can run the following command:

[source,terminal]
----
$ oc adm prune deployments [<options>]
----

.Prune deployments CLI configuration options
[cols="4,8",options="header"]
|===

|Option |Description

.^|`--confirm`
|Indicate that pruning should occur, instead of performing a dry-run.

.^|`--orphans`
|Prune all deployments that no longer have a DeploymentConfig, has status
is `Complete` or `Failed`, and has a replica count of zero.

.^|`--keep-complete=<N>`
|Per DeploymentConfig, keep the last `N` deployments that have a status
of `Complete` and replica count of zero. (default `5`)

.^|`--keep-failed=<N>`
|Per  DeploymentConfig, keep the last `N` deployments that have a status
of `Failed` and replica count of zero. (default `1`)

.^|`--keep-younger-than=<duration>`
|Do not prune any object that is younger than `<duration>` relative to the
current time. (default `60m`) Valid units of measurement include nanoseconds
(`ns`), microseconds (`us`), milliseconds (`ms`), seconds (`s`), minutes (`m`),
and hours (`h`).
|===

To see what a pruning operation would delete:

[source,terminal]
----
$ oc adm prune deployments --orphans --keep-complete=5 --keep-failed=1 \
    --keep-younger-than=60m
----

To actually perform the prune operation:

[source,terminal]
----
$ oc adm prune deployments --orphans --keep-complete=5 --keep-failed=1 \
    --keep-younger-than=60m --confirm
----
