File tree Expand file tree Collapse file tree 9 files changed +115
-15
lines changed Expand file tree Collapse file tree 9 files changed +115
-15
lines changed Original file line number Diff line number Diff line change @@ -127,3 +127,45 @@ Ingress url for tunnels
127
127
{ {- end -} }
128
128
{ {- end -} }
129
129
130
+
131
+ { {/*
132
+ Return true if a TLS secret object should be created for tunnels ingress
133
+ */} }
134
+ { {- define " codefresh-tunnel-server.tunnels.createTlsSecret" -} }
135
+ { {- if and .Values.tunnels.ingress.tls.enabled (not .Values.tunnels.ingress.tls.existingSecret) } }
136
+ { {- true -} }
137
+ { {- end -} }
138
+ { {- end -} }
139
+
140
+ { {/*
141
+ Return true if a TLS secret object should be created for tunnel server
142
+ */} }
143
+ { {- define " codefresh-tunnel-server.createTlsSecret" -} }
144
+ { {- if and .Values.ingress.tls.enabled (not .Values.ingress.tls.existingSecret) } }
145
+ { {- true -} }
146
+ { {- end -} }
147
+ { {- end -} }
148
+
149
+ { {/*
150
+ Return the secret containing TLS certificates for tunnels ingress
151
+ */} }
152
+ { {- define " codefresh-tunnel-server.tunnels.tlsSecretName" -} }
153
+ { {- $secretName := .Values.tunnels.ingress.tls.existingSecret -} }
154
+ { {- if $secretName -} }
155
+ { {- printf " %s" (tpl $secretName $) -} }
156
+ { {- else -} }
157
+ { {- printf " %s-tunnels-cert" (include " codefresh-tunnel-server.name" .) -} }
158
+ { {- end -} }
159
+ { {- end -} }
160
+
161
+ { {/*
162
+ Return the secret containing TLS certificates for tunnel server
163
+ */} }
164
+ { {- define " codefresh-tunnel-server.tlsSecretName" -} }
165
+ { {- $secretName := .Values.ingress.tls.existingSecret -} }
166
+ { {- if $secretName -} }
167
+ { {- printf " %s" (tpl $secretName $) -} }
168
+ { {- else -} }
169
+ { {- printf " %s-cert" (include " codefresh-tunnel-server.name" .) -} }
170
+ { {- end -} }
171
+ { {- end -} }
Original file line number Diff line number Diff line change 20
20
tls :
21
21
- hosts :
22
22
- {{ .Values.ingress.host }}
23
- {{- if .Values.ingress.tls.secretName }}
24
- secretName : {{ .Values.ingress.tls.secretName }}
25
- {{- else }}
26
- {{ fail "TLS for ingress is enabled but no secretName provided"}}
27
- {{- end }}
23
+ secretName : {{ include "codefresh-tunnel-server.tlsSecretName" . }}
28
24
{{- end }}
29
25
{{- end }}
Original file line number Diff line number Diff line change
1
+ {{- if (include "codefresh-tunnel-server.createTlsSecret" .) }}
2
+ apiVersion : v1
3
+ kind : Secret
4
+ metadata :
5
+ name : {{ include "codefresh-tunnel-server.tlsSecretName" . }}
6
+ labels :
7
+ {{- include "codefresh-tunnel-server.labels" . | nindent 4 }}
8
+ type : kubernetes.io/tls
9
+ data :
10
+ {{- $tls := buildCustomCert (required "A valid .Values.ingress.tls.cert is required!" .Values.ingress.tls.cert) (required "A valid .Values.ingress.tls.key is required!" .Values.ingress.tls.key) }}
11
+ tls.crt : {{ b64enc $tls.Cert }}
12
+ tls.key : {{ b64enc $tls.Key }}
13
+ {{- end }}
Original file line number Diff line number Diff line change 19
19
{{- if .Values.tunnels.ingress.tls.enabled }}
20
20
tls :
21
21
- hosts :
22
- - {{ .Values.tunnels.ingress.host }}
23
- {{- if .Values.tunnels.ingress.tls.secretName }}
24
- secretName : {{ .Values.tunnels.ingress.tls.secretName }}
25
- {{- else }}
26
- {{ fail "TLS for ingress is enabled but no secretName provided"}}
27
- {{- end }}
22
+ - {{ include "codefresh-tunnel-server.tunnels-ingress-host" . }}
23
+ secretName : {{ include "codefresh-tunnel-server.tunnels.tlsSecretName" . }}
28
24
{{- end }}
29
25
{{- end }}
Original file line number Diff line number Diff line change
1
+ {{- if (include "codefresh-tunnel-server.tunnels.createTlsSecret" .) }}
2
+ apiVersion : v1
3
+ kind : Secret
4
+ metadata :
5
+ name : {{ include "codefresh-tunnel-server.tunnels.tlsSecretName" . }}
6
+ labels :
7
+ {{- include "codefresh-tunnel-server.labels" . | nindent 4 }}
8
+ type : kubernetes.io/tls
9
+ data :
10
+ {{- $tls := buildCustomCert (required "A valid .Values.tunnels.ingress.tls.cert is required!" .Values.tunnels.ingress.tls.cert) (required "A valid .Values.tunnels.ingress.tls.key is required!" .Values.tunnels.ingress.tls.key) }}
11
+ tls.crt : {{ b64enc $tls.Cert }}
12
+ tls.key : {{ b64enc $tls.Key }}
13
+ {{- end }}
Original file line number Diff line number Diff line change
1
+ suite : Test tunnels ingress tls secret
2
+ templates :
3
+ - tunnel-server-ingress.yaml
4
+ - tunnel-server-tls-secret.yaml
5
+ tests :
6
+ - it : Should equal to existingSecret when existingSecret is set
7
+ template : tunnel-server-ingress.yaml
8
+ set :
9
+ ingress.enabled : true
10
+ host : register-tunnels.example.com
11
+ ingress.tls.enabled : true
12
+ ingress.tls.existingSecret : my-existing-secret
13
+ asserts :
14
+ - equal :
15
+ path : spec.tls[0].secretName
16
+ value : " my-existing-secret"
Original file line number Diff line number Diff line change 45
45
asserts :
46
46
- failedTemplate :
47
47
errorMessage : " subdomainHost or host must be provided for tunnels ingress"
48
-
49
-
Original file line number Diff line number Diff line change
1
+ suite : Test tunnels ingress tls secret
2
+ templates :
3
+ - tunnels-ingress.yaml
4
+ - tunnels-tls-secret.yaml
5
+ tests :
6
+ - it : Should equal to existingSecret when existingSecret is set
7
+ template : tunnels-ingress.yaml
8
+ set :
9
+ tunnels.ingress.enabled : true
10
+ tunnels.subdomainHost : tunnels.example.com
11
+ tunnels.ingress.tls.enabled : true
12
+ tunnels.ingress.tls.existingSecret : my-existing-secret
13
+ asserts :
14
+ - equal :
15
+ path : spec.tls[0].secretName
16
+ value : " my-existing-secret"
Original file line number Diff line number Diff line change @@ -30,7 +30,12 @@ tunnels:
30
30
# kubernetes.io/tls-acme: "true"
31
31
tls :
32
32
enabled : false
33
- secretName :
33
+ # Existing secret with TLS certificate
34
+ existingSecret :
35
+ # Custom certificate (base64 encoded)
36
+ cert : " "
37
+ # Custom private key (base64 encoded)
38
+ key : " "
34
39
35
40
# The serive of the tunnel server
36
41
service :
@@ -46,7 +51,12 @@ ingress:
46
51
# kubernetes.io/tls-acme: "true"
47
52
tls :
48
53
enabled : false
49
- secretName :
54
+ # Existing secret with TLS certificate
55
+ existingSecret :
56
+ # Custom certificate (base64 encoded)
57
+ cert : " "
58
+ # Custom private key (base64 encoded)
59
+ key : " "
50
60
51
61
serviceAccount :
52
62
create : true
You can’t perform that action at this time.
0 commit comments