uselagoon / lagoon

Lagoon, the developer-focused application delivery platform
https://docs.lagoon.sh/
Apache License 2.0
560 stars 149 forks source link

feat: introduce retention policy support #3709

Open shreddedbacon opened 5 months ago

shreddedbacon commented 5 months ago

General Checklist

Database Migrations

Introducing retention policy support to Lagoon. This first iteration only contains Harbor and history based retention policy support.

Retention policy support allows platform owners to configure policies globally, organizationally, or directly on projects. Policy inheritance exists-ish, and a project will override organization, which will override global.

Harbor Policies

Harbor policies allow for retaining the Last Pulled number of images based on rules that can be defined. This allows platform owners to be able to write rules that could retain all images of a project for the last # pulled images. Or configure multiple rules based on doublestar pattern matching that Harbor uses to prune some images more aggressively than others.

Harbor policies are enforced when they are linked, unlinked, updated, or when a deployment reaches the final stages. It uses hooks on certain events, and then send messages to the remotes to inform their configured Harbor of any policy changes that are required.

This requires that the remote-controller be updated with support for receiving the retention policy payloads

History Policies

History policies allow for retaining the last X number of builds and tasks and associated files/logs for these. It is possible to configure this for COUNT, DAYS, MONTHS. This allows for platform owners to retain a small number of builds and tasks within an environment if they choose to.

History policies are enforced whenever a new task or build is created.

See the README for more information about retention policies.