Skip to content

Commit 2ba938b

Browse files
authored
Merge pull request #1588 from sgaist/refactor_image_cleaner_handling
Simplify image-cleaner handling
2 parents 4b10825 + a93f8b5 commit 2ba938b

File tree

7 files changed

+36
-33
lines changed

7 files changed

+36
-33
lines changed

helm-chart/binderhub/schema.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,8 @@ properties:
362362
363363
imageBuilderType:
364364
type: string
365-
enum: ["local", "dind", "pink"]
366-
default: "local"
365+
enum: ["host", "dind", "pink"]
366+
default: "host"
367367
description: |
368368
Selected image builder type
369369
@@ -479,12 +479,12 @@ properties:
479479
host:
480480
type: object
481481
additionalProperties: false
482-
required: [enabled, dockerSocket, dockerLibDir]
482+
required: [dockerSocket, dockerLibDir]
483483
properties:
484484
enabled:
485485
type: boolean
486486
description: |
487-
TODO
487+
DEPRECATED: use imageCleaner.enabled if the cleaner shall not used.
488488
dockerSocket:
489489
type: string
490490
description: |

helm-chart/binderhub/templates/NOTES.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,15 @@ config:
190190
{{- $breaking = print $breaking "\n\nimageBuilderType: dind" }}
191191
{{- end }}
192192

193+
{{- if hasKey .Values.imageCleaner.host "enabled" }}
194+
{{- $breaking = print $breaking "\n\nCHANGED:" }}
195+
{{- $breaking = print $breaking "\n\nimageCleaner:" }}
196+
{{- $breaking = print $breaking "\n host:" }}
197+
{{- $breaking = print $breaking "\n enabled: true" }}
198+
{{- $breaking = print $breaking "\n\nas of version 0.3.0 is not used anymore." }}
199+
{{- $breaking = print $breaking "\n\nThe image cleaner is either disabled or adapted to the value of imageBuilderType." }}
200+
{{- end }}
201+
193202
{{- if $breaking }}
194203
{{- fail (print $breaking_title $breaking) }}
195204
{{- end }}

helm-chart/binderhub/templates/container-builder/daemonset.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
{{- if ne .Values.imageBuilderType "local" -}}
1+
{{- if ne .Values.imageBuilderType "host" -}}
22
{{- $builderName := .Values.imageBuilderType -}}
33
{{- $builder := index .Values $builderName -}}
44
{{- $daemonset := $builder.daemonset -}}
5+
56
apiVersion: apps/v1
67
kind: DaemonSet
78
metadata:
@@ -46,9 +47,9 @@ spec:
4647
{{- with $daemonset.image.pullPolicy }}
4748
imagePullPolicy: {{ . }}
4849
{{- end }}
49-
{{- with $daemonset.resources }}
50+
{{- with $builder.resources }}
5051
resources:
51-
{{- $daemonset.resources | toYaml | nindent 12 }}
52+
{{- $builder.resources | toYaml | nindent 12 }}
5253
{{- end }}
5354
{{- if eq $builderName "dind" }}
5455
args:

helm-chart/binderhub/templates/image-cleaner.yaml

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{{- if .Values.imageCleaner.enabled -}}
2-
{{- $Values := .Values -}}
32
apiVersion: apps/v1
43
kind: DaemonSet
54
metadata:
@@ -36,38 +35,34 @@ spec:
3635
serviceAccountName: {{ .Release.Name }}-image-cleaner
3736
{{- end }}
3837
containers:
39-
{{- range $i, $kind := tuple "host" "dind" "pink" }}
40-
{{- if or (and (eq $kind "dind") (eq $Values.imageBuilderType "dind")) (and (eq $kind "pink") (eq $Values.imageBuilderType "pink")) (and (eq $kind "host") $Values.imageCleaner.host.enabled) }}
41-
- name: image-cleaner-{{ $kind }}
42-
image: {{ $Values.imageCleaner.image.name }}:{{ $Values.imageCleaner.image.tag }}
43-
{{- with $Values.imageCleaner.image.pullPolicy }}
38+
- name: image-cleaner-{{ .Values.imageBuilderType }}
39+
image: {{ .Values.imageCleaner.image.name }}:{{ .Values.imageCleaner.image.tag }}
40+
{{- with .Values.imageCleaner.image.pullPolicy }}
4441
imagePullPolicy: {{ . }}
4542
{{- end }}
4643
volumeMounts:
47-
- name: storage-{{ $kind }}
48-
mountPath: /var/lib/{{ $kind }}
49-
- name: socket-{{ $kind }}
44+
- name: storage-{{ .Values.imageBuilderType }}
45+
mountPath: /var/lib/{{ .Values.imageBuilderType }}
46+
- name: socket-{{ .Values.imageBuilderType }}
5047
mountPath: /var/run/docker.sock
5148
env:
5249
- name: DOCKER_IMAGE_CLEANER_NODE_NAME
5350
valueFrom:
5451
fieldRef:
5552
fieldPath: spec.nodeName
5653
- name: DOCKER_IMAGE_CLEANER_PATH_TO_CHECK
57-
value: /var/lib/{{ $kind }}
54+
value: /var/lib/{{ .Values.imageBuilderType }}
5855
- name: DOCKER_IMAGE_CLEANER_DELAY_SECONDS
59-
value: {{ $Values.imageCleaner.delay | quote }}
56+
value: {{ .Values.imageCleaner.delay | quote }}
6057
- name: DOCKER_IMAGE_CLEANER_THRESHOLD_TYPE
61-
value: {{ $Values.imageCleaner.imageGCThresholdType | quote }}
58+
value: {{ .Values.imageCleaner.imageGCThresholdType | quote }}
6259
- name: DOCKER_IMAGE_CLEANER_THRESHOLD_HIGH
63-
value: {{ $Values.imageCleaner.imageGCThresholdHigh | quote }}
60+
value: {{ .Values.imageCleaner.imageGCThresholdHigh | quote }}
6461
- name: DOCKER_IMAGE_CLEANER_THRESHOLD_LOW
65-
value: {{ $Values.imageCleaner.imageGCThresholdLow | quote }}
66-
{{- end }}
67-
{{- end }}
62+
value: {{ .Values.imageCleaner.imageGCThresholdLow | quote }}
6863
terminationGracePeriodSeconds: 0
6964
volumes:
70-
{{- if .Values.imageCleaner.host.enabled }}
65+
{{- if eq .Values.imageBuilderType "host" }}
7166
- name: storage-host
7267
hostPath:
7368
path: {{ .Values.imageCleaner.host.dockerLibDir }}
@@ -76,7 +71,7 @@ spec:
7671
path: {{ .Values.imageCleaner.host.dockerSocket }}
7772
type: Socket
7873
{{- end }}
79-
{{- if eq $Values.imageBuilderType "dind" }}
74+
{{- if eq .Values.imageBuilderType "dind" }}
8075
- name: storage-dind
8176
hostPath:
8277
path: {{ .Values.dind.hostLibDir }}
@@ -86,7 +81,7 @@ spec:
8681
path: {{ .Values.dind.hostSocketDir }}/docker.sock
8782
type: Socket
8883
{{- end }}
89-
{{- if eq $Values.imageBuilderType "pink" }}
84+
{{- if eq .Values.imageBuilderType "pink" }}
9085
- name: storage-pink
9186
hostPath:
9287
path: {{ .Values.pink.hostStorageDir }}
@@ -96,5 +91,4 @@ spec:
9691
path: {{ .Values.pink.hostSocketDir }}/podman.sock
9792
type: Socket
9893
{{- end }}
99-
10094
{{- end }}

helm-chart/binderhub/values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ deployment:
248248
timeoutSeconds: 10
249249
labels: {}
250250

251-
imageBuilderType: "local"
251+
imageBuilderType: "host"
252252

253253
dind:
254254
initContainers: []
@@ -300,8 +300,8 @@ imageCleaner:
300300
imageGCThresholdHigh: 80
301301
imageGCThresholdLow: 60
302302
# cull images on the host docker as well as dind
303+
# configuration to use if `imageBuilderType: host` is configured
303304
host:
304-
enabled: true
305305
dockerSocket: /var/run/docker.sock
306306
dockerLibDir: /var/lib/docker
307307

testing/k8s-binder-k8s-hub/binderhub-chart-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ ingress:
3333
# used actively in our CI system.
3434
enabled: true
3535

36-
# No in cluster builder to test the creation/update of the image-cleaner DaemonSet
36+
# No "in cluster" builder to test the creation/update of the image-cleaner DaemonSet
3737
# resource because it also requires us to setup a container registry to test
3838
# against which we haven't. We currently only test this through the use of
3939
# lint-and-validate-values.yaml and setting this value explicitly to make sure
4040
# our rendered templates are valid against a k8s api-server.
41-
imageBuilderType: "local"
41+
imageBuilderType: "host"
4242

4343
# NOTE: This is a mirror of the jupyterhub section in
4444
# jupyterhub-chart-config.yaml in testing/local-binder-k8s-hub, keep these

tools/templates/lint-and-validate-values.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ deployment:
8686
livenessProbe: *probe
8787
labels: *labels
8888

89-
imageBuilderType: local
89+
imageBuilderType: host
9090

9191
dind:
9292
initContainers: &initContainers
@@ -128,7 +128,6 @@ imageCleaner:
128128
imageGCThresholdHigh: 2
129129
imageGCThresholdLow: 1
130130
host:
131-
enabled: true
132131
dockerSocket: /var/run/docker.sock
133132
dockerLibDir: /var/lib/docker
134133

0 commit comments

Comments
 (0)