<commit_before>= Pruning Resources
{product-author}
{product-version}
:data-uri:
:icons:
:experimental:
:toc: macro
:toc-title:

toc::[]

== Overview
This topic provides information on CLI operations and syntax to prune old resources
from the server that accumulate over periods of use, but are no longer needed.

== Prune Operations
The CLI groups prune operations under a common parent command.

----
$ oadm prune <resource_type> <options>
----

This specifies:

- The `<resource_type>` to perform the action on, such as `builds`, `deployments`, or `images`.
- The `<options>` supported to prune that resource type.

*Deployments*

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>]
----

.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 whose deployment config no longer exists, status is complete or failed, and replica count is zero.

.^|`--keep-complete=<N>`
|Per deployment config, keep the last N deployments whose status is complete and replica count is zero. (default `5`)

.^|`--keep-failed=<N>`
|Per deployment config, keep the last N deployments whose status is failed and replica count is zero. (default `1`)

.^|`--keep-younger-than=<duration>`
|Do not prune any resource that is younger than `<duration>` relative to the current time. (default `60m`)
|===

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
----

*Builds*

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>]
----

.Prune Builds 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 builds whose build config no longer exists, status is complete, failed, error, or canceled.

.^|`--keep-complete=<N>`
|Per build config, keep the last N builds whose status is complete. (default `5`)

.^|`--keep-failed=<N>`
|Per build config, keep the last N builds whose status is failed, error, or canceled (default `1`)

.^|`--keep-younger-than=<duration>`
|Do not prune any resource that is younger than `<duration>` relative to the current time. (default `60m`)
|===

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
----
====

*Images*

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>]
----

.Prune Images CLI Configuration Options
[cols="4,8",options="header"]
|===

|Option |Description

.^|`--certificate-authority`
|The path to a certificate authority file to use when communicating with the OpenShift-managed registries. Defaults to the certificate authority data from the current user's config file.

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

.^|`--keep-tag-revisions=<N>`
|For each image stream, keep up to at most N image revisions per tag. (default `60m`)

.^|`--keep-younger-than=<duration>`
|Do not prune any image that is younger than `<duration>` relative to the current time. Do not prune any image that is referenced by any other object that is younger than `<duration>` relative to the current time. (default `60m`)
|===

OpenShift uses the following logic to determine which images and layers to prune:

Remove any image managed by OpenShift (see below) 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 configs
- any build configs
- any builds
- the `--keep-tag-revisions` most recent items in stream.status.tags[].items

There is no support for pruning from external registries.

Images "managed by OpenShift" will have the annotation `openshift.io/image.managed`.

When an image is pruned, all references to the image are removed from all ImageStreams having 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
----
<commit_msg>fix formatting: remove errant ‘====’<commit_after>= Pruning Resources
{product-author}
{product-version}
:data-uri:
:icons:
:experimental:
:toc: macro
:toc-title:

toc::[]

== Overview
This topic provides information on CLI operations and syntax to prune old resources
from the server that accumulate over periods of use, but are no longer needed.

== Prune Operations
The CLI groups prune operations under a common parent command.

----
$ oadm prune <resource_type> <options>
----

This specifies:

- The `<resource_type>` to perform the action on, such as `builds`, `deployments`, or `images`.
- The `<options>` supported to prune that resource type.

*Deployments*

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>]
----

.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 whose deployment config no longer exists, status is complete or failed, and replica count is zero.

.^|`--keep-complete=<N>`
|Per deployment config, keep the last N deployments whose status is complete and replica count is zero. (default `5`)

.^|`--keep-failed=<N>`
|Per deployment config, keep the last N deployments whose status is failed and replica count is zero. (default `1`)

.^|`--keep-younger-than=<duration>`
|Do not prune any resource that is younger than `<duration>` relative to the current time. (default `60m`)
|===

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
----

*Builds*

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>]
----

.Prune Builds 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 builds whose build config no longer exists, status is complete, failed, error, or canceled.

.^|`--keep-complete=<N>`
|Per build config, keep the last N builds whose status is complete. (default `5`)

.^|`--keep-failed=<N>`
|Per build config, keep the last N builds whose status is failed, error, or canceled (default `1`)

.^|`--keep-younger-than=<duration>`
|Do not prune any resource that is younger than `<duration>` relative to the current time. (default `60m`)
|===

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
----

*Images*

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>]
----

.Prune Images CLI Configuration Options
[cols="4,8",options="header"]
|===

|Option |Description

.^|`--certificate-authority`
|The path to a certificate authority file to use when communicating with the OpenShift-managed registries. Defaults to the certificate authority data from the current user's config file.

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

.^|`--keep-tag-revisions=<N>`
|For each image stream, keep up to at most N image revisions per tag. (default `60m`)

.^|`--keep-younger-than=<duration>`
|Do not prune any image that is younger than `<duration>` relative to the current time. Do not prune any image that is referenced by any other object that is younger than `<duration>` relative to the current time. (default `60m`)
|===

OpenShift uses the following logic to determine which images and layers to prune:

Remove any image managed by OpenShift (see below) 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 configs
- any build configs
- any builds
- the `--keep-tag-revisions` most recent items in stream.status.tags[].items

There is no support for pruning from external registries.

Images "managed by OpenShift" will have the annotation `openshift.io/image.managed`.

When an image is pruned, all references to the image are removed from all ImageStreams having 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
----

{'fraction_non_alphanumeric': 0.11931387414708113, 'fraction_numerical': 0.0075815011372251705, 'mean_word_length': 3.926704014939309, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4991590', 'n_tokens_mistral': 3252, 'n_tokens_neox': 3064, 'n_words': 1340}