Skip to content

Commit 64fec2d

Browse files
Enrichment process templates and values (#14)
* add enrichment manifests
1 parent 21284aa commit 64fec2d

17 files changed

+382
-15
lines changed

charts/gitops-runtime/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
appVersion: v0.0.1
33
description: A Helm chart for Codefresh gitops runtime
44
name: gitops-runtime
5-
version: 0.2.0-alpha-6
5+
version: 0.2.0-alpha-7
66
home: https://github.com/codefresh-io/gitops-runtime-helm
77
keywords:
88
- codefresh

charts/gitops-runtime/README.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# gitops-runtime
22

3-
![Version: 0.2.0-alpha-6](https://img.shields.io/badge/Version-0.2.0--alpha--6-informational?style=flat-square) ![AppVersion: v0.0.1](https://img.shields.io/badge/AppVersion-v0.0.1-informational?style=flat-square)
3+
![Version: 0.2.0-alpha-7](https://img.shields.io/badge/Version-0.2.0--alpha--7-informational?style=flat-square) ![AppVersion: v0.0.1](https://img.shields.io/badge/AppVersion-v0.0.1-informational?style=flat-square)
44

55
A Helm chart for Codefresh gitops runtime
66

@@ -33,6 +33,19 @@ A Helm chart for Codefresh gitops runtime
3333
| app-proxy.config.env | string | `"production"` | |
3434
| app-proxy.env | object | `{}` | |
3535
| app-proxy.fullnameOverride | string | `"cap-app-proxy"` | |
36+
| app-proxy.image-enrichment | object | `{"config":{"clientHeartbeatIntervalInSeconds":5,"concurrencyCmKey":"imageReportExecutor","concurrencyCmName":"workflow-synchronization-semaphores","podGcStrategy":"OnWorkflowCompletion","ttlActiveInSeconds":900,"ttlAfterCompletionInSeconds":86400},"enabled":true,"serviceAccount":{"annotations":null,"create":true,"name":"codefresh-image-enrichment-sa"}}` | Image enrichment process configuration |
37+
| app-proxy.image-enrichment.config | object | `{"clientHeartbeatIntervalInSeconds":5,"concurrencyCmKey":"imageReportExecutor","concurrencyCmName":"workflow-synchronization-semaphores","podGcStrategy":"OnWorkflowCompletion","ttlActiveInSeconds":900,"ttlAfterCompletionInSeconds":86400}` | Configurations for image enrichment workflow |
38+
| app-proxy.image-enrichment.config.clientHeartbeatIntervalInSeconds | int | `5` | Client heartbeat interval in seconds for image enrichemnt workflow |
39+
| app-proxy.image-enrichment.config.concurrencyCmKey | string | `"imageReportExecutor"` | The name of the key in the configmap to use as synchronization semaphore |
40+
| app-proxy.image-enrichment.config.concurrencyCmName | string | `"workflow-synchronization-semaphores"` | The name of the configmap to use as synchronization semaphore, see https://argoproj.github.io/argo-workflows/synchronization/ |
41+
| app-proxy.image-enrichment.config.podGcStrategy | string | `"OnWorkflowCompletion"` | Pod grabage collection strategy. By default all pods will be deleted when the enrichment workflow completes. |
42+
| app-proxy.image-enrichment.config.ttlActiveInSeconds | int | `900` | Maximum allowed runtime for the enrichment workflow |
43+
| app-proxy.image-enrichment.config.ttlAfterCompletionInSeconds | int | `86400` | Number of seconds to live after completion |
44+
| app-proxy.image-enrichment.enabled | bool | `true` | Enable or disable enrichment process. Please note that for enrichemnt, argo-workflows has to be enabled as well. |
45+
| app-proxy.image-enrichment.serviceAccount | object | `{"annotations":null,"create":true,"name":"codefresh-image-enrichment-sa"}` | Service account that will be used for enrichemnt process |
46+
| app-proxy.image-enrichment.serviceAccount.annotations | string | `nil` | Annotations on the service account |
47+
| app-proxy.image-enrichment.serviceAccount.create | bool | `true` | Whether to create the service account or use an existing one |
48+
| app-proxy.image-enrichment.serviceAccount.name | string | `"codefresh-image-enrichment-sa"` | Name of the service account to create or the name of the existing one to use |
3649
| app-proxy.image.pullPolicy | string | `"IfNotPresent"` | |
3750
| app-proxy.image.repository | string | `"quay.io/codefresh/cap-app-proxy"` | |
3851
| app-proxy.image.tag | string | `"1.2142.0"` | |

charts/gitops-runtime/templates/_components/cap-app-proxy/_config.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,16 @@ data:
1010
argoCdUsername: {{ .Values.config.argoCdUsername }}
1111
argoWorkflowsInsecure: {{ .Values.config.argoWorkflowsInsecure | quote }}
1212
env: {{ .Values.config.env }}
13+
argoWorkflowsUrl: {{ default "" .Values.config.argoWorkflowsUrl }}
1314
runtimeName: {{ .Values.global.runtime.name }}
15+
{{- $enrichmentValues := get .Values "image-enrichment" }}
16+
{{- if $enrichmentValues.enabled }}
17+
enrichmentConcurrencyCmName: {{ $enrichmentValues.config.concurrencyCmName }}
18+
enrichmentConcurrencyCmKey: {{ $enrichmentValues.config.concurrencyCmKey }}
19+
enrichmentServiceAccountName: {{ $enrichmentValues.serviceAccount.name }}
20+
enrichmentPodGcStrategy: {{ $enrichmentValues.config.podGcStrategy }}
21+
enrichmentTtlAfterCompletionInSeconds: {{ $enrichmentValues.config.ttlAfterCompletionInSeconds }}
22+
enrichmentTtlActiveInSeconds: {{ $enrichmentValues.config.ttlActiveInSeconds }}
23+
enrichmentClientHeartbeatIntervalInSeconds: {{ $enrichmentValues.config.clientHeartbeatIntervalInSeconds }}
24+
{{- end }}
1425
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{- define "cap-app-proxy.image-enrichment.resources.role-binding" }}
2+
{{- $enrichmentValues := get .Values "image-enrichment" }}
3+
apiVersion: rbac.authorization.k8s.io/v1
4+
kind: RoleBinding
5+
metadata:
6+
name: {{ include "cap-app-proxy.fullname" . }}-enrichment
7+
labels:
8+
{{- include "cap-app-proxy.labels" . | nindent 4 }}
9+
roleRef:
10+
apiGroup: ""
11+
kind: Role
12+
name: {{ include "cap-app-proxy.fullname" . }}-enrichment
13+
subjects:
14+
- kind: ServiceAccount
15+
name: {{ $enrichmentValues.serviceAccount.name }}
16+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{{- define "cap-app-proxy.image-enrichment.resources.role" }}
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: Role
4+
metadata:
5+
name: {{ include "cap-app-proxy.fullname" . }}-enrichment
6+
labels:
7+
{{- include "cap-app-proxy.labels" . | nindent 4 }}
8+
rules:
9+
- apiGroups:
10+
- "*"
11+
resources:
12+
- "*"
13+
verbs:
14+
- "*"
15+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{{- define "cap-app-proxy.image-enrichment.resources.sa" }}
2+
{{- $enrichmentValues := get .Values "image-enrichment" }}
3+
{{- if $enrichmentValues.serviceAccount.create }}
4+
apiVersion: v1
5+
kind: ServiceAccount
6+
metadata:
7+
name: {{ $enrichmentValues.serviceAccount.name }}
8+
labels:
9+
{{- include "cap-app-proxy.labels" . | nindent 4 }}
10+
{{- with $enrichmentValues.serviceAccount.annotations }}
11+
annotations:
12+
{{- toYaml . | nindent 4 }}
13+
{{- end }}
14+
{{- end }}
15+
{{- end }}

charts/gitops-runtime/templates/_components/cap-app-proxy/environment-variables/_main-container.yaml

+42
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,48 @@ STRIP_PREFIX:
103103
name: cap-app-proxy-cm
104104
key: stripPrefix
105105
optional: true
106+
IRW_SERVICE_ACCOUNT:
107+
valueFrom:
108+
configMapKeyRef:
109+
name: cap-app-proxy-cm
110+
key: enrichmentServiceAccountName
111+
optional: true
112+
IRW_CONCURRENCY_CM_NAME:
113+
valueFrom:
114+
configMapKeyRef:
115+
name: cap-app-proxy-cm
116+
key: enrichmentConcurrencyCmName
117+
optional: true
118+
IRW_CONCURRENCY_CM_KEY:
119+
valueFrom:
120+
configMapKeyRef:
121+
name: cap-app-proxy-cm
122+
key: enrichmentConcurrencyCmKey
123+
optional: true
124+
IRW_POD_GC_STRATEGY:
125+
valueFrom:
126+
configMapKeyRef:
127+
name: cap-app-proxy-cm
128+
key: enrichmentPodGcStrategy
129+
optional: true
130+
IRW_TTL_AFTER_COMPLETION_IN_SECONDS:
131+
valueFrom:
132+
configMapKeyRef:
133+
name: cap-app-proxy-cm
134+
key: enrichmentTtlAfterCompletionInSeconds
135+
optional: true
136+
IRW_TTL_ACTIVE_IN_SECONDS:
137+
valueFrom:
138+
configMapKeyRef:
139+
name: cap-app-proxy-cm
140+
key: enrichmentTtlActiveInSeconds
141+
optional: true
142+
IRW_HEARTBEAT_INTERVAL_IN_SECONDS:
143+
valueFrom:
144+
configMapKeyRef:
145+
name: cap-app-proxy-cm
146+
key: enrichmentClientHeartbeatIntervalInSeconds
147+
optional: true
106148
NODE_EXTRA_CA_CERTS: /app/config/all/all.cer
107149
{{- end -}}
108150

charts/gitops-runtime/templates/_helpers.tpl

+5-1
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,12 @@ Determine argo worklofws server name
136136
Determine argo workflows server url. Must be called with chart root context
137137
*/}}
138138
{{- define "codefresh-gitops-runtime.argo-workflows.server.url" -}}
139+
{{- $protocol := "http" }}
140+
{{- if index (get .Values "argo-workflows") "server" "secure" }}
141+
{{- $protocol = "https" }}
142+
{{- end -}}
139143
{{/* For now use template from Argo workflows chart until better approach */}}
140-
{{- printf "https://%s:2746" (include "codefresh-gitops-runtime.argo-workflows.server.name" .) }}
144+
{{- printf "%s://%s:2746" $protocol (include "codefresh-gitops-runtime.argo-workflows.server.name" .) }}
141145
{{- end }}
142146

143147
{{/*

charts/gitops-runtime/templates/app-proxy/config.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@
44
{{ $_ := set $appProxyContext "Values" (get .Values "app-proxy") }}
55
{{ $_ := set $appProxyContext.Values "global" (get .Values "global") }}
66
{{ $_ := set $appProxyContext.Values.config "argoCdUrl" $argoCdUrl }}
7+
{{- if index (get .Values "argo-workflows") "enabled" }}
8+
{{- $argoWorkflowsUrl := include "codefresh-gitops-runtime.argo-workflows.server.url" . }}
9+
{{- $_ := set $appProxyContext.Values.config "argoWorkflowsUrl" $argoWorkflowsUrl }}
10+
{{- end}}
711
{{- include "cap-app-proxy.resources.configmap" $appProxyContext }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{- if and (index (get .Values "app-proxy") "image-enrichment" "enabled") (not (index (get .Values "argo-workflows") "enabled")) }}
2+
{{- fail "ERROR: app-proxy.image-enrichment is enabled but argo-workflows is disabled. This is not suppurted. Either disable erichment or enable workflows"}}
3+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{{- $appProxyContext := deepCopy . }}
2+
{{- $_ := set $appProxyContext "Values" (get .Values "app-proxy") }}
3+
{{- $_ := set $appProxyContext.Values "global" (get .Values "global") }}
4+
{{- if (index (get $appProxyContext "Values") "image-enrichment" "enabled") }}
5+
{{- include "cap-app-proxy.image-enrichment.resources.role" $appProxyContext }}
6+
---
7+
{{- include "cap-app-proxy.image-enrichment.resources.role-binding" $appProxyContext }}
8+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{{- $appProxyContext := deepCopy . }}
2+
{{- $_ := set $appProxyContext "Values" (get .Values "app-proxy") }}
3+
{{- $_ := set $appProxyContext.Values "global" (get .Values "global") }}
4+
{{- if (index (get $appProxyContext "Values") "image-enrichment" "enabled") }}
5+
{{- include "cap-app-proxy.image-enrichment.resources.sa" $appProxyContext }}
6+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
suite: Test integration of outputs from Argo Project templates with components that use them in the runtime chart
2+
templates:
3+
- app-proxy/deployment.yaml
4+
- app-proxy/config.yaml
5+
- app-proxy/enrichment/sa.yaml
6+
- app-proxy/enrichment/rbac.yaml
7+
- app-proxy/enrichment/enforce-workflows-enabled.yaml
8+
tests:
9+
- it: Fail template if enrichment is enabled and workflows disabled
10+
template: 'app-proxy/enrichment/enforce-workflows-enabled.yaml'
11+
values:
12+
- ./values/mandatory-values.yaml
13+
set:
14+
argo-workflows.enabled: false
15+
app-proxy.image-enrichment.enabled: true
16+
asserts:
17+
- failedTemplate:
18+
errorMessage: 'app-proxy.image-enrichment is enabled but argo-workflows is disabled. This is not suppurted. Either disable erichment or enable workflows'
19+
20+
- it: Set correct values in app-proxy configmap
21+
template: 'app-proxy/config.yaml'
22+
values:
23+
- ./values/mandatory-values.yaml
24+
set:
25+
app-proxy.image-enrichment.enabled: true
26+
app-proxy.image-enrichment.config.concurrencyCmName: test
27+
app-proxy.image-enrichment.config.concurrencyCmKey: test
28+
app-proxy.image-enrichment.config.podGcStrategy: test
29+
app-proxy.image-enrichment.config.ttlAfterCompletionInSeconds: 1
30+
app-proxy.image-enrichment.config.ttlActiveInSeconds: 1
31+
app-proxy.image-enrichment.config.clientHeartbeatIntervalInSeconds: 1
32+
app-proxy.image-enrichment.serviceAccount.name: test
33+
asserts:
34+
- equal:
35+
path: data.enrichmentConcurrencyCmName
36+
value: test
37+
- equal:
38+
path: data.enrichmentConcurrencyCmKey
39+
value: test
40+
- equal:
41+
path: data.enrichmentPodGcStrategy
42+
value: test
43+
- equal:
44+
path: data.enrichmentTtlAfterCompletionInSeconds
45+
value: 1
46+
- equal:
47+
path: data.enrichmentTtlActiveInSeconds
48+
value: 1
49+
- equal:
50+
path: data.enrichmentClientHeartbeatIntervalInSeconds
51+
value: 1
52+
- equal:
53+
path: data.enrichmentServiceAccountName
54+
value: test
55+
56+
- it: app proxy environment variables set for enrichemnt and match the values in the configmap
57+
template: 'app-proxy/deployment.yaml'
58+
values:
59+
- ./values/mandatory-values.yaml
60+
set:
61+
app-proxy.image-enrichment.enabled: true
62+
asserts:
63+
- contains:
64+
path: spec.template.spec.containers[0].env
65+
content:
66+
name: IRW_CONCURRENCY_CM_NAME
67+
valueFrom:
68+
configMapKeyRef:
69+
name: cap-app-proxy-cm
70+
key: enrichmentConcurrencyCmName
71+
optional: true
72+
- contains:
73+
path: spec.template.spec.containers[0].env
74+
content:
75+
name: IRW_CONCURRENCY_CM_KEY
76+
valueFrom:
77+
configMapKeyRef:
78+
name: cap-app-proxy-cm
79+
key: enrichmentConcurrencyCmKey
80+
optional: true
81+
- contains:
82+
path: spec.template.spec.containers[0].env
83+
content:
84+
name: IRW_POD_GC_STRATEGY
85+
valueFrom:
86+
configMapKeyRef:
87+
name: cap-app-proxy-cm
88+
key: enrichmentPodGcStrategy
89+
optional: true
90+
- contains:
91+
path: spec.template.spec.containers[0].env
92+
content:
93+
name: IRW_TTL_AFTER_COMPLETION_IN_SECONDS
94+
valueFrom:
95+
configMapKeyRef:
96+
name: cap-app-proxy-cm
97+
key: enrichmentTtlAfterCompletionInSeconds
98+
optional: true
99+
- contains:
100+
path: spec.template.spec.containers[0].env
101+
content:
102+
name: IRW_TTL_ACTIVE_IN_SECONDS
103+
valueFrom:
104+
configMapKeyRef:
105+
name: cap-app-proxy-cm
106+
key: enrichmentTtlActiveInSeconds
107+
optional: true
108+
- contains:
109+
path: spec.template.spec.containers[0].env
110+
content:
111+
name: IRW_HEARTBEAT_INTERVAL_IN_SECONDS
112+
valueFrom:
113+
configMapKeyRef:
114+
name: cap-app-proxy-cm
115+
key: enrichmentClientHeartbeatIntervalInSeconds
116+
optional: true
117+
- contains:
118+
path: spec.template.spec.containers[0].env
119+
content:
120+
name: IRW_SERVICE_ACCOUNT
121+
valueFrom:
122+
configMapKeyRef:
123+
name: cap-app-proxy-cm
124+
key: enrichmentServiceAccountName
125+
optional: true
126+
127+
- it: Verify correct name of serviceAccount
128+
template: 'app-proxy/enrichment/sa.yaml'
129+
values:
130+
- ./values/mandatory-values.yaml
131+
set:
132+
app-proxy.image-enrichment.serviceAccount.name: test
133+
asserts:
134+
- equal:
135+
path: metadata.name
136+
value: test
137+
138+
- it: Correct serviceaccount is set in role binding
139+
template: 'app-proxy/enrichment/rbac.yaml'
140+
documentIndex: 1
141+
values:
142+
- ./values/mandatory-values.yaml
143+
set:
144+
app-proxy.image-enrichment.serviceAccount.name: test
145+
asserts:
146+
- contains:
147+
path: subjects
148+
content:
149+
kind: ServiceAccount
150+
name: test
151+
- equal:
152+
path: roleRef.name
153+
value: cap-app-proxy-enrichment
154+
155+
156+
157+
158+

0 commit comments

Comments
 (0)