Skip to content

Commit

Permalink
Support pruning images using CronJobs
Browse files Browse the repository at this point in the history
Signed-off-by: Vadim Rutkovsky <vrutkovs@redhat.com>
  • Loading branch information
vrutkovs committed Nov 2, 2017
1 parent 1db03bb commit 718b185
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ Role Variables
osbs_sources_command: fedpkg sources
osbs_source_registry_uri: https://source.registry.fedoraproject.org # Empty default value

# Pruning
osbs_prune: false
osbs_prune_schedule: '0 0 */8 * *'
osbs_prune_secret: ''
osbs_prune_image: ''

For a full list, see defaults/main.yml

Dependencies
Expand Down
5 changes: 5 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,8 @@ osbs_build_json_dir: /usr/share/osbs
osbs_sources_command: fedpkg sources
osbs_vendor: Fedora Project
osbs_nodeselector: ''

osbs_prune: false
osbs_prune_schedule: '0 0 */8 * *'
osbs_prune_secret: ''
osbs_prune_image: ''
20 changes: 20 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,5 +188,25 @@
tags:
- oc

- name: copy prune cronjob yaml
template:
src: openshift-prune-cronjob.yml.j2
dest: "{{ osbs_openshift_home }}/{{ inventory_hostname }}-{{ osbs_namespace }}-prune-cronjob.yml"
register: yaml_cronjob
when: osbs_prune
tags:
- oc

- name: import prune cronjob yaml
command: >
oc replace
--namespace={{ osbs_namespace }}
--force=true
--filename={{ osbs_openshift_home }}/{{ inventory_hostname }}-{{ osbs_namespace }}-prune-cronjob.yml
environment: "{{ osbs_environment }}"
when: osbs_prune and yaml_cronjob.changed
tags:
- oc

- include: orchestrator.yml
when: osbs_orchestrator
24 changes: 24 additions & 0 deletions templates/openshift-prune-cronjob.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: batch/v2alpha1
kind: CronJob
metadata:
name: build-pruner
spec:
schedule: "{{ osbs_prune_schedule }}"
jobTemplate:
spec:
template:
spec:
volumes:
- name: token
secret:
defaultMode: 420
secretName: {{ osbs_prune_secret }}
containers:
- name: build-pruner
image: {{ osbs_prune_image }}
command: ["/prune.sh"]
volumeMounts:
- mountPath: /token
name: token
readOnly: true
restartPolicy: Never

0 comments on commit 718b185

Please sign in to comment.