Skip to content

Commit 403ca10

Browse files
[prometheus-pushgateway] Add HTTPRoute support (#6360)
Signed-off-by: Jocelyn Thode <[email protected]> Signed-off-by: zeritti <[email protected]> Co-authored-by: zeritti <[email protected]>
1 parent 0b95a2b commit 403ca10

File tree

5 files changed

+122
-1
lines changed

5 files changed

+122
-1
lines changed

charts/prometheus-pushgateway/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: v2
33
appVersion: v1.11.2
44
description: A Helm chart for prometheus pushgateway
55
name: prometheus-pushgateway
6-
version: 3.4.2
6+
version: 3.5.0
77
home: https://github.com/prometheus/pushgateway
88
sources:
99
- https://github.com/prometheus/pushgateway
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
## Test case: httpRoute
3+
route:
4+
main:
5+
enabled: true
6+
labels:
7+
foo: bar
8+
baz: qux
9+
hostnames:
10+
- "an.example.com"
11+
parentRefs:
12+
- name: contour
13+
filters:
14+
- type: RequestHeaderModifier
15+
requestHeaderModifier:
16+
set:
17+
- name: my-header-name
18+
value: my-new-header-value
19+
additionalRules:
20+
- filters:
21+
- type: RequestHeaderModifier
22+
requestHeaderModifier:
23+
remove: ["x-request-id"]

charts/prometheus-pushgateway/templates/NOTES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
{{- range .Values.ingress.hosts }}
44
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }}
55
{{- end }}
6+
{{- else if .Values.route.main.enabled }}
7+
{{- range .Values.route.main.hostnames }}
8+
http://{{ tpl . $ }}
9+
{{- end }}
610
{{- else if contains "NodePort" .Values.service.type }}
711
export NODE_PORT=$(kubectl get --namespace {{ template "prometheus-pushgateway.namespace" . }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "prometheus-pushgateway.fullname" . }})
812
export NODE_IP=$(kubectl get nodes --namespace {{ template "prometheus-pushgateway.namespace" . }} -o jsonpath="{.items[0].status.addresses[0].address}")
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{{- range $name, $route := .Values.route }}
2+
{{- if $route.enabled }}
3+
---
4+
apiVersion: {{ $route.apiVersion | default "gateway.networking.k8s.io/v1" }}
5+
kind: {{ $route.kind | default "HTTPRoute" }}
6+
metadata:
7+
{{- with $route.annotations }}
8+
annotations: {{ toYaml . | nindent 4 }}
9+
{{- end }}
10+
name: {{ include "prometheus-pushgateway.fullname" $ }}
11+
namespace: {{ include "prometheus-pushgateway.namespace" $ }}
12+
labels: {{ include "prometheus-pushgateway.defaultLabels" $ | nindent 4 }}
13+
{{- with $route.labels }}
14+
{{- toYaml . | nindent 4 }}
15+
{{- end }}
16+
spec:
17+
{{- with $route.parentRefs }}
18+
parentRefs: {{ toYaml . | nindent 4 }}
19+
{{- end }}
20+
{{- with $route.hostnames }}
21+
hostnames: {{ tpl (toYaml .) $ | nindent 4 }}
22+
{{- end }}
23+
rules:
24+
{{- with $route.additionalRules }}
25+
{{- tpl (toYaml .) $ | nindent 4 }}
26+
{{- end }}
27+
{{- if $route.httpsRedirect }}
28+
- filters:
29+
- type: RequestRedirect
30+
requestRedirect:
31+
scheme: https
32+
statusCode: 301
33+
{{- else }}
34+
- backendRefs:
35+
- name: {{ include "prometheus-pushgateway.fullname" $ }}
36+
port: {{ $.Values.service.port }}
37+
{{- with $route.filters }}
38+
filters: {{ toYaml . | nindent 8 }}
39+
{{- end }}
40+
{{- with $route.matches }}
41+
matches: {{ toYaml . | nindent 8 }}
42+
{{- end }}
43+
{{- end }}
44+
{{- end }}
45+
{{- end }}

charts/prometheus-pushgateway/values.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,55 @@ ingress:
189189
# hosts:
190190
# - pushgateway.domain.com
191191

192+
## route (map) allows configuration of HTTPRoute resources
193+
## Requires Gateway API resources and suitable controller installed within the cluster
194+
## Ref. https://gateway-api.sigs.k8s.io/guides/http-routing/
195+
route:
196+
main:
197+
## Enable this route
198+
enabled: false
199+
200+
## ApiVersion set by default to "gateway.networking.k8s.io/v1"
201+
apiVersion: ""
202+
## kind set by default to HTTPRoute
203+
kind: ""
204+
205+
## Annotations to attach to the HTTPRoute resource
206+
annotations: {}
207+
## Labels to attach to the HTTPRoute resource
208+
labels: {}
209+
210+
## ParentRefs refers to resources this HTTPRoute is to be attached to (Gateways)
211+
parentRefs: []
212+
# - name: contour
213+
# sectionName: http
214+
215+
## Hostnames (templated) defines a set of hostnames that should match against the HTTP Host
216+
## header to select a HTTPRoute used to process the request
217+
hostnames: []
218+
# - my.example.com
219+
220+
## additionalRules (templated) allows adding custom rules to the route
221+
additionalRules: []
222+
223+
## Filters define the filters that are applied to requests that match
224+
## this rule
225+
filters: []
226+
227+
## Matches define conditions used for matching the rule against incoming
228+
## HTTP requests
229+
matches:
230+
- path:
231+
type: PathPrefix
232+
value: /
233+
234+
## httpsRedirect adds a filter for redirecting to https (HTTP 301 Moved Permanently).
235+
## To redirect HTTP traffic to HTTPS, you need to have a Gateway with both HTTP and HTTPS listeners.
236+
## Matches and filters do not take effect if enabled.
237+
## Ref. https://gateway-api.sigs.k8s.io/guides/http-redirect-rewrite/
238+
httpsRedirect: false
239+
240+
192241
tolerations: []
193242
# - effect: NoSchedule
194243
# operator: Exists

0 commit comments

Comments
 (0)