Lifecycle policy in Yandex Cloud Registry
A lifecycle policy consists of rules that manage storage or deletion of artifacts in a registry. Policies automate the cleanup of old or unused artifact versions to save space and reduce storage costs.
Rules are specified as a JSON array of rule objects when creating a lifecycle policy.
Each policy rule includes a filter by path_prefix. It indicates which artifacts the rule applies to.
Examples
| Prefix | Apply the rule to |
|---|---|
.* |
All artifacts in the registry |
ubuntu/.* |
Artifacts whose paths start with ubuntu/ |
Warning
Rules apply to packages. If you set a rule saying Keep only the ten most recent versions with path_prefix = .* for a registry containing two packages, e.g., ubuntu and vault, the rule will apply separately to each package. As a result, the ten latest versions will be retained in each package, rather than across all packages.
The number of lifecycle policies and rules within them are subject to quotas and limits.
Types of rules
Lifecycle policy rules:
- Apply only to artifacts matching the filter.
- Determine which of these artifacts to retain or delete.
KEEP
Rules of the KEEP type describe which artifacts the lifecycle policy should retain. These rules have higher priority than deletion rules (HARD_DELETE and SOFT_DELETE).
The retention conditions include:
- Age: Keeps artifacts younger than the specified age in days.
- Number of versions: Keeps the specified number of the latest artifact versions, e.g., the five most recently created versions.
HARD_DELETE
A rule of the HARD_DELETE type permanently deletes artifacts matching the rule conditions. After the rule applies, the artifacts are permanently deleted, and you cannot restore them.
The deletion conditions include:
- Age: Deletes artifacts older than the specified age in days.
- Number of versions: Deletes the oldest artifacts if they exceed the specified number (the oldest versions are deleted).
- Always: Deletes all artifacts.
SOFT_DELETE
A rule of the SOFT_DELETE type marks artifacts for deletion but does not delete them immediately. The artifacts remain in the registry during the cooldown period specified in the rule. After this period ends, the artifacts are permanently deleted.
Note
Artifacts marked for soft deletion remain billable until the end of the cooldown period.
The SOFT_DELETE and HARD_DELETE rule conditions are the same.
Rule filters
Each rule includes filters indicating which artifacts the rule applies to:
- Path prefix (
path_prefix): Determines which artifacts the rule applies to based on their path. If you specify.*, the rule will apply to all artifacts of all packages in the registry. You can provide a specific path prefix, e.g.,@path/prefix.*. - Docker filters: Additional filters for Docker images by tag status (with tags, no tags).
- Maven filters: Additional filters for Java artifacts by version type (release versions, snapshots).
Rules based on the number of versions or date apply to artifacts matching all the specified filters.
Applying policies
Lifecycle policies apply automatically according to a schedule. Rules are processed daily at the specified time. Policy changes are not immediate and take effect with the next processing cycle.
Rules apply in the following priority order:
KEEPrules: Determine which artifacts to retain.HARD_DELETEandSOFT_DELETErules: Determine which artifacts to delete, ignoring those protected by theKEEPrules.
Rule object (LifecycleRule)
The keep_by_age, keep_by_version, and delete fields are mutually exclusive; you can only specify one action per rule.
| Field | Type | Description |
|---|---|---|
path_prefix |
string |
Path prefix indicating which artifacts the rule applies to. If it is not specified, the rule will apply to all artifacts. |
keep_by_age |
KeepByAgeLifecycleRule | Keeping artifacts based on their age. |
keep_by_version |
KeepByVersionLifecycleRule | Keeping artifacts based on the number of versions. |
delete |
DeleteLifecycleRule | Deleting artifacts. |
docker_filters |
DockerFilters | Filters for rules applied to Docker images. |
maven_filters |
MavenFilters | Filters for rules applied to Java artifacts. |
version_regexp |
string |
Regular expression to search for a package version or Docker image tag. |
KeepByAgeLifecycleRule object
| Field | Type | Description |
|---|---|---|
younger_than_days |
integer |
Keep artifacts younger than the specified number of days. |
KeepByVersionLifecycleRule object
| Field | Type | Description |
|---|---|---|
keep_versions_count |
integer |
Keep the specified number of artifact versions. |
DeleteLifecycleRule object
The older_than_days, version_condition, and always fields are mutually exclusive; you can only specify one deletion condition.
| Field | Type | Description |
|---|---|---|
type |
string |
Deletion type:
|
cooldown_period_days |
integer |
Waiting period before deletion, in days. |
older_than_days |
integer |
Delete artifacts older than the specified number of days. |
version_condition |
DeleteByVersionCondition | Delete artifacts based on the number of versions. |
always |
boolean |
Delete all matching artifacts. |
DeleteByVersionCondition object
| Field | Type | Description |
|---|---|---|
versions_count_greater_than |
integer |
Delete artifacts if their versions exceed the specified number. |
DockerFilters object
| Field | Type | Description |
|---|---|---|
tag_status |
string |
Filter Docker images by tag status:
|
MavenFilters object
| Field | Type | Description |
|---|---|---|
version_type |
string |
Filter Java artifacts by version type:
|