Skip to content

Commit 128daf1

Browse files
feat: empty dind requests (#367)
1 parent 2e704b1 commit 128daf1

File tree

7 files changed

+212
-16
lines changed

7 files changed

+212
-16
lines changed

charts/cf-runtime/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v2
22
description: A Helm chart for Codefresh Runner
33
name: cf-runtime
4-
version: 3.0.0
4+
version: 3.0.1
55
keywords:
66
- codefresh
77
- runner
@@ -15,7 +15,7 @@ maintainers:
1515
annotations:
1616
artifacthub.io/changes: |
1717
- kind: added
18-
description: Added runtime-environment template
18+
description: Added option to specify null requests for dind
1919
dependencies:
2020
- name: cf-common
2121
repository: https://chartmuseum.codefresh.io/cf-common

charts/cf-runtime/README.md

Lines changed: 103 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Codefresh Runner
22

3-
![Version: 3.0.0](https://img.shields.io/badge/Version-3.0.0-informational?style=flat-square)
3+
![Version: 3.0.1](https://img.shields.io/badge/Version-3.0.1-informational?style=flat-square)
44

55
Helm chart for deploying [Codefresh Runner](https://codefresh.io/docs/docs/installation/codefresh-runner/) to Kubernetes.
66

@@ -18,6 +18,7 @@ Helm chart for deploying [Codefresh Runner](https://codefresh.io/docs/docs/insta
1818
- [Custom volume mounts](#custom-volume-mounts)
1919
- [Custom global environment variables](#custom-global-environment-variables)
2020
- [Volume reuse policy](#volume-reuse-policy)
21+
- [Volume cleaners](#volume-cleaners)
2122

2223
## Prerequisites
2324

@@ -61,7 +62,7 @@ helm repo update
6162
codefresh runner execute-test-pipeline --runtime-name <runtime-name>
6263
```
6364

64-
## Upgrade chart
65+
## Upgrade Chart
6566

6667
### To 2.x
6768

@@ -275,6 +276,104 @@ Downside: More PVs to maintain and therefore higher costs.
275276

276277
- `reuseVolumeSelector: 'codefresh-app,io.codefresh.accountName,pipeline_id,trigger'` - PV can be used only by single pipeline AND single trigger.
277278
279+
### Volume cleaners
280+
281+
Codefresh pipelines require disk space for:
282+
* [Pipeline Shared Volume](https://codefresh.io/docs/docs/pipelines/introduction-to-codefresh-pipelines/#sharing-the-workspace-between-build-steps) (`/codefresh/volume`, implemented as [docker volume](https://docs.docker.com/storage/volumes/))
283+
* Docker containers, both running and stopped
284+
* Docker images and cached layers
285+
286+
Codefresh offers two options to manage disk space and prevent out-of-space errors:
287+
* Use runtime cleaners on Docker images and volumes
288+
* [Set the minimum disk space per pipeline build volume](https://codefresh.io/docs/docs/pipelines/pipelines/#set-minimum-disk-space-for-a-pipeline-build)
289+
290+
To improve performance by using Docker cache, Codefresh `volume-provisioner` can provision previously used disks with Docker images and pipeline volumes from previously run builds.
291+
292+
### Types of runtime volume cleaners
293+
294+
Docker images and volumes must be cleaned on a regular basis.
295+
296+
* [IN-DIND cleaner](https://github.com/codefresh-io/dind/tree/master/cleaner): Deletes extra Docker containers, volumes, and images in **DIND pod**.
297+
* [External volume cleaner](https://github.com/codefresh-io/dind-volume-cleanup): Deletes unused **external** PVs (EBS, GCE/Azure disks).
298+
* [Local volume cleaner](https://github.com/codefresh-io/dind-volume-utils/blob/master/local-volumes/lv-cleaner.sh): Deletes **local** volumes if node disk space is close to the threshold.
299+
300+
### IN-DIND cleaner
301+
302+
**Purpose:** Removes unneeded *docker containers, images, volumes* inside Kubernetes volume mounted on the DIND pod
303+
304+
**How it runs:** Inside each DIND pod as script
305+
306+
**Triggered by:** SIGTERM and also during the run when disk usage > 90% (configurable)
307+
308+
**Configured by:** Environment Variables which can be set in Runtime Environment spec
309+
310+
**Configuration/Logic:** [README.md](https://github.com/codefresh-io/dind/tree/master/cleaner#readme)
311+
312+
Override `.Values.runtime.dind.env` if necessary (the following are **defaults**):
313+
314+
```yaml
315+
runtime:
316+
dind:
317+
env:
318+
CLEAN_PERIOD_SECONDS: '21600' # launch clean if last clean was more than CLEAN_PERIOD_SECONDS seconds ago
319+
CLEAN_PERIOD_BUILDS: '5' # launch clean if last clean was more CLEAN_PERIOD_BUILDS builds since last build
320+
IMAGE_RETAIN_PERIOD: '14400' # do not delete docker images if they have events since current_timestamp - IMAGE_RETAIN_PERIOD
321+
VOLUMES_RETAIN_PERIOD: '14400' # do not delete docker volumes if they have events since current_timestamp - VOLUMES_RETAIN_PERIOD
322+
DISK_USAGE_THRESHOLD: '0.8' # launch clean based on current disk usage DISK_USAGE_THRESHOLD
323+
INODES_USAGE_THRESHOLD: '0.8' # launch clean based on current inodes usage INODES_USAGE_THRESHOLD
324+
```
325+
326+
### External volumes cleaner
327+
328+
**Purpose:** Removes unused *kubernetes volumes and related backend volumes*
329+
330+
**How it runs:** Runs as `dind-volume-cleanup` CronJob. Installed in case the Runner uses non-local volumes `.Values.storage.backend != local`
331+
332+
**Triggered by:** CronJob every 10min (configurable)
333+
334+
**Configuration:**
335+
336+
Set `codefresh.io/volume-retention` for dinds' PVCs:
337+
338+
```yaml
339+
runtime:
340+
dind:
341+
pvcs:
342+
- name: dind
343+
...
344+
annotations:
345+
codefresh.io/volume-retention: 7d
346+
```
347+
348+
Or override environment variables for `dind-volume-cleanup` cronjob:
349+
350+
```yaml
351+
volumeProvisioner:
352+
dind-volume-cleanup:
353+
env:
354+
RETENTION_DAYS: 7 # clean volumes that were last used more than `RETENTION_DAYS` (default is 4) ago
355+
```
356+
357+
### Local volumes cleaner
358+
359+
**Purpose:** Deletes local volumes when node disk space is close to the threshold
360+
361+
**How it runs:** Runs as `dind-lv-monitor` DaemonSet. Installed in case the Runner uses local volumes `.Values.storage.backend == local`
362+
363+
**Triggered by:** Disk space usage or inode usage that exceeds thresholds (configurable)
364+
365+
**Configuration:**
366+
367+
Override environment variables for `dind-lv-monitor` daemonset:
368+
369+
```yaml
370+
volumeProvisioner:
371+
dind-lv-monitor:
372+
env:
373+
KB_USAGE_THRESHOLD: 60 # default 80 (percentage)
374+
INODE_USAGE_THRESHOLD: 60 # default 80
375+
```
376+
278377
## Requirements
279378
280379
| Repository | Name | Version |
@@ -371,7 +470,7 @@ Downside: More PVs to maintain and therefore higher costs.
371470
| runner.tolerations | list | `[]` | Set tolerations |
372471
| runner.updateStrategy | object | `{"type":"RollingUpdate"}` | Upgrade strategy |
373472
| runtime | object | See below | Set runtime parameters |
374-
| runtime.dind | object | `{"affinity":{},"env":{},"image":{"registry":"quay.io","repository":"codefresh/dind","tag":"20.10.18-1.25.7"},"nodeSelector":{},"podAnnotations":{},"pvcs":[{"name":"dind","reuseVolumeSelector":"codefresh-app,io.codefresh.accountName","reuseVolumeSortOrder":"pipeline_id","storageClassName":"{{ include \"dind-volume-provisioner.storageClassName\" . }}","volumeSize":"16Gi"}],"resources":{"limits":{"cpu":"400m","memory":"800Mi"},"requests":{"cpu":"400m","memory":"800Mi"}},"schedulerName":"","serviceAccount":"codefresh-engine","tolerations":[],"userAccess":true,"userVolumeMounts":{},"userVolumes":{}}` | Parameters for DinD (docker-in-docker) pod (aka "runtime" pod). |
473+
| runtime.dind | object | `{"affinity":{},"env":{},"image":{"registry":"quay.io","repository":"codefresh/dind","tag":"20.10.18-1.25.7"},"nodeSelector":{},"podAnnotations":{},"pvcs":[{"name":"dind","reuseVolumeSelector":"codefresh-app,io.codefresh.accountName","reuseVolumeSortOrder":"pipeline_id","storageClassName":"{{ include \"dind-volume-provisioner.storageClassName\" . }}","volumeSize":"16Gi"}],"resources":{"limits":{"cpu":"400m","memory":"800Mi"},"requests":null},"schedulerName":"","serviceAccount":"codefresh-engine","tolerations":[],"userAccess":true,"userVolumeMounts":{},"userVolumes":{}}` | Parameters for DinD (docker-in-docker) pod (aka "runtime" pod). |
375474
| runtime.dind.affinity | object | `{}` | Set affinity |
376475
| runtime.dind.env | object | `{}` | Set additional env vars. |
377476
| runtime.dind.image | object | `{"registry":"quay.io","repository":"codefresh/dind","tag":"20.10.18-1.25.7"}` | Set dind image. |
@@ -382,7 +481,7 @@ Downside: More PVs to maintain and therefore higher costs.
382481
| runtime.dind.pvcs[0].reuseVolumeSelector | string | `"codefresh-app,io.codefresh.accountName"` | PV reuse selector. Ref: https://codefresh.io/docs/docs/installation/codefresh-runner/#volume-reuse-policy |
383482
| runtime.dind.pvcs[0].storageClassName | string | `"{{ include \"dind-volume-provisioner.storageClassName\" . }}"` | PVC storage class name. Change ONLY if you need to use storage class NOT from Codefresh volume-provisioner |
384483
| runtime.dind.pvcs[0].volumeSize | string | `"16Gi"` | PVC size. |
385-
| runtime.dind.resources | object | `{"limits":{"cpu":"400m","memory":"800Mi"},"requests":{"cpu":"400m","memory":"800Mi"}}` | Set dind resources. |
484+
| runtime.dind.resources | object | `{"limits":{"cpu":"400m","memory":"800Mi"},"requests":null}` | Set dind resources. |
386485
| runtime.dind.schedulerName | string | `""` | Set scheduler name. |
387486
| runtime.dind.serviceAccount | string | `"codefresh-engine"` | Set service account for pod. |
388487
| runtime.dind.tolerations | list | `[]` | Set tolerations. |

charts/cf-runtime/README.md.gotmpl

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Helm chart for deploying [Codefresh Runner](https://codefresh.io/docs/docs/insta
1818
- [Custom volume mounts](#custom-volume-mounts)
1919
- [Custom global environment variables](#custom-global-environment-variables)
2020
- [Volume reuse policy](#volume-reuse-policy)
21+
- [Volume cleaners](#volume-cleaners)
2122

2223
## Prerequisites
2324

@@ -61,7 +62,7 @@ helm repo update
6162
codefresh runner execute-test-pipeline --runtime-name <runtime-name>
6263
```
6364

64-
## Upgrade chart
65+
## Upgrade Chart
6566

6667
### To 2.x
6768

@@ -275,6 +276,103 @@ Downside: More PVs to maintain and therefore higher costs.
275276

276277
- `reuseVolumeSelector: 'codefresh-app,io.codefresh.accountName,pipeline_id,trigger'` - PV can be used only by single pipeline AND single trigger.
277278

279+
### Volume cleaners
280+
281+
Codefresh pipelines require disk space for:
282+
* [Pipeline Shared Volume](https://codefresh.io/docs/docs/pipelines/introduction-to-codefresh-pipelines/#sharing-the-workspace-between-build-steps) (`/codefresh/volume`, implemented as [docker volume](https://docs.docker.com/storage/volumes/))
283+
* Docker containers, both running and stopped
284+
* Docker images and cached layers
285+
286+
Codefresh offers two options to manage disk space and prevent out-of-space errors:
287+
* Use runtime cleaners on Docker images and volumes
288+
* [Set the minimum disk space per pipeline build volume](https://codefresh.io/docs/docs/pipelines/pipelines/#set-minimum-disk-space-for-a-pipeline-build)
289+
290+
To improve performance by using Docker cache, Codefresh `volume-provisioner` can provision previously used disks with Docker images and pipeline volumes from previously run builds.
291+
292+
### Types of runtime volume cleaners
293+
294+
Docker images and volumes must be cleaned on a regular basis.
295+
296+
* [IN-DIND cleaner](https://github.com/codefresh-io/dind/tree/master/cleaner): Deletes extra Docker containers, volumes, and images in **DIND pod**.
297+
* [External volume cleaner](https://github.com/codefresh-io/dind-volume-cleanup): Deletes unused **external** PVs (EBS, GCE/Azure disks).
298+
* [Local volume cleaner](https://github.com/codefresh-io/dind-volume-utils/blob/master/local-volumes/lv-cleaner.sh): Deletes **local** volumes if node disk space is close to the threshold.
299+
300+
### IN-DIND cleaner
301+
302+
**Purpose:** Removes unneeded *docker containers, images, volumes* inside Kubernetes volume mounted on the DIND pod
303+
304+
**How it runs:** Inside each DIND pod as script
305+
306+
**Triggered by:** SIGTERM and also during the run when disk usage > 90% (configurable)
307+
308+
**Configured by:** Environment Variables which can be set in Runtime Environment spec
309+
310+
**Configuration/Logic:** [README.md](https://github.com/codefresh-io/dind/tree/master/cleaner#readme)
311+
312+
Override `.Values.runtime.dind.env` if necessary (the following are **defaults**):
313+
314+
```yaml
315+
runtime:
316+
dind:
317+
env:
318+
CLEAN_PERIOD_SECONDS: '21600' # launch clean if last clean was more than CLEAN_PERIOD_SECONDS seconds ago
319+
CLEAN_PERIOD_BUILDS: '5' # launch clean if last clean was more CLEAN_PERIOD_BUILDS builds since last build
320+
IMAGE_RETAIN_PERIOD: '14400' # do not delete docker images if they have events since current_timestamp - IMAGE_RETAIN_PERIOD
321+
VOLUMES_RETAIN_PERIOD: '14400' # do not delete docker volumes if they have events since current_timestamp - VOLUMES_RETAIN_PERIOD
322+
DISK_USAGE_THRESHOLD: '0.8' # launch clean based on current disk usage DISK_USAGE_THRESHOLD
323+
INODES_USAGE_THRESHOLD: '0.8' # launch clean based on current inodes usage INODES_USAGE_THRESHOLD
324+
```
325+
326+
### External volumes cleaner
327+
328+
**Purpose:** Removes unused *kubernetes volumes and related backend volumes*
329+
330+
**How it runs:** Runs as `dind-volume-cleanup` CronJob. Installed in case the Runner uses non-local volumes `.Values.storage.backend != local`
331+
332+
**Triggered by:** CronJob every 10min (configurable)
333+
334+
**Configuration:**
335+
336+
Set `codefresh.io/volume-retention` for dinds' PVCs:
337+
338+
```yaml
339+
runtime:
340+
dind:
341+
pvcs:
342+
- name: dind
343+
...
344+
annotations:
345+
codefresh.io/volume-retention: 7d
346+
```
347+
348+
Or override environment variables for `dind-volume-cleanup` cronjob:
349+
350+
```yaml
351+
volumeProvisioner:
352+
dind-volume-cleanup:
353+
env:
354+
RETENTION_DAYS: 7 # clean volumes that were last used more than `RETENTION_DAYS` (default is 4) ago
355+
```
356+
357+
### Local volumes cleaner
358+
359+
**Purpose:** Deletes local volumes when node disk space is close to the threshold
360+
361+
**How it runs:** Runs as `dind-lv-monitor` DaemonSet. Installed in case the Runner uses local volumes `.Values.storage.backend == local`
362+
363+
**Triggered by:** Disk space usage or inode usage that exceeds thresholds (configurable)
364+
365+
**Configuration:**
366+
367+
Override environment variables for `dind-lv-monitor` daemonset:
368+
369+
```yaml
370+
volumeProvisioner:
371+
dind-lv-monitor:
372+
env:
373+
KB_USAGE_THRESHOLD: 60 # default 80 (percentage)
374+
INODE_USAGE_THRESHOLD: 60 # default 80
375+
```
278376

279377
{{ template "chart.requirementsSection" . }}
280378

charts/cf-runtime/templates/runtime/runtime-env-spec-tmpl.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,13 @@ dockerDaemonScheduler:
9494
{{- end }}
9595
defaultDindResources:
9696
{{- with $dindContext.resources }}
97+
{{- if not .requests }}
98+
limits: {{- toYaml .limits | nindent 6 }}
99+
requests: null
100+
{{- else }}
97101
{{- toYaml . | nindent 4 }}
98102
{{- end }}
103+
{{- end }}
99104
{{- with $dindContext.terminationGracePeriodSeconds }}
100105
terminationGracePeriodSeconds: {{ . }}
101106
{{- end }}

charts/cf-runtime/tests/runtime/runtime_test.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ tests:
128128
limits:
129129
cpu: 1000m
130130
memory: 2048Mi
131-
requests:
132-
cpu: 1000m
133-
memory: 2048Mi
131+
requests: null
134132
userVolumeMounts:
135133
my-cert:
136134
mountPath: /etc/ssl/cert

charts/cf-runtime/tests/runtime/runtime_values.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ runtime:
33
image:
44
tag: tagoverride
55
resources:
6-
requests:
7-
cpu: 1000m
8-
memory: 2048Mi
6+
requests: null
97
limits:
108
cpu: 1000m
119
memory: 2048Mi

charts/cf-runtime/values.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,7 @@ runtime:
379379
tag: 20.10.18-1.25.7
380380
# -- Set dind resources.
381381
resources:
382-
requests:
383-
cpu: 400m
384-
memory: 800Mi
382+
requests: null
385383
limits:
386384
cpu: 400m
387385
memory: 800Mi

0 commit comments

Comments
 (0)