Skip to content

Commit 7a4e1ab

Browse files
committed
add cleanreg cronjob
1 parent 009a523 commit 7a4e1ab

File tree

5 files changed

+156
-3
lines changed

5 files changed

+156
-3
lines changed

charts/docker-registry/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: docker-registry
33
description: |-
44
Helm chart to deploy [docker-registry](https://github.com/distribution/distribution).
55
type: application
6-
version: 0.0.2
6+
version: 0.0.3
77
appVersion: 2.8.1
88
home: https://github.com/slamdev/helm-charts/tree/master/charts/docker-registry
99
icon: https://docs.docker.com/favicons/docs@2x.ico

charts/docker-registry/README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# docker-registry
22

3-
![Version: 0.0.2](https://img.shields.io/badge/Version-0.0.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.8.1](https://img.shields.io/badge/AppVersion-2.8.1-informational?style=flat-square)
3+
![Version: 0.0.3](https://img.shields.io/badge/Version-0.0.3-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.8.1](https://img.shields.io/badge/AppVersion-2.8.1-informational?style=flat-square)
44

55
Helm chart to deploy [docker-registry](https://github.com/distribution/distribution).
66

@@ -18,6 +18,21 @@ Helm chart to deploy [docker-registry](https://github.com/distribution/distribut
1818
|-----|------|---------|-------------|
1919
| additionalResources | list | `[]` | list of additional resources to create (are processed via `tpl` function) |
2020
| affinity | object | `{}` | affinity for scheduler pod assignment |
21+
| cleanregCronJob.args | list | `["--registry=http://docker-registry","--assume-yes","--clean-full-catalog","--keepimages=10","--skip-tls-verify","--ignore-ref-tags"]` | args for cleanreg https://github.com/hcguersoy/cleanreg#usage |
22+
| cleanregCronJob.env | list | `[]` | additional environment variables for the deployment |
23+
| cleanregCronJob.failedJobsHistoryLimit | int | `1` | the number of failed finished jobs to retain |
24+
| cleanregCronJob.image.pullPolicy | string | `"IfNotPresent"` | image pull policy |
25+
| cleanregCronJob.image.repository | string | `"hcguersoy/cleanreg"` | image repository |
26+
| cleanregCronJob.image.tag | string | `"v0.8.0"` | image tag (chart's appVersion value will be used if not set) |
27+
| cleanregCronJob.imagePullSecrets | list | `[]` | image pull secret for private images |
28+
| cleanregCronJob.podSecurityContext | object | `{}` | specifies security settings for a pod |
29+
| cleanregCronJob.resources | object | `{}` | custom resource configuration |
30+
| cleanregCronJob.restartPolicy | string | `"Never"` | container restart policy |
31+
| cleanregCronJob.schedule | string | `"@daily"` | the schedule in Cron format, see https://en.wikipedia.org/wiki/Cron |
32+
| cleanregCronJob.securityContext | object | `{}` | specifies security settings for a container |
33+
| cleanregCronJob.successfulJobsHistoryLimit | int | `3` | the number of successful finished jobs to retain |
34+
| cleanregCronJob.volumeMounts | list | `[]` | additional volume mounts |
35+
| cleanregCronJob.volumes | list | `[]` | additional volumes |
2136
| config | string | `"http:\n addr: :5000"` | docker-registry config to provision inside of the container |
2237
| containerPorts | list | `[{"containerPort":5000,"name":"http","protocol":"TCP"}]` | ports exposed by container |
2338
| deploymentAnnotations | object | `{}` | annotations to add to the deployment |
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
apiVersion: batch/v1
2+
kind: CronJob
3+
metadata:
4+
name: {{ include "docker-registry.fullname" . }}-cleanreg
5+
namespace: {{ .Release.Namespace }}
6+
labels:
7+
{{- include "docker-registry.labels" . | nindent 4 }}
8+
app.kubernetes.io/component: cleanreg
9+
spec:
10+
concurrencyPolicy: Forbid
11+
successfulJobsHistoryLimit: {{ .Values.cleanregCronJob.successfulJobsHistoryLimit }}
12+
failedJobsHistoryLimit: {{ .Values.cleanregCronJob.failedJobsHistoryLimit }}
13+
schedule: {{ .Values.cleanregCronJob.schedule | quote }}
14+
jobTemplate:
15+
metadata:
16+
labels:
17+
{{- include "docker-registry.selectorLabels" . | nindent 8 }}
18+
app.kubernetes.io/component: cleanreg
19+
spec:
20+
template:
21+
metadata:
22+
labels:
23+
{{- include "docker-registry.selectorLabels" . | nindent 12 }}
24+
app.kubernetes.io/component: cleanreg
25+
spec:
26+
restartPolicy: {{ .Values.cleanregCronJob.restartPolicy }}
27+
{{- with .Values.cleanregCronJob.imagePullSecrets }}
28+
imagePullSecrets:
29+
{{- toYaml . | nindent 12 }}
30+
{{- end }}
31+
serviceAccountName: {{ include "docker-registry.serviceAccountName" . }}
32+
securityContext:
33+
{{- toYaml .Values.cleanregCronJob.podSecurityContext | nindent 12 }}
34+
containers:
35+
- name: {{ .Chart.Name }}
36+
{{- with .Values.cleanregCronJob.args }}
37+
args:
38+
{{- toYaml . | nindent 16 }}
39+
{{- end }}
40+
securityContext:
41+
{{- toYaml .Values.cleanregCronJob.securityContext | nindent 16 }}
42+
image: "{{ .Values.cleanregCronJob.image.repository }}:{{ .Values.cleanregCronJob.image.tag }}"
43+
imagePullPolicy: {{ .Values.cleanregCronJob.image.pullPolicy }}
44+
resources:
45+
{{- toYaml .Values.cleanregCronJob.resources | nindent 16 }}
46+
{{- with .Values.cleanregCronJob.env }}
47+
env:
48+
{{- toYaml . | nindent 16 }}
49+
{{- end }}
50+
{{- with .Values.cleanregCronJob.volumeMounts }}
51+
volumeMounts:
52+
{{- toYaml . | nindent 16 }}
53+
{{- end }}
54+
{{- with .Values.cleanregCronJob.volumes }}
55+
volumes:
56+
{{- toYaml . | nindent 12 }}
57+
{{- end }}
58+
{{- with .Values.nodeSelector }}
59+
nodeSelector:
60+
{{- toYaml . | nindent 12 }}
61+
{{- end }}
62+
{{- with .Values.affinity }}
63+
affinity:
64+
{{- toYaml . | nindent 12 }}
65+
{{- end }}
66+
{{- with .Values.tolerations }}
67+
tolerations:
68+
{{- toYaml . | nindent 12 }}
69+
{{- end }}

charts/docker-registry/templates/cronjob.yaml renamed to charts/docker-registry/templates/cronjob-gc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: batch/v1
22
kind: CronJob
33
metadata:
4-
name: {{ include "docker-registry.fullname" . }}
4+
name: {{ include "docker-registry.fullname" . }}-gc
55
namespace: {{ .Release.Namespace }}
66
labels:
77
{{- include "docker-registry.labels" . | nindent 4 }}

charts/docker-registry/values.yaml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,72 @@ garbageCollectCronJob:
150150
# requests:
151151
# cpu: 100m
152152
# memory: 128Mi
153+
154+
cleanregCronJob:
155+
156+
image:
157+
# cleanregCronJob.image.repository -- image repository
158+
repository: hcguersoy/cleanreg
159+
# cleanregCronJob.image.tag -- image tag (chart's appVersion value will be used if not set)
160+
tag: v0.8.0
161+
# cleanregCronJob.image.pullPolicy -- image pull policy
162+
pullPolicy: IfNotPresent
163+
164+
# cleanregCronJob.imagePullSecrets -- image pull secret for private images
165+
imagePullSecrets: [ ]
166+
167+
# cleanregCronJob.podSecurityContext -- specifies security settings for a pod
168+
podSecurityContext: { }
169+
# fsGroup: 2000
170+
171+
# cleanregCronJob.securityContext -- specifies security settings for a container
172+
securityContext: { }
173+
# capabilities:
174+
# drop:
175+
# - ALL
176+
# readOnlyRootFilesystem: true
177+
# runAsNonRoot: true
178+
# runAsUser: 1000
179+
180+
181+
# cleanregCronJob.env -- additional environment variables for the deployment
182+
env: [ ]
183+
# - name: SAMPLE
184+
# value: text
185+
186+
# cleanregCronJob.volumeMounts -- additional volume mounts
187+
volumeMounts: [ ]
188+
# - name: cache
189+
# mountPath: /data/docker-registry/cache
190+
191+
# cleanregCronJob.volumes -- additional volumes
192+
volumes: [ ]
193+
# - name: cache
194+
# emptyDir: {}
195+
196+
# cleanregCronJob.resources -- custom resource configuration
197+
resources: { }
198+
# limits:
199+
# cpu: 100m
200+
# memory: 128Mi
201+
# requests:
202+
# cpu: 100m
203+
# memory: 128Mi
204+
205+
# cleanregCronJob.successfulJobsHistoryLimit -- the number of successful finished jobs to retain
206+
successfulJobsHistoryLimit: 3
207+
# cleanregCronJob.failedJobsHistoryLimit -- the number of failed finished jobs to retain
208+
failedJobsHistoryLimit: 1
209+
# cleanregCronJob.schedule -- the schedule in Cron format, see https://en.wikipedia.org/wiki/Cron
210+
schedule: "@daily"
211+
# cleanregCronJob.restartPolicy -- container restart policy
212+
restartPolicy: Never
213+
214+
# cleanregCronJob.args -- args for cleanreg https://github.com/hcguersoy/cleanreg#usage
215+
args:
216+
- --registry=http://docker-registry
217+
- --assume-yes
218+
- --clean-full-catalog
219+
- --keepimages=10
220+
- --skip-tls-verify
221+
- --ignore-ref-tags

0 commit comments

Comments
 (0)