Skip to content

Commit 1b3f7aa

Browse files
Make ingress controller configurable in Helm charts (#101)
* theia-cloud-base: add `issuerprod.ingressClass` and use it in production ClusterIssuer * theia-cloud: introduce ingress helper templates and centralize annotations/ingressClassName handling * theia-cloud: add `ingress.controller`, optional `ingress.ingressClassName` and per-ingress `annotations` values Co-authored-by: Lucas Koehler <[email protected]>
1 parent 3cf379f commit 1b3f7aa

14 files changed

+194
-103
lines changed

charts/theia-cloud-base/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 1.2.0-next.0
18+
version: 1.2.0-next.1
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to

charts/theia-cloud-base/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# theia-cloud-base
22

3-
![Version: 1.2.0-next.0](https://img.shields.io/badge/Version-1.2.0--next.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.2.0-next](https://img.shields.io/badge/AppVersion-1.2.0--next-informational?style=flat-square)
3+
![Version: 1.2.0-next.1](https://img.shields.io/badge/Version-1.2.0--next.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.2.0-next](https://img.shields.io/badge/AppVersion-1.2.0--next-informational?style=flat-square)
44

55
Theia-cloud base chart
66

@@ -16,6 +16,7 @@ Theia-cloud base chart
1616
| issuerca.enable | bool | `true` | whether to install the CA certificate signer |
1717
| issuerca.name | string | `"theia-cloud-ca-certificate-signer"` | name for the issuer preparing a self signed CA certificate |
1818
| issuerprod.enable | bool | `true` | whether to install the let's encrypt production cluster issuer |
19+
| issuerprod.ingressClass | string | `"nginx"` | ingress class for the HTTP-01 ACME challenge solver |
1920
| issuerprod.name | string | `"letsencrypt-prod"` | name for the let's encrypt production cluster issuer |
2021
| issuerstaging.name | string | `"theia-cloud-selfsigned-issuer"` | name for the self signed cluster issuer |
2122
| operatorrole.name | string | `"operator-api-access"` | name for the operator's cluster role |

charts/theia-cloud-base/templates/clusterissuer-production.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ spec:
1212
solvers:
1313
- http01:
1414
ingress:
15-
class: nginx
15+
class: {{ .Values.issuerprod.ingressClass }}
1616
{{- end }}
1717

charts/theia-cloud-base/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ issuerprod:
99
enable: true
1010
# -- name for the let's encrypt production cluster issuer
1111
name: letsencrypt-prod
12+
# -- ingress class for the HTTP-01 ACME challenge solver
13+
ingressClass: nginx
1214

1315
issuerstaging:
1416
# -- name for the self signed cluster issuer

charts/theia-cloud/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 1.2.0-next.2
18+
version: 1.2.0-next.3
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to

charts/theia-cloud/README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# theia-cloud
22

3-
![Version: 1.2.0-next.2](https://img.shields.io/badge/Version-1.2.0--next.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.2.0-next](https://img.shields.io/badge/AppVersion-1.2.0--next-informational?style=flat-square)
3+
![Version: 1.2.0-next.3](https://img.shields.io/badge/Version-1.2.0--next.3-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.2.0-next](https://img.shields.io/badge/AppVersion-1.2.0--next-informational?style=flat-square)
44

55
A Helm chart for Theia Cloud
66

@@ -38,11 +38,18 @@ A Helm chart for Theia Cloud
3838
| 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 |
3939
| 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. |
4040
| ingress.clusterIssuer | string | `"letsencrypt-prod"` | The cluster issuer to use Only needed when ingress.certManagerAnnotations is true |
41-
| ingress.instances | object | `{"allWildcardSecretNames":{},"configurationSnippets":["proxy_set_header 'X-Forwarded-Uri' $request_uri"],"name":"theia-cloud-demo-ws-ingress","proxyBodySize":"1m"}` | Values to influence the instances ingress |
41+
| ingress.controller | string | `"nginx"` | The ingress controller to use. Currently supported: "nginx" or null Determines controller-specific default annotations and ingress class name to use. Using null or an unknown value results in only explicitly specified annotations being used. |
42+
| ingress.ingressClassName | string | `""` | Optional: Override the ingressClassName. If empty, defaults based on ingress.controller |
43+
| ingress.instances | object | (see details below) | Values to influence the instances ingress |
4244
| ingress.instances.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`. |
43-
| ingress.instances.configurationSnippets | list | `["proxy_set_header 'X-Forwarded-Uri' $request_uri"]` | Additional configuration to the ingress configuration via the `nginx.ingress.kubernetes.io/configuration-snippet` annotation. One entry in this array results in a line for the annotation. Do not add a semicolon at the end of the line here, it is automatically added. Note: Since ingress-nginx version 1.10 this annotation needs to be enabled. See [this README](../../README.md#cluster-prerequisites) for more information. |
45+
| ingress.instances.annotations | object | `{}` | Optional: Custom annotations for instances ingress. If empty, defaults based on ingress.controller |
46+
| ingress.instances.configurationSnippets | Deprecated | `["proxy_set_header 'X-Forwarded-Uri' $request_uri"]` | Additional configuration to the ingress configuration via the `nginx.ingress.kubernetes.io/configuration-snippet` annotation. One entry in this array results in a line for the annotation. Do not add a semicolon at the end of the line here, it is automatically added. This is deprecated in favor of using ingress.instances.annotations with the configuration-snippet key. If both configurationSnippets and annotations with configuration-snippet are provided, annotations takes precedence. Note: Since ingress-nginx version 1.10 this annotation needs to be enabled. See [this README](../../README.md#cluster-prerequisites) for more information. |
4447
| ingress.instances.name | 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 |
4548
| ingress.instances.proxyBodySize | string | `"1m"` | Sets the maximum allowed size of the client request body inside the application (e.g. file uploads in Theia). Defaults to 1m. Setting size to 0 disables checking of client request body size. |
49+
| ingress.landingPage | object | (see details below) | Values to influence the landing page ingress |
50+
| ingress.landingPage.annotations | object | `{}` | Optional: Custom annotations for landing page ingress. If empty, defaults based on ingress.controller |
51+
| ingress.service | object | (see details below) | Values to influence the service ingress |
52+
| ingress.service.annotations | object | `{}` | Optional: Custom annotations for service ingress. If empty, defaults based on ingress.controller |
4653
| ingress.theiaCloudCommonName | bool | `false` | When set to true the cert-manager.io/common-name annotation will be set. This is only required when the issued certificate by the cert-manager misses a common-name Only needed when ingress.certManagerAnnotations is true |
4754
| ingress.tls | bool | `true` | Does Theia Cloud expect TLS connections (true) or is TLS terminated outside of Theia Cloud (e.g. via a Load Balancer) (false) |
4855
| issuer | object | (see details below) | Values related to certificates/Cert-manager |
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
{{/*
2+
Return the ingress class name
3+
*/}}
4+
{{- define "theiacloud.ingress.className" -}}
5+
{{- if .Values.ingress.ingressClassName -}}
6+
{{ .Values.ingress.ingressClassName }}
7+
{{- else if eq .Values.ingress.controller "nginx" -}}
8+
nginx
9+
{{- else -}}
10+
{{ .Values.ingress.controller }}
11+
{{- end -}}
12+
{{- end -}}
13+
14+
{{/*
15+
Return the annotations for the instances ingress
16+
*/}}
17+
{{- define "theiacloud.ingress.instances.annotations" -}}
18+
{{- $annotations := dict -}}
19+
{{- if .Values.ingress.instances.annotations -}}
20+
{{- $annotations = .Values.ingress.instances.annotations -}}
21+
{{- else -}}
22+
{{- if eq .Values.ingress.controller "nginx" -}}
23+
{{- $annotations = include "theiacloud.ingress.nginx.instances.defaultAnnotations" . | fromYaml | default (dict) -}}
24+
{{- end -}}
25+
{{- end -}}
26+
{{- $certAnnotations := include "theiacloud.ingress.certManagerAnnotations" . | fromYaml | default (dict) -}}
27+
{{- $annotations = merge $annotations $certAnnotations -}}
28+
{{- $annotations | toYaml -}}
29+
{{- end -}}
30+
31+
{{/*
32+
Return the annotations for the landing page ingress
33+
*/}}
34+
{{- define "theiacloud.ingress.landingPage.annotations" -}}
35+
{{- $annotations := dict -}}
36+
{{- if .Values.ingress.landingPage.annotations -}}
37+
{{- $annotations = .Values.ingress.landingPage.annotations -}}
38+
{{- else -}}
39+
{{- if eq .Values.ingress.controller "nginx" -}}
40+
{{- $annotations = include "theiacloud.ingress.nginx.landingPage.defaultAnnotations" . | fromYaml | default (dict) -}}
41+
{{- end -}}
42+
{{- end -}}
43+
{{- $certAnnotations := include "theiacloud.ingress.certManagerAnnotations" (dict "root" . "includeHttp01" false) | fromYaml | default (dict) -}}
44+
{{- $annotations = merge $annotations $certAnnotations -}}
45+
{{- $annotations | toYaml -}}
46+
{{- end -}}
47+
48+
{{/*
49+
Return the annotations for the service ingress
50+
*/}}
51+
{{- define "theiacloud.ingress.service.annotations" -}}
52+
{{- $annotations := dict -}}
53+
{{- if .Values.ingress.service.annotations -}}
54+
{{- $annotations = .Values.ingress.service.annotations -}}
55+
{{- else -}}
56+
{{- if eq .Values.ingress.controller "nginx" -}}
57+
{{- $annotations = include "theiacloud.ingress.nginx.service.defaultAnnotations" . | fromYaml | default (dict) -}}
58+
{{- end -}}
59+
{{- end -}}
60+
{{- $certAnnotations := include "theiacloud.ingress.certManagerAnnotations" . | fromYaml | default (dict) -}}
61+
{{- $annotations = merge $annotations $certAnnotations -}}
62+
{{- $annotations | toYaml -}}
63+
{{- end -}}
64+
65+
{{/*
66+
Return default nginx annotations for instances ingress
67+
*/}}
68+
{{- define "theiacloud.ingress.nginx.instances.defaultAnnotations" -}}
69+
{{- if not .Values.ingress.tls }}
70+
nginx.ingress.kubernetes.io/ssl-redirect: "false"
71+
{{- end }}
72+
nginx.ingress.kubernetes.io/proxy-buffer-size: "128k"
73+
nginx.ingress.kubernetes.io/rewrite-target: /$2
74+
{{- if .Values.ingress.instances.configurationSnippets }}
75+
nginx.ingress.kubernetes.io/configuration-snippet: |
76+
{{- range .Values.ingress.instances.configurationSnippets }}
77+
{{ . }};
78+
{{- end }}
79+
{{- else }}
80+
nginx.ingress.kubernetes.io/configuration-snippet: |
81+
proxy_set_header 'X-Forwarded-Uri' $request_uri;
82+
{{- end }}
83+
nginx.ingress.kubernetes.io/proxy-body-size: {{ tpl (.Values.ingress.instances.proxyBodySize | toString) . }}
84+
{{- end -}}
85+
86+
{{/*
87+
Return default nginx annotations for landing page ingress (path-based)
88+
*/}}
89+
{{- define "theiacloud.ingress.nginx.landingPage.defaultAnnotations" -}}
90+
{{- if not .Values.ingress.tls }}
91+
nginx.ingress.kubernetes.io/ssl-redirect: "false"
92+
{{- end }}
93+
{{- if .Values.hosts.usePaths }}
94+
{{- if .Values.hosts.configuration.landing }}
95+
nginx.ingress.kubernetes.io/rewrite-target: /$2
96+
{{- end }}
97+
nginx.ingress.kubernetes.io/configuration-snippet: |
98+
rewrite ^([^.?]*[^/])$ $1/ redirect;
99+
{{- end }}
100+
{{- end -}}
101+
102+
{{/*
103+
Return default nginx annotations for service ingress
104+
*/}}
105+
{{- define "theiacloud.ingress.nginx.service.defaultAnnotations" -}}
106+
{{- if not .Values.ingress.tls }}
107+
nginx.ingress.kubernetes.io/ssl-redirect: "false"
108+
{{- end }}
109+
nginx.ingress.kubernetes.io/rewrite-target: /service$1
110+
{{- end -}}
111+
112+
{{/*
113+
Return cert-manager annotations if enabled
114+
Params:
115+
. - root context
116+
includeHttp01 - (optional) whether to include HTTP-01 specific annotations
117+
*/}}
118+
{{- define "theiacloud.ingress.certManagerAnnotations" -}}
119+
{{- $includeHttp01 := true -}}
120+
{{- if hasKey . "includeHttp01" -}}
121+
{{- $includeHttp01 = .includeHttp01 -}}
122+
{{- end -}}
123+
{{- $root := . -}}
124+
{{- if hasKey . "root" -}}
125+
{{- $root = .root -}}
126+
{{- end -}}
127+
{{- if $root.Values.ingress.addTLSSecretName }}
128+
{{- if $root.Values.ingress.certManagerAnnotations }}
129+
cert-manager.io/cluster-issuer: {{ tpl ($root.Values.ingress.clusterIssuer | toString) $root }}
130+
{{- if and $includeHttp01 $root.Values.ingress.theiaCloudCommonName }}
131+
cert-manager.io/common-name: "Theia Cloud"
132+
{{- end }}
133+
{{- if $includeHttp01 }}
134+
acme.cert-manager.io/http01-ingress-class: {{ include "theiacloud.ingress.className" $root }}
135+
{{- end }}
136+
{{- end }}
137+
{{- end }}
138+
{{- end -}}

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

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,9 @@ metadata:
55
name: {{ tpl (.Values.ingress.instances.name | toString) . }}
66
namespace: {{ .Release.Namespace }}
77
annotations:
8-
{{- if not .Values.ingress.tls }}
9-
nginx.ingress.kubernetes.io/ssl-redirect: "false"
10-
{{- end }}
11-
nginx.ingress.kubernetes.io/proxy-buffer-size: "128k"
12-
nginx.ingress.kubernetes.io/rewrite-target: /$2
13-
{{- if .Values.ingress.instances.configurationSnippets }}
14-
nginx.ingress.kubernetes.io/configuration-snippet: |
15-
{{- range .Values.ingress.instances.configurationSnippets }}
16-
{{ . }};
17-
{{- end }}
18-
{{- end }}
19-
nginx.ingress.kubernetes.io/proxy-body-size: {{ tpl (.Values.ingress.instances.proxyBodySize | toString) . }}
20-
{{- if .Values.ingress.addTLSSecretName }}
21-
{{- if .Values.ingress.certManagerAnnotations }}
22-
cert-manager.io/cluster-issuer: {{ tpl (.Values.ingress.clusterIssuer | toString) . }}
23-
{{- if .Values.ingress.theiaCloudCommonName }}
24-
cert-manager.io/common-name: "Theia Cloud"
25-
{{- end }}
26-
acme.cert-manager.io/http01-ingress-class: nginx
27-
{{- end }}
28-
{{- end }}
8+
{{- include "theiacloud.ingress.instances.annotations" . | nindent 4 }}
299
spec:
30-
ingressClassName: nginx
10+
ingressClassName: {{ include "theiacloud.ingress.className" . }}
3111
{{- if .Values.ingress.tls }}
3212
tls:
3313
- hosts:

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

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,9 @@ metadata:
55
name: {{ tpl (.Values.ingress.instances.name | toString) . }}
66
namespace: {{ .Release.Namespace }}
77
annotations:
8-
{{- if not .Values.ingress.tls }}
9-
nginx.ingress.kubernetes.io/ssl-redirect: "false"
10-
{{- end }}
11-
{{- if .Values.ingress.addTLSSecretName }}
12-
{{- if .Values.ingress.certManagerAnnotations }}
13-
cert-manager.io/cluster-issuer: {{ tpl (.Values.ingress.clusterIssuer | toString) . }}
14-
{{- if .Values.ingress.theiaCloudCommonName }}
15-
cert-manager.io/common-name: "Theia Cloud"
16-
{{- end }}
17-
acme.cert-manager.io/http01-ingress-class: nginx
18-
{{- end }}
19-
{{- end }}
20-
nginx.ingress.kubernetes.io/proxy-buffer-size: "128k"
21-
nginx.ingress.kubernetes.io/rewrite-target: /$2
22-
{{- if .Values.ingress.instances.configurationSnippets }}
23-
nginx.ingress.kubernetes.io/configuration-snippet: |
24-
{{- range .Values.ingress.instances.configurationSnippets }}
25-
{{ . }};
26-
{{- end }}
27-
{{- end }}
28-
nginx.ingress.kubernetes.io/proxy-body-size: {{ tpl (.Values.ingress.instances.proxyBodySize | toString) . }}
8+
{{- include "theiacloud.ingress.instances.annotations" . | nindent 4 }}
299
spec:
30-
ingressClassName: nginx
10+
ingressClassName: {{ include "theiacloud.ingress.className" . }}
3111
{{- if .Values.ingress.tls }}
3212
tls:
3313
- hosts:

charts/theia-cloud/templates/landing-page-ingress-path-based.yaml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,10 @@ kind: Ingress
55
metadata:
66
name: landing-page-ingress
77
annotations:
8-
{{- if not .Values.ingress.tls }}
9-
nginx.ingress.kubernetes.io/ssl-redirect: "false"
10-
{{- end }}
11-
{{- if .Values.hosts.configuration.landing }}
12-
nginx.ingress.kubernetes.io/rewrite-target: /$2
13-
{{- end }}
14-
# Rewrite all URLs not ending with a segment containing . or ? with a trailing slash
15-
# This is necessary to correctly resolve relative paths (e.g. for css files) from the landing page.
16-
nginx.ingress.kubernetes.io/configuration-snippet: |
17-
rewrite ^([^.?]*[^/])$ $1/ redirect;
18-
{{- if .Values.ingress.addTLSSecretName }}
19-
{{- if .Values.ingress.certManagerAnnotations }}
20-
cert-manager.io/cluster-issuer: {{ tpl (.Values.ingress.clusterIssuer | toString) . }}
21-
{{- end }}
22-
{{- end }}
8+
{{- include "theiacloud.ingress.landingPage.annotations" . | nindent 4 }}
239
namespace: {{ .Release.Namespace }}
2410
spec:
25-
ingressClassName: nginx
11+
ingressClassName: {{ include "theiacloud.ingress.className" . }}
2612
{{- if .Values.ingress.tls }}
2713
tls:
2814
- hosts:

0 commit comments

Comments
 (0)