All Projects → cd1989 → harbor-cleaner

cd1989 / harbor-cleaner

Licence: Apache-2.0 license
Clean images in Harbor by policies

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to harbor-cleaner

Type
🎉 Minimal and Clean Free Jekyll Theme
Stars: ✭ 185 (+537.93%)
Mutual labels:  clean
k8s-harbor
Harbor in Kubernetes
Stars: ✭ 36 (+24.14%)
Mutual labels:  harbor
white-theme-vscode
Minimalist monochrome theme for Visual Studio Code
Stars: ✭ 66 (+127.59%)
Mutual labels:  clean
Store
A beautifully-simple framework-agnostic modern state management library.
Stars: ✭ 204 (+603.45%)
Mutual labels:  clean
React Landing Page Template
A simple react one page landing page templates for startups/companies
Stars: ✭ 224 (+672.41%)
Mutual labels:  clean
go-zero-looklook
🔥基于go-zero(go zero) 微服务全技术栈开发最佳实践项目。Develop best practice projects based on the full technology stack of go zero (go zero) microservices.
Stars: ✭ 2,691 (+9179.31%)
Mutual labels:  harbor
Boo
Boo - A beautiful, clean and responsive theme for Ghost.
Stars: ✭ 176 (+506.9%)
Mutual labels:  clean
cncf-platform-stack
🐳 📦 🚀 ⚡ Recursos da série de vídeos sobre stack da CNCF
Stars: ✭ 59 (+103.45%)
Mutual labels:  harbor
Cqrs Clean Eventual Consistency
CQRS, using Clean Architecture, multiple databases and Eventual Consistency
Stars: ✭ 247 (+751.72%)
Mutual labels:  clean
community
Harbor community-related material
Stars: ✭ 65 (+124.14%)
Mutual labels:  harbor
Clean Architecture Android
Sample to practice Clean Architecture in android applications.
Stars: ✭ 207 (+613.79%)
Mutual labels:  clean
Transport Eta
Twitch streamed 🎥playground repo, README speaks to you.
Stars: ✭ 223 (+668.97%)
Mutual labels:  clean
Cleaner 42
Only for 42Network schools, Cleaner_42 script is linked to cclean command/program, and it saves you some memory space.
Stars: ✭ 186 (+541.38%)
Mutual labels:  clean
Xlog
Android logger, pretty, powerful and flexible, log to everywhere, save to file, all you want is here.
Stars: ✭ 2,468 (+8410.34%)
Mutual labels:  clean
docker-pushrm
"Docker Push Readme" - a Docker CLI plugin to update container repo docs
Stars: ✭ 100 (+244.83%)
Mutual labels:  harbor
Dropcss
An exceptionally fast, thorough and tiny unused-CSS cleaner
Stars: ✭ 2,102 (+7148.28%)
Mutual labels:  clean
gulp-cleanhtml
remove unneeded whitespaces, line-breaks, comments, etc from the HTML.
Stars: ✭ 19 (-34.48%)
Mutual labels:  clean
dobbi
An open-source NLP library: fast text cleaning and preprocessing
Stars: ✭ 21 (-27.59%)
Mutual labels:  clean
remove-files-webpack-plugin
A plugin for webpack that removes files and folders before and after compilation.
Stars: ✭ 48 (+65.52%)
Mutual labels:  clean
Alphalio
A clean HTML5 Resume/CV template
Stars: ✭ 23 (-20.69%)
Mutual labels:  clean

中文

Harbor Cleaner

Clean images in Harbor by policies.

Features

  • Delete tags without side effects As we known when we delete a tag from a repo in docker registry, the underneath manifest is deleted, so are other tags what share the same manifest. In this tool, we protect tags from such situation.
  • Delete by policies Support delete tags by configurable policies
  • Dry run before actual cleanup To see what would be cleaned up before performing real cleanup.
  • Cron Schedule Schedule the cleanup regularly by cron.

Concepts

Image Project Repo Tag
library/busybox:1.30.0 library busybox 1.30.0
release/devops/tools:v1.0 release devops/tools v1.0

Policies

Number Policy

Number policy will retain latest N tags for each repo and remove other old ones. Latest tags are determined by images' creation time.

numberPolicy:
    number: 5

This policy takes only one argument, the number of tags to retain.

Regex Policy

Regex policy removes images that match the given repo and tag regex patterns. A tag will be removed only when following conditions are all satisfied:

  • It matches at least one repo pattern
  • It matches at least one tag pattern

Regex here are Golang supported regex. For example .* matches all.

regexPolicy:
    repos: [".*"]
    tags: [".*-alpha.*", "dev"]

The above policy config will remove tags from all repos that are 'dev' or contain 'alpha'. For example,

  • dev
  • v1.0.0-alpha
  • v1.4.0-alpha.2
  • 1.0-alpha.5

Recently Not Touched Policy

This policy works depends on Harbor's access log. It collects images that are recently touched (pull, push, delete), and remove all other images that are not touched recently. It takes a time in second to configure the time period.

notTouchedPolicy:
  time: 604800

How To Use

Get Image

$ make image VERSION=latest

You can also pull one from DockerHub.

$ docker pull k8sdevops/harbor-cleaner:v0.4.0

Configure

# Host of the Harbor
host: https://dev.cargo.io
# Version of the Harbor, e.g. 1.7, 1.4.0
version: 1.7
# Admin account
auth:
  user: admin
  password: Pwd123456
# Projects list to clean images for, it you want to clean images for all
# projects, leave it empty.
projects: []
# Policy to clean images
policy:
  # Policy type, e.g. "number", "regex", "recentlyNotTouched"
  type: number

  # Number policy: to retain the latest N tags for each repo
  # This configure takes effect only when 'policy.type' is set to 'number'
  numberPolicy:
    number: 5

  # Regex policy: only clean images that match the given repo patterns and tag patterns
  # This configure takes effect only when 'policy.type' is set to 'regex'
  regexPolicy:
    # Regex to match repos, a repo will be regarded as matched when it matches any regex in the list
    repos: [".*"]
    # Regex to match tags, a tag will be regarded as matched when it matches any regex in the list
    tags: [".*-alpha.*", "dev"]

  # Recently not touched policy: clean images that not touched within the given time period
  # This configure takes effect only when 'policy.type' is set to 'recentlyNotTouched'
  notTouchedPolicy:
    # Time in second that to check for images
    time: 604800

  # Tags that should be retained anyway, '?', '*' supported.
  retainTags: []
# Trigger for the cleanup, if you only want to run cleanup once, remove the 'trigger' part or leave
# the 'trigger.cron' empty
trigger:
  # Cron expression to trigger the cleanup, for example "0 0 * * *", leave it empty will disable the
  # trigger and fallback to run cleanup once. Note: you may need to quote the cron expression with double quote.
  # Time zone of the cron depends on the running environment, if run in docker container, it's UTC time.
  cron:
# For Harbor version v1.9+, you should configure the XSRF protection. For other version, keep the default values.
xsrf:
  # Refer to 'EnableXSRF' in Harbor config file 'common/config/core/app.conf'.
  enabled: true
  # Refer to 'XSRFKey' in Harbor config file 'common/config/core/app.conf'.
  key: T20zVqpLbDDlQGVIiiwDtAAtsm8bSRjHBJSMyejG

In the policy part, exact one of numberPolicy, regexPolicy, notTouchedPolicy should be configured according to the policy type.

DryRun

$ docker run -it --rm \
    -v <your-config-file>:/workspace/config.yaml \
    k8sdevops/harbor-cleaner:latest --dryrun=true

Clean

$ docker run -it --rm \
    -v <your-config-file>:/workspace/config.yaml \
    k8sdevops/harbor-cleaner:latest

Cron Schedule

Configure the cron trigger and run harbor cleaner container in background.

# Trigger for the cleanup, if you only want to run cleanup once, remove the 'trigger' part or leave
# the 'trigger.cron' empty
trigger:
  # Cron expression to trigger the cleanup, for example "0 0 * * *", leave it empty will disable the
  # trigger and fallback to run cleanup once.
  cron: 0 0 * * *
$ docker run -d --name=harbor-cleaner --rm \
    -v <your-config-file>:/workspace/config.yaml \
    k8sdevops/harbor-cleaner:latest

Supported Version

  • 1.4.x
  • 1.5.x
  • 1.6.x
  • 1.7.x
  • 1.8.x
  • 1.9.x (harbor-cleaner:v0.4.0+)

Harbor 2.x not supported yet.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].