Skip to content

Commit f1a4b39

Browse files
Add configurable secret names for wildcard instances (#73)
Previously, all instances - regardless of whether they contain wildcards or not - were using the same hard-coded `ws-cert-secret` TLS secret name. This results in the inability to use a preconfigured certificate only for the wildcard routes but keep the regular process for non-wildcard routes in place. This PR introduces an optional field `ingress.allWildcardSecretNames` that accepts a wildcardPattern->secretName mapping and configures the ingress to use the configured secret for the wildcard host. Making sure that no existing functionality is broken, the changes also make sure that: - ingress.allWildcardSecretNames does not introduce new routes. Only routes that were already configured via hosts.allWildcardInstances can be modified with a new secretName. - ingress.allWildcardSecretNames is optional and any wildcard-instance will use the `ws-cert-secret` by default. This also allows partial changes to some routes' certs. Co-authored-by: Lucas Koehler <[email protected]>
1 parent d0b180c commit f1a4b39

File tree

4 files changed

+39
-9
lines changed

4 files changed

+39
-9
lines changed

charts/theia-cloud/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ A Helm chart for Theia Cloud
3333
| imagePullPolicy | string | `"Always"` | The default imagePullPolicy for containers of theia cloud. Can be overridden for individual components by specifying the imagePullPolicy variable there. Possible values: - Always - IfNotPresent - Never |
3434
| ingress | object | (see details below) | Values to influence the ingresses |
3535
| ingress.addTLSSecretName | bool | `true` | whether the default Theia Cloud tls secret names should be used. If false no tls secret name will be set on the ingress only needed when ingress.tls == true |
36+
| ingress.allWildcardSecretNames | object | `{}` | All additional wildcard hostnames and the respective TLS secret names. Use this for wildcard hostnames that should use a TLS certificate with a `secretName` different from the default one. Only accepts wildcard hostnames that are configured in `hosts.allWildcardInstances`. |
3637
| ingress.certManagerAnnotations | bool | `true` | When set to true the cert-manager.io annotations will be set. Only used when ingress.addTLSSecretName === true When false certificate management is handled outside of Theia Cloud. |
3738
| ingress.clusterIssuer | string | `"letsencrypt-prod"` | The cluster issuer to use Only needed when ingress.certManagerAnnotations is true |
3839
| ingress.instanceName | string | `"theia-cloud-demo-ws-ingress"` | The name of the ingress which will be updated to publish new theia application. If this is not existing it will be created. You may chose to set the ingress up yourself and point Theia Cloud to the ingress via the name |

charts/theia-cloud/templates/instances-ingress-path-based.yaml

+15-4
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,30 @@ spec:
2828
tls:
2929
- hosts:
3030
- {{ tpl (.Values.hosts.configuration.baseHost | toString) . }}
31-
{{- range .Values.hosts.allWildcardInstances }}
32-
- {{ printf "'%s%s'" . $.Values.hosts.configuration.baseHost }}
33-
{{- end }}
3431
{{- if .Values.ingress.addTLSSecretName }}
32+
{{- range $wildcard := .Values.hosts.allWildcardInstances }}
33+
{{- if (not (hasKey $.Values.ingress.allWildcardSecretNames $wildcard)) }}
34+
- {{ printf "%s%s" (tpl . $) (tpl $.Values.hosts.configuration.baseHost $)| quote }}
35+
{{- end }}
36+
{{- end }}
3537
secretName: ws-cert-secret
3638
{{- end }}
3739
{{- end }}
40+
41+
{{- range $wildcard := .Values.hosts.allWildcardInstances }}
42+
{{- if hasKey $.Values.ingress.allWildcardSecretNames $wildcard }}
43+
{{- $secretName := get $.Values.ingress.allWildcardSecretNames $wildcard }}
44+
- hosts:
45+
- {{ printf "%s%s" (tpl $wildcard $) (tpl $.Values.hosts.configuration.baseHost $) | quote }}
46+
secretName: {{ tpl $secretName $ | quote }}
47+
{{- end }}
48+
{{- end }}
3849
{{- if not (lookup "networking.k8s.io/v1" "Ingress" .Release.Namespace (tpl (.Values.ingress.instanceName | toString) .) ) }}
3950
rules:
4051
- host: {{ tpl (.Values.hosts.configuration.baseHost | toString) . }}
4152
http:
4253
{{- range .Values.hosts.allWildcardInstances }}
43-
- host: {{ printf "'%s%s'" . $.Values.hosts.configuration.baseHost }}
54+
- host: {{ printf "'%s%s'" (tpl . $) (tpl $.Values.hosts.configuration.baseHost $) }}
4455
http:
4556
{{- end }}
4657
{{- else }}

charts/theia-cloud/templates/instances-ingress.yaml

+17-5
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,31 @@ spec:
2828
tls:
2929
- hosts:
3030
- {{ tpl (printf "%s.%s" .Values.hosts.configuration.instance .Values.hosts.configuration.baseHost | toString) . }}
31-
{{- range .Values.hosts.allWildcardInstances }}
32-
- {{ printf "'%s%s.%s'" . $.Values.hosts.configuration.instance $.Values.hosts.configuration.baseHost }}
33-
{{- end }}
3431
{{- if .Values.ingress.addTLSSecretName }}
32+
{{- range $wildcard := .Values.hosts.allWildcardInstances }}
33+
{{- if (not (hasKey $.Values.ingress.allWildcardSecretNames $wildcard)) }}
34+
- {{ printf "%s%s.%s" (tpl . $) (tpl $.Values.hosts.configuration.instance $) (tpl $.Values.hosts.configuration.baseHost $) | quote }}
35+
{{- end }}
36+
{{- end }}
3537
secretName: ws-cert-secret
3638
{{- end }}
3739
{{- end }}
40+
41+
{{- range $wildcard := .Values.hosts.allWildcardInstances }}
42+
{{- if hasKey $.Values.ingress.allWildcardSecretNames $wildcard }}
43+
{{- $secretName := get $.Values.ingress.allWildcardSecretNames $wildcard }}
44+
- hosts:
45+
- {{ printf "%s%s.%s" (tpl $wildcard $) (tpl $.Values.hosts.configuration.instance $) (tpl $.Values.hosts.configuration.baseHost $) | quote }}
46+
secretName: {{ tpl $secretName $ | quote }}
47+
{{- end }}
48+
{{- end }}
49+
3850
{{- if not (lookup "networking.k8s.io/v1" "Ingress" .Release.Namespace (tpl (.Values.ingress.instanceName | toString) .) ) }}
3951
rules:
40-
- host: {{ tpl (printf "%s.%s" .Values.hosts.configuration.instance .Values.hosts.configuration.baseHost | toString) . }}
52+
- host: {{ printf "%s.%s" (tpl .Values.hosts.configuration.instance .) (tpl .Values.hosts.configuration.baseHost .) }}
4153
http:
4254
{{- range .Values.hosts.allWildcardInstances }}
43-
- host: {{ printf "'%s%s.%s'" . $.Values.hosts.configuration.instance $.Values.hosts.configuration.baseHost }}
55+
- host: {{ printf "%s%s.%s" (tpl . $) (tpl $.Values.hosts.configuration.instance $) (tpl $.Values.hosts.configuration.baseHost $) | quote }}
4456
http:
4557
{{- end }}
4658
{{- else }}

charts/theia-cloud/values.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,12 @@ ingress:
326326
# only needed when ingress.tls == true
327327
addTLSSecretName: true
328328

329+
# -- All additional wildcard hostnames and the respective TLS secret names.
330+
# Use this for wildcard hostnames that should use a TLS certificate with a `secretName` different from the default one.
331+
# Only accepts wildcard hostnames that are configured in `hosts.allWildcardInstances`.
332+
allWildcardSecretNames: {}
333+
# "*.webview.": webview-ws-cert-secret
334+
329335
operatorrole:
330336
name: operator-api-access
331337

0 commit comments

Comments
 (0)