Skip to content

Commit 1441703

Browse files
fix: devurlsHost ref in ingress template (#233)
* Added .Values.ingress.classname and ingressClassName to ingress template spec * adding .idea to gitignore * fix: devurlsHost ref in ingress template * Apply suggestions from code review * Add tests and update README.md * Clarify ingress values in docs * Do not include ingressClassName if empty Co-authored-by: Dean Sheather <dean@deansheather.com>
1 parent a9a2840 commit 1441703

File tree

6 files changed

+29
-8
lines changed

6 files changed

+29
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/build
22
*.swp
3+
.idea

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,12 @@ View [our docs](https://coder.com/docs/setup/installation) for detailed installa
8181
| coderd.trustProxyIP | bool | Configures Coder to accept X-Real-IP and X-Forwarded-For headers from any origin. This option is deprecated and will be removed in a future release. Use the coderd.reverseProxy setting instead, which supports configuring an allowlist of trusted origins. | `false` |
8282
| envbox | object | Required for running Docker inside containers. See requirements: https://coder.com/docs/coder/latest/admin/workspace-management/cvms | `{"image":""}` |
8383
| envbox.image | string | Injected by Coder during release. | `""` |
84-
| ingress | object | Configure an Ingress to route traffic to Coder services. | `{"annotations":{"nginx.ingress.kubernetes.io/proxy-body-size":"0"},"enable":false,"host":"","tls":{"enable":false}}` |
84+
| ingress | object | Configure an Ingress to route traffic to Coder services. | `{"annotations":{"nginx.ingress.kubernetes.io/proxy-body-size":"0"},"className":"","enable":false,"host":"","tls":{"enable":false}}` |
8585
| ingress.annotations | object | Additional annotations to add to the Ingress object. The behavior is typically dependent on the Ingress Controller implementation, and useful for managing features like TLS termination. | `{"nginx.ingress.kubernetes.io/proxy-body-size":"0"}` |
86+
| ingress.className | string | The ingressClassName to set on the Ingress. | `""` |
8687
| ingress.enable | bool | A boolean controlling whether to create an Ingress. | `false` |
87-
| ingress.host | string | The hostname to proxy to the Coder installation. The cluster Ingress Controller typically uses server name indication or the HTTP Host header to route traffic. | `""` |
88-
| ingress.tls | object | Configures TLS settings for the Ingress. | `{"enable":false}` |
88+
| ingress.host | string | The hostname to proxy to the Coder installation. The cluster Ingress Controller typically uses server name indication or the HTTP Host header to route traffic. The dev URLs hostname is specified in coderd.devurlsHost. | `""` |
89+
| ingress.tls | object | Configures TLS settings for the Ingress. TLS certificates are specified in coderd.tls.hostSecretName and coderd.tls.devurlsHostSecretName. | `{"enable":false}` |
8990
| ingress.tls.enable | bool | Determines whether the Ingress handles TLS. | `false` |
9091
| logging | object | Configures the logging format and output of Coder. | `{"human":"/dev/stderr","json":"","splunk":{"channel":"","token":"","url":""},"stackdriver":""}` |
9192
| logging.human | string | Location to send logs that are formatted for readability. Set to an empty string to disable. | `"/dev/stderr"` |

templates/ingress.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ metadata:
1414
app.kubernetes.io/component: {{ include "coder.serviceName" . }}
1515
annotations: {{ toYaml .Values.ingress.annotations | nindent 4 }}
1616
spec:
17+
{{- if .Values.ingress.className }}
18+
{{/* If this is set to an empty string it fails validation on K8s */}}
19+
ingressClassName: {{ .Values.ingress.className | quote }}
20+
{{- end }}
1721
rules:
1822
- host: {{ .Values.ingress.host | quote }}
1923
http:
@@ -54,12 +58,10 @@ spec:
5458
- {{ .Values.ingress.host | quote }}
5559
secretName: {{ .Values.coderd.tls.hostSecretName | quote}}
5660
{{- end }}
57-
{{- if .Values.devurls }}
58-
{{- if and .Values.devurls.host .Values.coderd.tls.devurlsHostSecretName }}
61+
{{- if and .Values.coderd.devurlsHost .Values.coderd.tls.devurlsHostSecretName }}
5962
- hosts:
6063
- {{ .Values.coderd.devurlsHost | quote }}
6164
secretName: {{ .Values.coderd.tls.devurlsHostSecretName | quote }}
6265
{{- end }}
63-
{{- end }}
6466
{{- end }}
6567
{{- end }}

tests/ingress_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ func TestIngress(t *testing.T) {
5757
}
5858
require.Equal(t, defaultAnnotations, ingress.Annotations)
5959

60+
require.Empty(t, ingress.Spec.IngressClassName)
61+
6062
expectedRules := []netv1.IngressRule{
6163
{
6264
Host: "install.coder.com",
@@ -95,6 +97,16 @@ func TestIngress(t *testing.T) {
9597
require.Equal(t, expectedRules, ingress.Spec.Rules, "expected ingress spec to match")
9698
},
9799
},
100+
{
101+
Name: "ingress-className",
102+
ValuesFunc: func(v *CoderValues) {
103+
v.Ingress.Enable = pointer.Bool(true)
104+
v.Ingress.ClassName = pointer.String("test")
105+
},
106+
AssertFunc: func(t *testing.T, ingress *netv1.Ingress) {
107+
require.Equal(t, pointer.String("test"), ingress.Spec.IngressClassName, "expected classname to match")
108+
},
109+
},
98110
}
99111

100112
for _, test := range tests {

tests/values.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ type EnvboxValues struct {
188188
// IngressValues reflect values from ingress.
189189
type IngressValues struct {
190190
Enable *bool `json:"enable" yaml:"enable"`
191+
ClassName *string `json:"className" yaml:"className"`
191192
Host *string `json:"host" yaml:"host"`
192193
Annotations map[string]string `json:"annotations" yaml:"annotations"`
193194
TLS *IngressTLSValues `json:"tls" yaml:"tls"`

values.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,17 +269,21 @@ coderd:
269269
ingress:
270270
# ingress.enable -- A boolean controlling whether to create an Ingress.
271271
enable: false
272+
# ingress.className -- The ingressClassName to set on the Ingress.
273+
className: ""
272274
# ingress.host -- The hostname to proxy to the Coder installation.
273275
# The cluster Ingress Controller typically uses server name indication
274-
# or the HTTP Host header to route traffic.
276+
# or the HTTP Host header to route traffic. The dev URLs hostname is specified
277+
# in coderd.devurlsHost.
275278
host: ""
276279
# ingress.annotations -- Additional annotations to add to the Ingress
277280
# object. The behavior is typically dependent on the Ingress Controller
278281
# implementation, and useful for managing features like TLS termination.
279282
annotations:
280283
nginx.ingress.kubernetes.io/proxy-body-size: "0"
281284

282-
# ingress.tls -- Configures TLS settings for the Ingress.
285+
# ingress.tls -- Configures TLS settings for the Ingress. TLS certificates are
286+
# specified in coderd.tls.hostSecretName and coderd.tls.devurlsHostSecretName.
283287
tls:
284288
# ingress.tls.enable -- Determines whether the Ingress handles TLS.
285289
enable: false

0 commit comments

Comments
 (0)