1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-06 06:46:26 +01:00
Files
openshift-docs/modules/pruning-images.adoc

92 lines
4.0 KiB
Plaintext

// Module included in the following assemblies:
//
// * applications/pruning-objects.adoc
[id="pruning-images_{context}"]
= Automatically pruning images
Images that are no longer required by the system due to age,
status, or exceed limits are automatically pruned. Cluster administrators can configure the Pruning Custom Resource, or delete it to disable it.
[NOTE]
====
When the Pruning Custom Resource is deleted, the pruning `CronJob` and its related components should also be deleted.
====
.Prerequisites
* Cluster administrator permissions.
* Install the `oc` CLI.
.Procedure
* Verify that the object named `imagepruners.imageregistry.operator.openshift.io/cluster` contains the following `spec` and `status` fields:
[source,yaml]
----
spec:
schedule: "0 0 * * *" <1>
suspend: false <2>
keepTagRevisions: 3 <3>
keepYoungerThan: 60m <4>
resources: {} <5>
affinity: {} <6>
nodeSelector: {} <7>
tolerations: {} <8>
startingDeadlineSeconds: 60 <9>
successfulJobsHistoryLimit: 3 <10>
failedJobsHistoryLimit: 3 <11>
logLevel: Normal <12>
status:
observedGeneration: 2 <13>
conditions: <14>
- type: Available
status: "True"
lastTransitionTime: 2019-10-09T03:13:45
reason: Ready
message: "Periodic image pruner has been created."
- type: Scheduled
status: "True"
lastTransitionTime: 2019-10-09T03:13:45
reason: Scheduled
message: "Image pruner job has been scheduled."
- type: Failed
staus: "False"
lastTransitionTime: 2019-10-09T03:13:45
reason: Succeeded
message: "Most recent image pruning job succeeded."
----
<1> `schedule`: `CronJob` formatted schedule, defaults to daily at midnight for new clusters. This is a required field.
<2> `suspend`: If set to `true`, the `CronJob` running pruning is suspended. This is an optional field, and it defaults to `false`.
<3> `keepTagRevisions`: The number of revisions per tag to keep. This is an optional field, and it defaults to `3` if not set.
<4> `keepYoungerThan`: Retain images younger than this duration. This is an optional field, and it defaults `60m` if not set.
<5> `resources`: Standard `Pod` resource requests and limits. This is an optional field.
<6> `affinity`: Standard Pod affinity. This is an optional field.
<7> `nodeSelector`: Standard Pod node selector for the image pruner pod. This is an optional field.
<8> `tolerations`: Standard Pod tolerations. This is an optional field.
<9> `startingDeadlineSeconds`: Start deadline for `CronJob`. This is an optional field.
<10> `successfulJobsHistoryLimit`: The maximum number of successful jobs to retain. Must be `>= 1` to ensure metrics are reported. Defaults to `3` if not set.
<11> `failedJobsHistoryLimit`: The maximum number of failed jobs to retain. Must be `>= 1` to ensure metrics are reported. Defaults to `3` if not set.
<12> `logLevel`: Sets the log level for the pruner job. Defaults to `Normal`.
* `Normal`
* `Debug`
* `Trace`
* `TraceAll`
<13> `observedGeneration`: The generation observed by the Operator.
<14> `conditions`: The standard condition objects with the following types:
* `Available`: Indicates if the pruning job has been created. Reasons can be Ready or Error.
* `Scheduled`: Indicates if the next pruning job has been scheduled. Reasons can be Scheduled, Suspended, or Error.
* `Failed`: Indicates if the most recent pruning job failed.
[IMPORTANT]
====
The Image Registry Operator's behavior for managing the pruner is orthogonal to the `managementState` specified on the Image Registry Operator's `ClusterOperator` object. If the image registry Operator is not in the `Managed` state, the image pruner can still be configured and managed by the Pruning Custom Resource.
However, the `managementState` of the Image Registry Operator alters the behavior of the deployed image pruner job:
* `Managed`: the `--prune-registry` flag for the image pruner is set to `true`.
* `Removed`: the `--prune-registry` flag for the image pruner is set to `false`, meaning it only prunes image metatdata in etcd.
* `Unmanaged`: the `--prune-registry` flag for the image pruner is set to `false`.
====