Skip to content

Commit

Permalink
Added support for ingress.timeoutSeconds with Contour
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianeicher committed Mar 27, 2024
1 parent 82a9dce commit 5faac4c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
4 changes: 2 additions & 2 deletions charts/generic-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ app:
| `ingress.enabled` | `false` | Enables ingress into the service (either cluster-internal or public) |
| `ingress.port` | `80` | The container port ingress traffic is routed to |
| `ingress.protocol` | `http` | The internal protocol used for ingress (e.g., `http`, `https`, `h2c`, `grpc`, `http2`/`h2` or `grpcs`) |
| `ingress.timeoutSeconds` | | Number of seconds after which to timeout waiting for response from service |
| `ingress.timeoutSeconds` | | Number of seconds after which to timeout waiting for response from service; -1 for infinite |
| `ingress.domains` | `[]` | The public domain names under which the service is exposed (leave empty for cluster-internal only) |
| `ingress.paths` | `[]` | HTTP path prefixes to accept ingress traffic for (leave empty to accept traffic for any path) |
| `ingress.tls.enabled` | `false` | Enables TLS termination at the ingress (not applicable if `ingress.istio.enabled`) |
Expand All @@ -122,7 +122,7 @@ app:
| `ingress.extra.*.class` | same as `ingress.class` | Additional ingress controller to use (not applicable if `ingress.istio.enabled`) |
| `ingress.extra.*.port` | same as `ingress.port` | Additional container port ingress traffic is routed to (not applicable if `ingress.istio.enabled`) |
| `ingress.extra.*.protocol` | `http` | The protocol used for the port (e.g., `http`, `https`, `h2c`, `grpc`, `http2`/`h2` or `grpcs`) |
| `ingress.extra.*.timeoutSeconds` | | Number of seconds after which to timeout waiting for response from service |
| `ingress.extra.*.timeoutSeconds` | | Number of seconds after which to timeout waiting for response from service; -1 for infinite |
| `ingress.extra.*.domains` | `[]` | The public domain names under which the port is exposed (leave empty for cluster-internal only) |
| `ingress.extra.*.paths` | `[]` | HTTP path prefixes to accept ingress traffic for (leave empty to accept traffic for any path) |
| `ingress.extra.*.tls.enabled` | `false` | Enables TLS termination at the ingress |
Expand Down
14 changes: 14 additions & 0 deletions charts/generic-service/ci/ingress-contour-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Contour ingress test

image:
repository: jwilder/whoami
tag: latest

ingress:
enabled: true
port: 8000
class: contour
extra:
timeout:
domains: ['timeout.example.com']
timeoutSeconds: -1 # infinte
10 changes: 8 additions & 2 deletions charts/generic-service/templates/ingress-extra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{{- range $name, $extra := .Values.ingress.extra }}
{{- if $extra.domains }}
{{ $class := $extra.class | default $.Values.ingress.class }}
{{ $timeout := $extra.timeoutSeconds | default $.Values.ingress.timeoutSeconds }}

apiVersion: networking.k8s.io/v1
kind: Ingress
Expand All @@ -20,12 +21,17 @@ metadata:
{{- if $extra.port }}{{ $protocol = $extra.protocol }}{{ end }}
nginx.ingress.kubernetes.io/backend-protocol: {{ include "generic-service.normalize-protocol" $protocol | upper }}
{{- if or $extra.timeoutSeconds $.Values.ingress.timeoutSeconds }}
nginx.ingress.kubernetes.io/proxy-read-timeout: '{{ $extra.timeoutSeconds | default $.Values.ingress.timeoutSeconds }}'
nginx.ingress.kubernetes.io/proxy-read-timeout: '{{ $timeout }}'
{{- if or (eq $protocol "grpc") (eq $protocol "grpcs") }}
nginx.ingress.kubernetes.io/server-snippet: "grpc_read_timeout {{ $extra.timeoutSeconds | default $.Values.ingress.timeoutSeconds }}s; {{ get $merged "nginx.ingress.kubernetes.io/server-snippet" }}"
nginx.ingress.kubernetes.io/server-snippet: "grpc_read_timeout {{ $timeout }}s; {{ get $merged "nginx.ingress.kubernetes.io/server-snippet" }}"
{{- end }}
{{- end }}
{{- end }}
{{- if eq $class "contour" }}
{{- if $timeout }}
projectcontour.io/response-timeout: '{{ if eq (int $timeout) -1 }}infinity{{ else }}{{ $timeout }}s{{ end }}'
{{- end }}
{{- end }}

spec:
{{- if $class }}
Expand Down
5 changes: 5 additions & 0 deletions charts/generic-service/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ metadata:
{{ if .Values.ingress.cors.exposeHeaders }}nginx.ingress.kubernetes.io/cors-expose-headers: {{ join "," .Values.ingress.cors.exposeHeaders | quote }}{{ end }}
{{- end }}
{{- end }}
{{- if eq .Values.ingress.class "contour" }}
{{- if .Values.ingress.timeoutSeconds }}
projectcontour.io/response-timeout: '{{ if eq (int .Values.ingress.timeoutSeconds) -1 }}infinity{{ else }}{{ .Values.ingress.timeoutSeconds }}s{{ end }}'
{{- end }}
{{- end }}

spec:
{{- if .Values.ingress.class }}
Expand Down
4 changes: 2 additions & 2 deletions charts/generic-service/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@
},
"timeoutSeconds": {
"type": ["integer", "null"],
"description": "Number of seconds after which to timeout waiting for response from service"
"description": "Number of seconds after which to timeout waiting for response from service; -1 for infinite"
},
"domains": {
"type": "array",
Expand Down Expand Up @@ -652,7 +652,7 @@
},
"timeoutSeconds": {
"type": ["integer", "null"],
"description": "Number of seconds after which to timeout waiting for response from service"
"description": "Number of seconds after which to timeout waiting for response from service; -1 for infinite"
},
"domains": {
"type": "array",
Expand Down

0 comments on commit 5faac4c

Please sign in to comment.