Updated Janitor with KEEP_CONTAINERS and wildcard matches

Default setting to keep ALL containers protects Rancher templates where
run-once containers are used; in general Rancher will remove its own
containers where necessary.
User of Shell Wildcards allows more flexibility when specifying images to be
kept during the sweep.
This commit is contained in:
sshipway 2016-03-13 23:47:26 +00:00
parent 4b97b21b76
commit 0c20789ec6
3 changed files with 48 additions and 1 deletions

View File

@ -0,0 +1,16 @@
cleanup:
image: sshipway/docker-cleanup:1.5.2
environment:
CLEAN_PERIOD: ${FREQUENCY}
DELAY_TIME: "900"
KEEP_IMAGES: "${KEEP}"
KEEP_CONTAINERS: "${KEEPC}"
labels:
io.rancher.scheduler.global: "true"
io.rancher.scheduler.affinity:host_label_ne: "${EXCLUDE_LABEL}"
privileged: true
tty: false
stdin_open: false
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker:/var/lib/docker

View File

@ -0,0 +1,31 @@
.catalog:
name: "Janitor"
version: "v1.5.2"
description: "Docker cleanup"
uuid: janitor-1
questions:
- variable: "FREQUENCY"
label: "Frequency"
description: "Run the cleanup on a cycle of this many seconds"
default: 3600
required: true
type: "int"
- variable: "EXCLUDE_LABEL"
label: "Exclude label"
description: "Specify a Rancher host label here that will be used to determine on which hosts the Janitor container should not deploy."
default: janitor.exclude=true
required: true
type: "string"
- variable: "KEEP"
label: "Keep images"
description: "A comma separated list of images that should never be removed. These are left-anchored Bash Shell Wildcard patterns."
default: "rancher/"
required: false
type: "string"
- variable: "KEEPC"
label: "Keep containers"
description: "A comma separated list of images that should never have stopped containers removed. These are left-anchored Bash Shell Wildcard patterns."
default: "*:*"
required: false
type: "string"

View File

@ -1,7 +1,7 @@
name: Janitor
description: |
Automatic cleanup of unused images on hosts, in order to save disk space.
version: v1.4.0
version: v1.5.2
category: monitoring
maintainer: Steve Shipway <s.shipway@auckland.ac.nz>