Skip to content

Commit 1fd0dd2

Browse files
Add possibility to deploy the runtime with ingress disabled without deploying tunnel client (#41)
1 parent 599d942 commit 1fd0dd2

File tree

7 files changed

+165
-18
lines changed

7 files changed

+165
-18
lines changed

charts/gitops-runtime/Chart.yaml

Lines changed: 3 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.1-alpha.14
5+
version: 0.2.2-alpha.1
66
home: https://github.com/codefresh-io/gitops-runtime-helm
77
icon: https://codefresh.io/wp-content/uploads/2022/02/Codefresh_Logo_Vertical_LightBkgd.png
88
keywords:
@@ -14,7 +14,7 @@ maintainers:
1414
annotations:
1515
artifacthub.io/changes: |
1616
- kind: added
17-
description: Added support for custom CA
17+
description: Allow disabling ingress without deploying tunnel-client.
1818
dependencies:
1919
- name: argo-cd
2020
repository: https://codefresh-io.github.io/argo-helm
@@ -37,3 +37,4 @@ dependencies:
3737
repository: https://chartmuseum.codefresh.io/codefresh-tunnel-client
3838
version: "0.1.12"
3939
alias: tunnel-client
40+
condition: tunnel-client.enabled

charts/gitops-runtime/README.md

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

3-
![Version: 0.2.1-alpha.14](https://img.shields.io/badge/Version-0.2.1--alpha.14-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.2-alpha.1](https://img.shields.io/badge/Version-0.2.2--alpha.1-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

@@ -139,7 +139,7 @@ A Helm chart for Codefresh gitops runtime
139139
| global.codefresh.userToken | object | `{"secretKeyRef":{},"token":""}` | User token. Used for runtime registration against the patform. One of token (for plain text value) or secretKeyRef must be provided. |
140140
| global.codefresh.userToken.secretKeyRef | object | `{}` | User token that references an existing secret containing the token. |
141141
| global.codefresh.userToken.token | string | `""` | User token in plain text. The chart creates and manages the secret for this token. |
142-
| global.runtime | object | `{"cluster":"https://kubernetes.default.svc","eventBus":{"nats":{"native":{"auth":"token","containerTemplate":{"resources":{"limits":{"cpu":"500m","ephemeral-storage":"2Gi","memory":"4Gi"},"requests":{"cpu":"200m","ephemeral-storage":"2Gi","memory":"1Gi"}}},"maxPayload":"4MB","replicas":3}}},"eventBusName":"codefresh-eventbus","gitCredentials":{"password":{"secretKeyRef":{},"value":null},"username":"username"},"ingress":{"annotations":{},"className":"nginx","enabled":false,"hosts":[],"protocol":"https","tls":[]},"name":null}` | Runtime level settings |
142+
| global.runtime | object | `{"cluster":"https://kubernetes.default.svc","eventBus":{"nats":{"native":{"auth":"token","containerTemplate":{"resources":{"limits":{"cpu":"500m","ephemeral-storage":"2Gi","memory":"4Gi"},"requests":{"cpu":"200m","ephemeral-storage":"2Gi","memory":"1Gi"}}},"maxPayload":"4MB","replicas":3}}},"eventBusName":"codefresh-eventbus","gitCredentials":{"password":{"secretKeyRef":{},"value":null},"username":"username"},"ingress":{"annotations":{},"className":"nginx","enabled":false,"hosts":[],"protocol":"https","tls":[]},"ingressUrl":"","name":null}` | Runtime level settings |
143143
| global.runtime.cluster | string | `"https://kubernetes.default.svc"` | Runtime cluster. Should not be changed. |
144144
| global.runtime.eventBus | object | `{"nats":{"native":{"auth":"token","containerTemplate":{"resources":{"limits":{"cpu":"500m","ephemeral-storage":"2Gi","memory":"4Gi"},"requests":{"cpu":"200m","ephemeral-storage":"2Gi","memory":"1Gi"}}},"maxPayload":"4MB","replicas":3}}}` | EventBus spec |
145145
| global.runtime.eventBusName | string | `"codefresh-eventbus"` | Eventbus name |
@@ -152,6 +152,7 @@ A Helm chart for Codefresh gitops runtime
152152
| global.runtime.ingress.enabled | bool | `false` | Defines if ingress-based access mode is enabled for runtime. To use tunnel-based (ingressless) access mode, set to false. |
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. |
155+
| 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) |
155156
| 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. |
156157
| installer | object | `{"image":{"pullPolicy":"IfNotPresent","repository":"quay.io/codefresh/gitops-runtime-installer","tag":""}}` | Runtime installer used for running hooks and checks on the release |
157158
| internal-router.affinity | object | `{}` | |
@@ -180,7 +181,8 @@ A Helm chart for Codefresh gitops runtime
180181
| internal-router.serviceAccount.name | string | `""` | |
181182
| internal-router.tolerations | list | `[]` | |
182183
| sealed-secrets | object | `{"fullnameOverride":"sealed-secrets-controller","image":{"registry":"quay.io","repository":"codefresh/sealed-secrets-controller","tag":"v0.19.4"},"keyrenewperiod":"720h","resources":{"limits":{"cpu":"500m","memory":"1Gi"},"requests":{"cpu":"200m","memory":"512Mi"}}}` | --------------------------------------------------------------------------------------------------------------------- |
183-
| tunnel-client | object | `{"libraryMode":true,"tunnelServer":{"host":"register-tunnels.cf-cd.com","subdomainHost":"tunnels.cf-cd.com"}}` | Tunnel based runtime. Only relevant when runtime.ingress.enabled = false |
184+
| tunnel-client | object | `{"enabled":true,"libraryMode":true,"tunnelServer":{"host":"register-tunnels.cf-cd.com","subdomainHost":"tunnels.cf-cd.com"}}` | Tunnel based runtime. Not supported for on-prem platform. In on-prem use ingress based runtimes. |
185+
| tunnel-client.enabled | bool | `true` | Will only be used if global.runtime.ingress.enabled = false |
184186
| tunnel-client.libraryMode | bool | `true` | Do not change this value! Breaks chart logic |
185187

186188
----------------------------------------------

charts/gitops-runtime/templates/_helpers.tpl

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,19 +174,31 @@ valueFrom:
174174
Get ingress url for both tunnel based and ingress based runtimes
175175
*/}}
176176
{{- define "codefresh-gitops-runtime.ingress-url"}}
177+
{{- $supportedProtocols := list "http" "https" }}
177178
{{- if .Values.global.runtime.ingress.enabled }}
178-
{{- $supportedProtocols := list "http" "https" }}
179179
{{- if has .Values.global.runtime.ingress.protocol $supportedProtocols }}
180180
{{- printf "%s://%s" .Values.global.runtime.ingress.protocol (index .Values.global.runtime.ingress.hosts 0)}}
181181
{{- else }}
182182
{{ fail (printf "ERROR: Unsupported protocol %s for ingress. Only http and https supported" .Values.global.runtime.ingress.protocol)}}
183183
{{- end }}
184-
{{- else }}
185-
{{- $accoundId := required "codefresh.accountId is required" .Values.global.codefresh.accountId }}
186-
{{- $runtimeName := required "runtime.name is required" .Values.global.runtime.name }}
184+
{{/* If tunnel client is enabled - ingress url is <accoundId>-<runtimename>.<tunnel-subdomain> */}}
185+
{{- else if index .Values "tunnel-client" "enabled" }}
186+
{{- $accoundId := required "global.codefresh.accountId is required for tunnel based runtime" .Values.global.codefresh.accountId }}
187+
{{- $runtimeName := required "global.runtime.name is required for tunnel based runtime" .Values.global.runtime.name }}
187188
{{- $tunnelPrefix := printf "%s-%s" .Values.global.codefresh.accountId .Values.global.runtime.name }}
188189
{{- $tunnelHost := index (get .Values "tunnel-client") "tunnelServer" "subdomainHost"}}
189190
{{- printf "https://%s.%s" $tunnelPrefix $tunnelHost }}
191+
{{- else }}
192+
{{/* If ingress is disabled and tunnel-client is disabled, the ingressHost must be explicitly defined in the values*/}}
193+
{{- if .Values.global.runtime.ingressUrl }}
194+
{{- if or (hasPrefix "http" .Values.global.runtime.ingressUrl) (hasPrefix "https" .Values.global.runtime.ingressUrl)}}
195+
{{- print .Values.global.runtime.ingressUrl }}
196+
{{- else }}
197+
{{- fail "ERROR: Only http and https are supported for global.runtime.ingressUrl"}}
198+
{{- end }}
199+
{{- else }}
200+
{{- fail "ERROR: When global.runtime.ingress.enabled is false and tunnel-client.enabled is false - global.runtime.ingressUrl must be provided" }}
201+
{{- end }}
190202
{{- end }}
191203
{{- end }}
192204

@@ -213,7 +225,7 @@ Output comma separated list of installed runtime components
213225
{{- $comptList = append $comptList $workflowReporter}}
214226
{{- $comptList = append $comptList $argoWorkflows }}
215227
{{- end }}
216-
{{- if not .Values.global.runtime.ingress.enabled }}
228+
{{- if and ( not .Values.global.runtime.ingress.enabled) (index .Values "tunnel-client" "enabled") }}
217229
{{- $tunnelClient := dict "name" "codefresh-tunnel-client" "version" (get .Subcharts "tunnel-client").Chart.AppVersion }}
218230
{{- $comptList = append $comptList $tunnelClient }}
219231
{{- end }}

charts/gitops-runtime/templates/tunnel-client.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ to intruduce the subdomainPrefix to the tunnel.
44
Since the prefix is comprised of <accoundId>-<runtime name>, we can tempalate it and thus
55
reduce complexity of installation and number or mandatory values to provide for the installation to work.
66
*/}}
7-
{{- if not .Values.global.runtime.ingress.enabled}}
7+
{{- if and ( not .Values.global.runtime.ingress.enabled) (index .Values "tunnel-client" "enabled") }}
88
{{ $tunnelClientContext := (index .Subcharts "tunnel-client")}}
99
{{ $accoundId := required "codefresh.accountId is required" .Values.global.codefresh.accountId }}
1010
{{ $runtimeName := required "runtime.name is required" .Values.global.runtime.name }}
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
suite: misc tests on app-proxy templates generation
2+
templates:
3+
- templates/ingress.yaml
4+
- templates/tunnel-client.yaml
5+
- templates/codefresh-cm.yaml
6+
tests:
7+
- it: no ingress when tunnel runtime is configured
8+
template: templates/ingress.yaml
9+
values:
10+
- ./values/mandatory-values.yaml
11+
asserts:
12+
- hasDocuments:
13+
count: 0
14+
15+
- it: no tunnel when ingress is configured
16+
template: templates/tunnel-client.yaml
17+
values:
18+
- ./values/mandatory-values-ingress.yaml
19+
asserts:
20+
- hasDocuments:
21+
count: 0
22+
23+
- it: no tunnel when ingress and tunnel are disabled
24+
template: templates/tunnel-client.yaml
25+
values:
26+
- ./values/mandatory-values-ingress.yaml
27+
set:
28+
global.runtime.ingressUrl: https://test.test.test
29+
tunnel-client.enabled: false
30+
global.runtime.ingress.enabled: false
31+
asserts:
32+
- hasDocuments:
33+
count: 0
34+
35+
- it: tunnel client rendering fails when accountId not provided
36+
template: templates/tunnel-client.yaml
37+
values:
38+
- ./values/mandatory-values.yaml
39+
set:
40+
global.codefresh.accountId: ""
41+
asserts:
42+
- failedTemplate:
43+
errorMessage: codefresh.accountId is required
44+
45+
46+
47+
- it: when both tunnel-client and ingress are disabled fail rendering if ingressUrl is not provided
48+
template: templates/codefresh-cm.yaml
49+
values:
50+
- ./values/mandatory-values.yaml
51+
set:
52+
global.runtime.ingress.enabled: false
53+
tunnel-client.enabled: false
54+
asserts:
55+
- failedTemplate:
56+
errorMessage: When global.runtime.ingress.enabled is false and tunnel-client.enabled is false - global.runtime.ingressUrl must be provided
57+
58+
- it: fail on ingressUrl that is not http or https
59+
template: templates/codefresh-cm.yaml
60+
values:
61+
- ./values/mandatory-values.yaml
62+
set:
63+
global.runtime.ingress.enabled: false
64+
tunnel-client.enabled: false
65+
global.runtime.ingressUrl: test.test.fail
66+
asserts:
67+
- failedTemplate:
68+
errorMessage: Only http and https are supported for global.runtime.ingressUrl
69+
70+
- it: codefresh-cm ingressHost is set correctly when ingress enabled
71+
template: templates/codefresh-cm.yaml
72+
values:
73+
- ./values/mandatory-values-ingress.yaml
74+
set:
75+
global.runtime.ingress.enabled: true
76+
global.runtime.ingress.hosts: [test.example.com]
77+
global.runtime.ingress.protocol: https
78+
asserts:
79+
- equal:
80+
path: data.ingressHost
81+
value: https://test.example.com
82+
83+
- it: codefresh-cm ingressHost is set correctly when tunnel based
84+
template: templates/codefresh-cm.yaml
85+
values:
86+
- ./values/mandatory-values.yaml
87+
set:
88+
global.runtime.ingress.enabled: false
89+
global.codefresh.accountId: aabbccdd
90+
global.runtime.name: test
91+
tunnel-client.enabled: true
92+
tunnel-client.tunnelServer.subdomainHost: my-tunnels.com
93+
asserts:
94+
- equal:
95+
path: data.ingressHost
96+
value: https://aabbccdd-test.my-tunnels.com
97+
98+
- it: codefresh-cm ingressHost is set correctly when ingressUrl is used (ingress and tunnel both disabled)
99+
template: templates/codefresh-cm.yaml
100+
values:
101+
- ./values/mandatory-values.yaml
102+
set:
103+
global.runtime.ingress.enabled: false
104+
tunnel-client.enabled: false
105+
global.runtime.ingressUrl: https://test.test.test
106+
asserts:
107+
- equal:
108+
path: data.ingressHost
109+
value: https://test.test.test
110+
111+
- it: ingress correctly rendered
112+
template: templates/ingress.yaml
113+
set:
114+
global.runtime.ingress.enabled: true
115+
global.runtime.ingress.hosts: [test.example.com]
116+
global.runtime.ingress.protocol: https
117+
global.runtime.ingress.className: myclass
118+
global.runtime.ingress.tls: [{secretName: blah, hosts: [test.example.com]}]
119+
values:
120+
- ./values/mandatory-values-ingress.yaml
121+
asserts:
122+
- equal:
123+
path: spec.ingressClassName
124+
value: myclass
125+
- equal:
126+
path: spec.rules[0].host
127+
value: test.example.com
128+
- equal:
129+
path: spec.tls
130+
value:
131+
- hosts:
132+
- "test.example.com"
133+
secretName: blah

charts/gitops-runtime/tests/values/mandatory-values.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,5 @@ global:
66

77
runtime:
88
name: test-runtime1
9-
109
ingress:
11-
enabled: false
12-
13-
argo-rollouts:
14-
enabled: true
10+
enabled: false

charts/gitops-runtime/values.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ global:
6161
annotations: {}
6262
# -- Hosts for runtime ingress. Note that Codefresh platform will always use the first host in the list to access the runtime.
6363
hosts: []
64-
64+
# -- 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)
65+
ingressUrl: ""
6566
# -- Git credentials runtime. Runtime is not fully functional without those credentials.
6667
# If not provided through the installation, they must be provided through the Codefresh UI.
6768
gitCredentials:
@@ -260,8 +261,10 @@ internal-router:
260261
#-----------------------------------------------------------------------------------------------------------------------
261262
# tunnel client
262263
#-----------------------------------------------------------------------------------------------------------------------
263-
# -- Tunnel based runtime. Only relevant when runtime.ingress.enabled = false
264+
# -- Tunnel based runtime. Not supported for on-prem platform. In on-prem use ingress based runtimes.
264265
tunnel-client:
266+
# -- Will only be used if global.runtime.ingress.enabled = false
267+
enabled: true
265268
# -- Do not change this value! Breaks chart logic
266269
libraryMode: true
267270
tunnelServer:

0 commit comments

Comments
 (0)