Skip to content

Commit 8667259

Browse files
authored
CR-18557 - move createRuntime to main container (#43)
* moved all env vars from initContainer to main * inject platform cert to uninstall hook * bumped app-proxy to `1.2255.0` * updated version to `0.2.4-alpha`
1 parent a6abece commit 8667259

File tree

11 files changed

+64
-109
lines changed

11 files changed

+64
-109
lines changed

charts/gitops-runtime/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
appVersion: 0.1.29
33
description: A Helm chart for Codefresh gitops runtime
44
name: gitops-runtime
5-
version: 0.2.3-alpha
5+
version: 0.2.4-alpha
66
home: https://github.com/codefresh-io/gitops-runtime-helm
77
icon: https://codefresh.io/docs/assets/brand/codefresh_purple_dark_logo.png
88
keywords:
@@ -16,7 +16,7 @@ annotations:
1616
artifacthub.io/prerelease: "true"
1717
artifacthub.io/changes: |
1818
- kind: fixed
19-
description: Remove duplicate labels from app-proxy service and serviceaccount
19+
description: Moved runtime creation from `cap-app-proxy` initContainer into main container
2020
dependencies:
2121
- name: argo-cd
2222
repository: https://codefresh-io.github.io/argo-helm

charts/gitops-runtime/README.md

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

3-
![Version: 0.2.3-alpha](https://img.shields.io/badge/Version-0.2.3--alpha-informational?style=flat-square) ![AppVersion: 0.1.29](https://img.shields.io/badge/AppVersion-0.1.29-informational?style=flat-square)
3+
![Version: 0.2.4-alpha](https://img.shields.io/badge/Version-0.2.4--alpha-informational?style=flat-square) ![AppVersion: 0.1.29](https://img.shields.io/badge/AppVersion-0.1.29-informational?style=flat-square)
44

55
A Helm chart for Codefresh gitops runtime
66

@@ -54,14 +54,14 @@ A Helm chart for Codefresh gitops runtime
5454
| 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 |
5555
| app-proxy.image.pullPolicy | string | `"IfNotPresent"` | |
5656
| app-proxy.image.repository | string | `"quay.io/codefresh/cap-app-proxy"` | |
57-
| app-proxy.image.tag | string | `"1.2245.0"` | |
57+
| app-proxy.image.tag | string | `"1.2255.0"` | |
5858
| app-proxy.imagePullSecrets | list | `[]` | |
5959
| app-proxy.initContainer.command[0] | string | `"./init.sh"` | |
6060
| app-proxy.initContainer.env | object | `{}` | |
6161
| app-proxy.initContainer.extraVolumeMounts | list | `[]` | Extra volume mounts for init container |
6262
| app-proxy.initContainer.image.pullPolicy | string | `"IfNotPresent"` | |
6363
| app-proxy.initContainer.image.repository | string | `"quay.io/codefresh/cap-app-proxy-init"` | |
64-
| app-proxy.initContainer.image.tag | string | `"1.2245.0"` | |
64+
| app-proxy.initContainer.image.tag | string | `"1.2255.0"` | |
6565
| app-proxy.initContainer.resources.limits.cpu | string | `"1"` | |
6666
| app-proxy.initContainer.resources.limits.memory | string | `"512Mi"` | |
6767
| app-proxy.initContainer.resources.requests.cpu | string | `"0.2"` | |
@@ -153,7 +153,7 @@ A Helm chart for Codefresh gitops runtime
153153
| global.runtime.ingress.hosts | list | `[]` | Hosts for runtime ingress. Note that Codefresh platform will always use the first host in the list to access the runtime. |
154154
| global.runtime.ingress.protocol | string | `"https"` | The protocol that Codefresh platform will use to access the runtime ingress. Can be http or https. |
155155
| global.runtime.ingressUrl | string | `""` | Explicit url for runtime ingress. Provide this value only if you don't want the chart to create and ingress (global.runtime.ingress.enabled=false) and tunnel-client is not used (tunnel-client.enabled=false) |
156-
| global.runtime.name | string | `nil` | Runtime name. Must be identical to the namepsace in which it is intalled and must be unique per platform account. |
156+
| global.runtime.name | string | `nil` | Runtime name. Must be unique per platform account. |
157157
| installer | object | `{"image":{"pullPolicy":"IfNotPresent","repository":"quay.io/codefresh/gitops-runtime-installer","tag":""}}` | Runtime installer used for running hooks and checks on the release |
158158
| internal-router.affinity | object | `{}` | |
159159
| internal-router.env | object | `{}` | Environment variables - see values.yaml inside the chart for usage |

charts/gitops-runtime/templates/_components/_common_helpers.yaml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,28 @@
44
{{ fail "ERROR: env block must be a map"}}
55
{{- end -}}
66
{{- end -}}
7+
{{- if empty . -}}
8+
env: []
9+
{{- else -}}
710
env:
8-
{{- range $name, $val := . }}
9-
{{- if kindIs "string" $val}}
11+
{{- range $name, $val := . }}
12+
{{- if kindIs "string" $val}}
1013
- name: {{ $name }}
1114
value: {{ $val }}
12-
{{- else if kindIs "map" $val}}
13-
{{- if hasKey $val "valueFrom" }}
14-
{{- if or (hasKey $val.valueFrom "secretKeyRef") (hasKey $val.valueFrom "configMapKeyRef") (hasKey $val.valueFrom "fieldRef") }}
15+
{{- else if kindIs "map" $val}}
16+
{{- if hasKey $val "valueFrom" }}
17+
{{- if or (hasKey $val.valueFrom "secretKeyRef") (hasKey $val.valueFrom "configMapKeyRef") (hasKey $val.valueFrom "fieldRef") }}
1518
- name: {{ $name }}
1619
{{- $val | toYaml | nindent 2}}
17-
{{- else}}
18-
{{ fail "ERROR: Only secretKeyRef/configMapKeyRef/fieldRef are supported for valueFrom block for environment variables" }}
19-
{{- end}}
20+
{{- else}}
21+
{{ fail "ERROR: Only secretKeyRef/configMapKeyRef/fieldRef are supported for valueFrom block for environment variables" }}
22+
{{- end}}
23+
{{- else }}
24+
{{ fail "ERROR: Cannot generate environment variables only strings and valueFrom are supported"}}
25+
{{- end }}
2026
{{- else }}
21-
{{ fail "ERROR: Cannot generate environment variables only strings and valueFrom are supported"}}
27+
{{ fail "ERROR: Only maps and string are supported for environment variables"}}
2228
{{- end }}
23-
{{- else }}
24-
{{ fail "ERROR: Only maps and string are supported for environment variables"}}
2529
{{- end }}
2630
{{- end }}
2731
{{- end -}}
Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,6 @@
1-
{{- define "cap-app-proxy.environment-variables.init-container-defaults" -}}
2-
CHART_VERSION: {{ .Chart.Version }}
3-
CF_HOST:
4-
valueFrom:
5-
configMapKeyRef:
6-
name: codefresh-cm
7-
key: base-url
8-
CLUSTER: https://kubernetes.default.svc
9-
INGRESS_CLASS_NAME:
10-
valueFrom:
11-
configMapKeyRef:
12-
name: codefresh-cm
13-
key: ingressClassName
14-
INGRESS_CONTROLLER:
15-
valueFrom:
16-
configMapKeyRef:
17-
name: codefresh-cm
18-
key: ingressController
19-
INGRESS_HOST:
20-
valueFrom:
21-
configMapKeyRef:
22-
name: codefresh-cm
23-
key: ingressHost
24-
INSTALLATION_TYPE: HELM
25-
NAMESPACE:
26-
valueFrom:
27-
fieldRef:
28-
fieldPath: metadata.namespace
29-
RUNTIME_NAME:
30-
valueFrom:
31-
configMapKeyRef:
32-
name: cap-app-proxy-cm
33-
key: runtimeName
34-
RUNTIME_TOKEN:
35-
valueFrom:
36-
secretKeyRef:
37-
name: codefresh-token
38-
key: token
39-
optional: true
40-
RUNTIME_VERSION:
41-
valueFrom:
42-
configMapKeyRef:
43-
name: codefresh-cm
44-
key: version
45-
{{- end -}}
46-
471
{{/*
482
Read defaults from the template above and merge with the values provided in values file
493
*/}}
504
{{- define "cap-app-proxy.environment-variables.init-container" -}}
51-
{{- $defaults := (include "cap-app-proxy.environment-variables.init-container-defaults" . | fromYaml ) -}}
52-
{{- $overrides := .Values.initContainer.env -}}
53-
{{- $mergedValues := mergeOverwrite $defaults $overrides -}}
54-
{{- include "codefresh-gitops-runtime.components.common_helpers.container-templates.env-vars" $mergedValues -}}
5+
{{- include "codefresh-gitops-runtime.components.common_helpers.container-templates.env-vars" .Values.initContainer.env -}}
556
{{- end -}}

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ ARGO_WORKFLOWS_URL:
2828
name: cap-app-proxy-cm
2929
key: argoWorkflowsUrl
3030
optional: true
31+
CHART_VERSION: {{ .Chart.Version }}
3132
CF_HOST:
3233
valueFrom:
3334
configMapKeyRef:
3435
name: codefresh-cm
3536
key: base-url
3637
optional: true
38+
CLUSTER: https://kubernetes.default.svc
3739
CORS:
3840
valueFrom:
3941
configMapKeyRef:
@@ -59,6 +61,23 @@ GRAPHQL_PLAYGROUND:
5961
name: cap-app-proxy-cm
6062
key: graphqlPlayground
6163
optional: true
64+
INGRESS_CLASS_NAME:
65+
valueFrom:
66+
configMapKeyRef:
67+
name: codefresh-cm
68+
key: ingressClassName
69+
INGRESS_CONTROLLER:
70+
valueFrom:
71+
configMapKeyRef:
72+
name: codefresh-cm
73+
key: ingressController
74+
INGRESS_HOST:
75+
valueFrom:
76+
configMapKeyRef:
77+
name: codefresh-cm
78+
key: ingressHost
79+
INSTALLATION_TYPE: HELM
80+
MANAGED: '"false"'
6281
NAMESPACE:
6382
valueFrom:
6483
fieldRef:
@@ -93,6 +112,11 @@ RUNTIME_STORE_IV:
93112
name: codefresh-token
94113
key: encryptionIV
95114
optional: true
115+
RUNTIME_VERSION:
116+
valueFrom:
117+
configMapKeyRef:
118+
name: codefresh-cm
119+
key: version
96120
STORE_BACKEND:
97121
valueFrom:
98122
configMapKeyRef:

charts/gitops-runtime/templates/app-proxy/_app-proxy-env.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,3 @@ GIT_PASSWORD:
1414
{{- end }}
1515
WORKFLOW_PIPELINES_WEBHOOKS_TLS_SECRET: codefresh-workflow-pipelines-tls
1616
{{- end }}
17-
18-
{{- define "codefresh-gitops-runtime.app-proxy.init-container.calculated-env-vars"}}
19-
{{- if or .Values.global.codefresh.tls.caCerts.secret.create .Values.global.codefresh.tls.caCerts.secretKeyRef }}
20-
{{- $name := .Values.global.codefresh.tls.caCerts.secret.create | ternary "codefresh-tls-certs" .Values.global.codefresh.tls.caCerts.secretKeyRef.name }}
21-
{{- $key := .Values.global.codefresh.tls.caCerts.secret.create | ternary (default "ca-bundle.crt" .Values.global.codefresh.tls.caCerts.secret.key) .Values.global.codefresh.tls.caCerts.secretKeyRef.key }}
22-
SSL_CERT_FILE: /app/config/{{ $name }}/{{ $key }}
23-
{{- end }}
24-
USER_TOKEN:
25-
{{- include "codefresh-gitops-runtime.installation-token-env-var-value" . | nindent 2 }}
26-
{{- end }}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
{{- $_ := set $appProxyContext.Values "global" (get .Values "global") }}
44

55
{{/* Merge environment variables with the ones in _app-proxy-env.yaml */}}
6-
{{- $initContainerMergedValues := mergeOverwrite $appProxyContext.Values.initContainer.env (include "codefresh-gitops-runtime.app-proxy.init-container.calculated-env-vars" . | fromYaml) }}
76
{{- $mainContainerMergedValues := mergeOverwrite $appProxyContext.Values.env (include "codefresh-gitops-runtime.app-proxy.calculated-env-vars" . | fromYaml) }}
8-
{{- $_ := set $appProxyContext.Values.initContainer "env" $initContainerMergedValues }}
97
{{- $_ := set $appProxyContext.Values "env" $mainContainerMergedValues }}
108

119
{{/* Add extra volumes (used for cutom tls) */}}

charts/gitops-runtime/templates/hooks/pre-uninstall/delete-runtime-from-platform.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ spec:
1919
- name: PLATFORM_URL
2020
value: {{ .Values.global.codefresh.url }}
2121
- name: USER_TOKEN
22-
{{ include "codefresh-gitops-runtime.installation-token-env-var-value" . | nindent 10 }}
22+
{{- include "codefresh-gitops-runtime.installation-token-env-var-value" . | nindent 10 }}
23+
{{- if or .Values.global.codefresh.tls.caCerts.secret.create .Values.global.codefresh.tls.caCerts.secretKeyRef }}
24+
{{- $name := .Values.global.codefresh.tls.caCerts.secret.create | ternary "codefresh-tls-certs" .Values.global.codefresh.tls.caCerts.secretKeyRef.name }}
25+
{{- $key := .Values.global.codefresh.tls.caCerts.secret.create | ternary (default "ca-bundle.crt" .Values.global.codefresh.tls.caCerts.secret.key) .Values.global.codefresh.tls.caCerts.secretKeyRef.key }}
26+
- name: SSL_CERT_FILE
27+
value: /app/config/{{ $name }}/{{ $key }}
28+
{{- end }}
2329
imagePullPolicy: {{ .Values.installer.image.pullPolicy }}
2430
command: ["sh", "-c"]
2531
args:

charts/gitops-runtime/tests/custom-ca_test.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Test custom CA - affects app-proxy and event reporters
2-
suite: Tes custom CA
2+
suite: Test custom CA
33
templates:
44
- tls-custom-ca/codefresh-tls-certs.yaml
55
- tls-custom-ca/workflow-pipelines-git-webhooks.yaml
66
- app-proxy/deployment.yaml
77
- event-reporters/workflow-reporter/sensor.yaml
88
- event-reporters/events-reporter/sensor.yaml
99
- event-reporters/rollout-reporter/sensor.yaml
10+
- hooks/pre-uninstall/delete-runtime-from-platform.yaml
1011
tests:
1112

1213
- it: test chart created secret contents - default secret key
@@ -121,22 +122,22 @@ tests:
121122
name: codefresh-tls-certs
122123
readOnly: true
123124

124-
- it: environment variable in app-proxy init container - secret ref
125-
template: 'app-proxy/deployment.yaml'
125+
- it: environment variable in pre-delete hook - secret ref
126+
template: 'hooks/pre-uninstall/delete-runtime-from-platform.yaml'
126127
values:
127128
- ./values/mandatory-values.yaml
128129
set:
129130
global.codefresh.tls.caCerts.secretKeyRef.name: my-secret
130131
global.codefresh.tls.caCerts.secretKeyRef.key: my-key
131132
asserts:
132133
- contains:
133-
path: spec.template.spec.initContainers[0].env
134+
path: spec.template.spec.containers[0].env
134135
content:
135136
name: SSL_CERT_FILE
136137
value: /app/config/my-secret/my-key
137138

138-
- it: environment variable in app-proxy init container - chart created secret
139-
template: 'app-proxy/deployment.yaml'
139+
- it: environment variable in pre-delete hook - chart created secret
140+
template: 'hooks/pre-uninstall/delete-runtime-from-platform.yaml'
140141
values:
141142
- ./values/mandatory-values.yaml
142143
set:
@@ -147,12 +148,11 @@ tests:
147148
-----END CERTIFICATE-----
148149
asserts:
149150
- contains:
150-
path: spec.template.spec.initContainers[0].env
151+
path: spec.template.spec.containers[0].env
151152
content:
152153
name: SSL_CERT_FILE
153154
value: /app/config/codefresh-tls-certs/ca-bundle.crt
154155

155-
156156
- it: events reporter sensor - check chart created secret with default key
157157
template: event-reporters/events-reporter/sensor.yaml
158158
values:

charts/gitops-runtime/tests/installation-token_test.yaml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,6 @@ tests:
1111
set:
1212
global.codefresh.userToken.token: dummy
1313
asserts:
14-
- contains:
15-
path: spec.template.spec.initContainers[0].env
16-
content:
17-
name: USER_TOKEN
18-
valueFrom:
19-
secretKeyRef:
20-
name: codefresh-user-token
21-
key: token
22-
optional: true
2314
- contains:
2415
path: spec.template.spec.containers[0].env
2516
content:
@@ -46,11 +37,3 @@ tests:
4637
secretKeyRef:
4738
name: mysecret
4839
key: mykey
49-
- contains:
50-
path: spec.template.spec.initContainers[0].env
51-
content:
52-
name: USER_TOKEN
53-
valueFrom:
54-
secretKeyRef:
55-
name: mysecret
56-
key: mykey

charts/gitops-runtime/values.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ global:
4646

4747
# -- Runtime level settings
4848
runtime:
49-
# -- Runtime name. Must be identical to the namepsace in which it is intalled and must be unique per platform account.
49+
# -- Runtime name. Must be unique per platform account.
5050
name:
5151
# -- Runtime cluster. Should not be changed.
5252
cluster: https://kubernetes.default.svc
@@ -305,16 +305,15 @@ app-proxy:
305305

306306
image:
307307
repository: quay.io/codefresh/cap-app-proxy
308-
tag: 1.2245.0
308+
tag: 1.2255.0
309309
pullPolicy: IfNotPresent
310310
# -- Extra volume mounts for main container
311311
extraVolumeMounts: []
312312

313313
initContainer:
314314
image:
315315
repository: quay.io/codefresh/cap-app-proxy-init
316-
# Overrides the image tag whose default is the chart appVersion.
317-
tag: 1.2245.0
316+
tag: 1.2255.0
318317
pullPolicy: IfNotPresent
319318
command:
320319
- ./init.sh

0 commit comments

Comments
 (0)