Skip to content

Commit

Permalink
chore: add garbage collect cronjob for registry
Browse files Browse the repository at this point in the history
  • Loading branch information
heiruwu committed Mar 13, 2024
1 parent 4be16df commit 1480265
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 1 deletion.
70 changes: 70 additions & 0 deletions charts/core/templates/registry/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{{- if .Values.registry.garbageCollect.enabled }}
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ template "core.registry" . }}-garbage-collector
labels:
{{- include "core.labels" . | nindent 4 }}
app.kubernetes.io/component: registry
spec:
concurrencyPolicy: Forbid
schedule: {{ .Values.registry.garbageCollect.schedule | quote }}
jobTemplate:
metadata:
labels:
{{- include "core.matchLabels" . | nindent 8 }}
app.kubernetes.io/component: registry
annotations:
checksum/config: {{ include (print $.Template.BasePath "/registry/configmap.yaml") . | sha256sum }}
{{- with .Values.registry.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
template:
spec:
{{- if .Values.registry.serviceAccountName }}
serviceAccountName: {{ .Values.registry.serviceAccountName }}
{{- end }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 12 }}
{{- end }}
securityContext:
runAsUser: 65534
runAsGroup: 65534
fsGroup: 65534
containers:
- name: garbage-collect
image: {{ .Values.registry.image.repository }}:{{ .Values.registry.image.tag }}
imagePullPolicy: {{ .Values.registry.image.pullPolicy }}
command:
- /bin/registry
- garbage-collect
- --delete-untagged={{ .Values.registry.garbageCollect.deleteUntagged }}
- /etc/docker/registry/config.yml
securityContext:
runAsUser: 65534
runAsGroup: 65534
fsGroup: 65534
volumeMounts:
- name: config
mountPath: {{ .Values.registry.configPath }}
subPath: config.yaml
restartPolicy: OnFailure
{{- with .Values.registry.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.registry.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.registry.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: config
configMap:
name: {{ template "core.registry" . }}
{{- end }}
6 changes: 5 additions & 1 deletion charts/core/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1417,6 +1417,10 @@ registry:
spec:
minAvailable:
maxUnavailable:
garbageCollect:
enabled: false
deleteUntagged: true
schedule: "@midnight"
config:
version: 0.1
log:
Expand All @@ -1438,7 +1442,7 @@ registry:
blobdescriptorsize: 10000
maintenance:
uploadpurging:
enabled: false
enabled: true
age: 168h
interval: 24h
dryrun: false
Expand Down

0 comments on commit 1480265

Please sign in to comment.