Repositories and retention
Deployed and supported. The fields and commands described here are stable within version v1alpha1.
A repository must be declared before the registry accepts pushing an image to it or pulling
one from it. This guide shows how to declare it with sng registry create or a
RegistryRepository manifest, set tag retention, and delete it.
Prerequisites
- The
sngCLI authenticated (sng sso login) and a tenant session (sng tenant use acme). - The right to apply manifests (
deploy:write, included inreadwrite).
1. Declare a repository
sng registry create web
repository "web" declared in tenant acme, then usable as ovh-gra-0.registry.dev.stackngo.fr/acme/web
The command stores a RegistryRepository manifest in your tenant's desired state. The
repository is usable a few minutes later; until then, the registry refuses access to it.
The same repository as a manifest:
apiVersion: registry.stackngo.io/v1alpha1
kind: RegistryRepository
metadata:
name: web
spec: {}
sng apply infra/RegistryRepository/web.yml
To start from a commented template: sng template gen RegistryRepository web > web.yml.
Repository name: lowercase letters, digits and separators ., _, - between two
alphanumeric characters (web, shop-api, tools.v2); no /. The full path is
<tenant>/<repository>.
2. Choose the retention
Without retention, all tags are kept. To limit storage:
sng registry create web --keep-last 20 --keep-days 90 --keep-tag '^v\d+\.\d+\.\d+$'
apiVersion: registry.stackngo.io/v1alpha1
kind: RegistryRepository
metadata:
name: web
spec:
retention:
keepLastCount: 20 # the last 20 tags pushed
keepDays: 90 # or pushed less than 90 days ago
keepTagsRegex: ['^v\d+\.\d+\.\d+$'] # or the releases, forever
A tag is kept if it meets at least one condition:
| Rule | sng registry create flag | Effect |
|---|---|---|
keepTagsRegex | --keep-tag REGEX (repeatable, 16 at most) | kept forever if it matches one of the expressions (Go syntax) |
keepLastCount | --keep-last N | kept if it is among the last N tags pushed that match no keepTagsRegex |
keepDays | --keep-days N | kept if it was pushed less than N days ago |
deleteUntagged | --keep-untagged to disable it | untagged images are erased (by default) |
The other tags are erased by a periodic cleanup: the effect is not immediate (allow up to 24 hours).
With only keepTagsRegex, without keepLastCount or keepDays, all tags remain
kept: the platform deletes nothing as long as no limit is given for the others.
3. Make a repository public
sng registry create docs --public
public: true allows anonymous pull, without any session. push and deletion
always require a session (or, for push, an access key). A public repository is also the way to share an
image with another tenant.
4. Check
sng kind list RegistryRepository
The list displays each declared repository (NAME) and the date of its last modification
(UPDATED).
The most direct way to check that the repository is active is to push an image to it
(Push and pull): a registry refused the access refusal right
after the declaration most often means that the repository is not ready yet: try again a few minutes later.
5. Delete a repository
sng registry delete web
⚠ Suppression définitive du RegistryRepository "web".
Tapez « oui » pour confirmer : oui
deleted: web (images are purged if deletionPolicy is Delete)
What happens to the images depends on deletionPolicy:
deletionPolicy | The repository contains tags | Result |
|---|---|---|
Block (default) | yes | the repository remains: no push accepted anymore, pull continues; it disappears as soon as its last tags are erased |
Block | no | the repository disappears |
Delete | — | all tagged images are erased, then the repository disappears |
To delete a Block repository that still contains images, erase them first
(sng registry delete web:1.0.0, see Push and pull),
or declare it with --deletion-policy Delete before deleting it.
Going further
- Modify a repository: rerun
sng registry createwith other flags, or modify the manifest andsng apply. The new retention is taken into account without interruption. - Invalid expression:
sng registry createrefuses an invalid regex before sending anything. With a manifest whose regex is invalid, the repository falls back to "keep everything". - Evaluation order: a tag that matches
keepTagsRegexis not counted inkeepLastCount. WithkeepLastCount: 20andv1.2.3releases, you keep all the releases plus the last 20 other tags. - Deletion in progress: a tag pushed during the purge delays the disappearance of the repository by a few minutes.
- Repository state:
sng kind get RegistryRepository webshows the manifest, then the repository's state as comments (Readycondition, reason and message). SeeRegistryRepository.