Skip to content

Commit 2e704b1

Browse files
feat: add runtime spec template (#363)
1 parent 199edb3 commit 2e704b1

31 files changed

+1151
-64
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
* [venonactl](venonactl/README.md) - Codefresh installer of Kubernetes YAML's. [![Codefresh build status]( https://g.codefresh.io/api/badges/pipeline/codefresh-inc/codefresh-io%2Fvenona%2Fvenonactl-ci?type=cf-1)]( https://g.codefresh.io/public/accounts/codefresh-inc/pipelines/new/5c336db4c67fe44c098c9cd3)
2-
* [venona](venona/README.md) - Codefresh runner process, [official docs](https://codefresh.io/docs/docs/administration/codefresh-runner/). [![Codefresh build status]( https://g.codefresh.io/api/badges/pipeline/codefresh-inc/codefresh-io%2Fvenona%2Fvenona-ci?type=cf-1&key=eyJhbGciOiJIUzI1NiJ9.NTY3MmQ4ZGViNjcyNGI2ZTM1OWFkZjYy.AN2wExsAsq7FseTbVxxWls8muNx_bBUnQWQVS8IgDTI)]( https://g.codefresh.io/pipelines/edit/new/builds?id=5edde99dcf40d573569eab9b&pipeline=venona-ci&projects=codefresh-io%2Fvenona&projectId=5c98d41cbd5b6f40758ee49c)
1+
* [venonactl](venonactl/README.md) - Codefresh installer of Kubernetes YAML's.
2+
* [venona](venona/README.md) - Codefresh runner process, [official docs](https://codefresh.io/docs/docs/administration/codefresh-runner/).

charts/cf-runtime/.ci/values-ci.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Values used in `helm-chart-ci` pipeline
2+
global:
3+
codefreshToken: placeholder
24
appProxy:
35
enabled: true
46
ingress:
@@ -10,3 +12,38 @@ monitor:
1012
rbac:
1113
namespaced: true
1214
runner: {}
15+
runtime:
16+
dind:
17+
resources:
18+
requests:
19+
cpu: 100m
20+
memory: 128Mi
21+
limits:
22+
cpu: 1001m
23+
memory: 1024Mi
24+
podAnnotations:
25+
karpenter.sh/do-not-evict: 'true'
26+
nodeSelector:
27+
node-type: dind
28+
tolerations:
29+
- effect: NoSchedule
30+
key: codefresh.io
31+
operator: Equal
32+
value: dinds
33+
engine:
34+
resources:
35+
requests:
36+
cpu: 100m
37+
memory: 128Mi
38+
limits:
39+
cpu: 1000m
40+
memory: 1024Mi
41+
podAnnotations:
42+
karpenter.sh/do-not-evict: 'true'
43+
nodeSelector:
44+
node-type: engine
45+
tolerations:
46+
- effect: NoSchedule
47+
key: codefresh.io
48+
operator: Equal
49+
value: engines

charts/cf-runtime/Chart.yaml

Lines changed: 2 additions & 4 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: 2.0.1
4+
version: 3.0.0
55
keywords:
66
- codefresh
77
- runner
@@ -15,9 +15,7 @@ maintainers:
1515
annotations:
1616
artifacthub.io/changes: |
1717
- kind: added
18-
description: Major templates refactor
19-
- kind: fixed
20-
description: Initial helm unit tests
18+
description: Added runtime-environment template
2119
dependencies:
2220
- name: cf-common
2321
repository: https://chartmuseum.codefresh.io/cf-common

charts/cf-runtime/README.md

Lines changed: 175 additions & 17 deletions
Large diffs are not rendered by default.

charts/cf-runtime/README.md.gotmpl

Lines changed: 125 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22

33
{{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}{{ template "chart.appVersionBadge" . }}
44

5+
Helm chart for deploying [Codefresh Runner](https://codefresh.io/docs/docs/installation/codefresh-runner/) to Kubernetes.
6+
7+
## Table of Content
8+
9+
- [Prerequisites](#prerequisites)
10+
- [Get Repo Info](#get-repo-info)
11+
- [Install Chart](#install-chart)
12+
- [Upgrade Chart](#upgrade-chart)
13+
- [To 2.x](#to-2x)
14+
- [To 3.x](#to-3x)
15+
- [Architecture](#architecture)
16+
- [Configuration](#configuration)
17+
- [EBS backend volume configuration](#ebs-backend-volume-configuration)
18+
- [Custom volume mounts](#custom-volume-mounts)
19+
- [Custom global environment variables](#custom-global-environment-variables)
20+
- [Volume reuse policy](#volume-reuse-policy)
21+
522
## Prerequisites
623

724
- Kubernetes **1.19+**
@@ -34,11 +51,53 @@ helm repo update
3451

3552
helm upgrade --install cf-runtime cf-runtime/cf-runtime -f ./generated_values.yaml --create-namespace --namespace codefresh
3653
```
54+
55+
*Install from OCI-based registry*
56+
```console
57+
helm upgrade --install cf-runtime oci://quay.io/codefresh/cf-runtime -f ./generated_values.yaml --create-namespace --namespace codefresh
58+
```
3759
4. At this point you should have a working Codefresh Runner. You can verify the installation by running:
3860
```console
3961
codefresh runner execute-test-pipeline --runtime-name <runtime-name>
4062
```
4163

64+
## Upgrade chart
65+
66+
### To 2.x
67+
68+
This major release renames and deprecated several values in the chart. Most of the workload templates have been refactored.
69+
70+
Affected values:
71+
- `dockerRegistry` is deprecated. Replaced with `global.imageRegistry`
72+
- `re` is renamed to `runtime`
73+
- `storage.localVolumeMonitor` is replaced with `volumeProvisioner.dind-lv-monitor`
74+
- `volumeProvisioner.volume-cleanup` is replaced with `volumeProvisioner.dind-volume-cleanup`
75+
- `image` values structure has been updated. Split to `image.registry` `image.repository` `image.tag`
76+
- pod's `annotations` is renamed to `podAnnotations`
77+
78+
### To 3.x
79+
80+
⚠️⚠️⚠️
81+
### Please, READ this before the upgrade!
82+
83+
This major release adds [runtime-environment](https://codefresh.io/docs/docs/installation/codefresh-runner/#runtime-environment-specification) spec into chart templates.
84+
That means it is possible to set parametes for `dind` and `engine` pods via [values.yaml](./values.yaml).
85+
86+
**If you had any overrides (i.e. tolerations/nodeSelector/environment variables/etc) added in runtime spec via [codefresh CLI](https://codefresh-io.github.io/cli/) (for example, you did use [get](https://codefresh-io.github.io/cli/runtime-environments/get-runtime-environments/) and [patch](https://codefresh-io.github.io/cli/runtime-environments/apply-runtime-environments/) commands to modify the runtime-environment), you MUST add these into chart's [values.yaml](./values.yaml) for `.Values.runtime.dind` or(and) .`Values.runtime.engine`**
87+
88+
**For backward compatibility, you can disable updating runtime-environment spec via** `.Values.runtime.patch.enabled=false`
89+
90+
Affected values:
91+
- added **mandatory** `global.codefresh.codefreshToken`/`global.codefresh.codefreshTokenSecretKeyRef` **You must specify it before the upgrade!**
92+
- `runtime.engine` is added
93+
- `runtime.dind` is added
94+
- `global.existingAgentToken` is replaced with `global.agentTokenSecretKeyRef`
95+
- `global.existingDindCertsSecret` is replaced with `global.dindCertsSecretRef`
96+
97+
## Architecture
98+
99+
[Codefresh Runner architecture](https://codefresh.io/docs/docs/installation/codefresh-runner/#codefresh-runner-architecture)
100+
42101
## Configuration
43102

44103
See [Customizing the Chart Before Installing](https://helm.sh/docs/intro/using_helm/#customizing-the-chart-before-installing). To see all configurable options with detailed comments, visit the chart's [values.yaml](./values.yaml), or run these configuration commands:
@@ -148,21 +207,76 @@ volumeProvisioner:
148207
eks.amazonaws.com/role-arn: "arn:aws:iam::<ACCOUNT_ID>:role/<IAM_ROLE_NAME>"
149208
```
150209

151-
{{ template "chart.requirementsSection" . }}
210+
### Custom volume mounts
152211

153-
## Upgrading
212+
You can add your own volumes and volume mounts in the runtime environment, so that all pipeline steps will have access to the same set of external files.
154213

155-
### To 2.0.0
214+
```yaml
215+
runtime:
216+
dind:
217+
userVolumes:
218+
regctl-docker-registry:
219+
name: regctl-docker-registry
220+
secret:
221+
items:
222+
- key: .dockerconfigjson
223+
path: config.json
224+
secretName: regctl-docker-registry
225+
optional: true
226+
userVolumeMounts:
227+
regctl-docker-registry:
228+
name: regctl-docker-registry
229+
mountPath: /home/appuser/.docker/
230+
readOnly: true
156231

157-
This major release renames and deprecated several values in the chart. Most of the workload templates have been refactored.
232+
```
158233

159-
Affected values:
160-
- `dockerRegistry` is deprecated. Replaced with `global.imageRegistry`
161-
- `re` is renamed to `runtime`
162-
- `storage.localVolumeMonitor` is replaced with `volumeProvisioner.dind-lv-monitor`
163-
- `volumeProvisioner.volume-cleanup` is replaced with `volumeProvisioner.dind-volume-cleanup`
164-
- `image` values structure has been updated. Split to `image.registry` `image.repository` `image.tag`
165-
- pod's `annotations` is renamed to `podAnnotations`
234+
### Custom global environment variables
235+
236+
You can add your own environment variables to the runtime environment. All pipeline steps have access to the global variables.
237+
238+
```yaml
239+
runtime:
240+
engine:
241+
userEnvVars:
242+
- name: GITHUB_TOKEN
243+
valueFrom:
244+
secretKeyRef:
245+
name: github-token
246+
key: token
247+
```
248+
249+
### Volume reuse policy
250+
251+
Volume reuse behavior depends on the configuration for `reuseVolumeSelector` in the runtime environment spec.
252+
253+
```yaml
254+
runtime:
255+
dind:
256+
pvcs:
257+
- name: dind
258+
...
259+
reuseVolumeSelector: 'codefresh-app,io.codefresh.accountName'
260+
reuseVolumeSortOrder: pipeline_id
261+
```
262+
263+
The following options are available:
264+
- `reuseVolumeSelector: 'codefresh-app,io.codefresh.accountName'` - PV can be used by ANY pipeline in the specified account (default).
265+
Benefit: Fewer PVs, resulting in lower costs. Since any PV can be used by any pipeline, the cluster needs to maintain/reserve fewer PVs in its PV pool for Codefresh.
266+
Downside: Since the PV can be used by any pipeline, the PVs could have assets and info from different pipelines, reducing the probability of cache.
267+
268+
- `reuseVolumeSelector: 'codefresh-app,io.codefresh.accountName,project_id'` - PV can be used by ALL pipelines in your account, assigned to the same project.
269+
270+
- `reuseVolumeSelector: 'codefresh-app,io.codefresh.accountName,pipeline_id'` - PV can be used only by a single pipeline.
271+
Benefit: More probability of cache without “spam” from other pipelines.
272+
Downside: More PVs to maintain and therefore higher costs.
273+
274+
- `reuseVolumeSelector: 'codefresh-app,io.codefresh.accountName,pipeline_id,io.codefresh.branch_name'` - PV can be used only by single pipeline AND single branch.
275+
276+
- `reuseVolumeSelector: 'codefresh-app,io.codefresh.accountName,pipeline_id,trigger'` - PV can be used only by single pipeline AND single trigger.
277+
278+
279+
{{ template "chart.requirementsSection" . }}
166280

167281
{{ template "chart.valuesSection" . }}
168282

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{ $cfCommonTplSemver := printf "cf-common-%s" (index .Subcharts "cf-common").Chart.Version }}
2+
{{ $values := .Values.runtime.engine.runtimeImages }}
3+
---
4+
kind: ConfigMap
5+
apiVersion: v1
6+
metadata:
7+
{{- /* template just to list runtime images */}}
8+
name: {{ include "runtime.fullname" . }}-images
9+
labels:
10+
{{- include "runtime.labels" . | nindent 4 }}
11+
annotations:
12+
{{- with $values.annotations }}
13+
{{- toYaml . | nindent 4 }}
14+
{{- end }}
15+
data:
16+
images: |
17+
{{- range $key, $val := $values }}
18+
image: {{ $val }}
19+
{{- end }}

charts/cf-runtime/templates/runtime/_helpers.tpl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,35 @@ Selector labels
2929
{{ include "cf-runtime.selectorLabels" . }}
3030
codefresh.io/application: runtime
3131
{{- end }}
32+
33+
{{/*
34+
Return runtime image (classic runtime) with private registry prefix
35+
*/}}
36+
{{- define "runtime.runtimeImageName" -}}
37+
{{- if .registry -}}
38+
{{- $imageName := (trimPrefix "quay.io/" .imageFullName) -}}
39+
{{- printf "%s/%s" .registry $imageName -}}
40+
{{- else -}}
41+
{{- printf "%s" .imageFullName -}}
42+
{{- end -}}
43+
{{- end -}}
44+
45+
{{/*
46+
Environment variable value of Codefresh installation token
47+
*/}}
48+
{{- define "runtime.installation-token-env-var-value" -}}
49+
{{- if .Values.global.codefreshToken }}
50+
valueFrom:
51+
secretKeyRef:
52+
name: {{ include "runtime.installation-token-secret-name" . }}
53+
key: codefresh-api-token
54+
{{- else if .Values.global.codefreshTokenSecretKeyRef }}
55+
valueFrom:
56+
secretKeyRef:
57+
{{- .Values.global.codefreshTokenSecretKeyRef | toYaml | nindent 4 }}
58+
{{- end }}
59+
{{- end }}
60+
61+
{{- define "runtime.installation-token-secret-name" }}
62+
{{- print "codefresh-user-token" }}
63+
{{- end }}

charts/cf-runtime/templates/runtime/codefresh-certs-server-secret.yaml renamed to charts/cf-runtime/templates/runtime/dind-certs-secret.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if (not .Values.global.existingDindCertsSecret ) }}
1+
{{- if or (not .Values.global.existingDindCertsSecret ) (not .Values.global.dindCertsSecretRef) }}
22
apiVersion: v1
33
type: Opaque
44
kind: Secret

0 commit comments

Comments
 (0)