Skip to content

Commit

Permalink
[prometheus] add tpl to ingress (#4956)
Browse files Browse the repository at this point in the history
* add tpl into ingress

Signed-off-by: Chris Jedro <[email protected]>

* fix NOTES.txt

Signed-off-by: Chris Jedro <[email protected]>

* fix NOTES.txt

Signed-off-by: Chris Jedro <[email protected]>

---------

Signed-off-by: Chris Jedro <[email protected]>
  • Loading branch information
christianjedroCDT authored Nov 4, 2024
1 parent 79c53c7 commit a6a4d8d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion charts/prometheus/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: prometheus
appVersion: v2.55.0
version: 25.28.0
version: 25.29.0
kubeVersion: ">=1.19.0-0"
description: Prometheus is a monitoring system and time series database.
home: https://prometheus.io/
Expand Down
16 changes: 16 additions & 0 deletions charts/prometheus/ci/12-ingress-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
## Test case: add ingress, also using tpl
global:
default:
hostname: "example.com"

server:
ingress:
enabled: true
ingressClassName: nginx
hosts:
- '{{ $.Values.global.default.hostname }}'
tls:
- secretName: ingress-tls-certificate
hosts:
- '{{ $.Values.global.default.hostname }}'
2 changes: 1 addition & 1 deletion charts/prometheus/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The Prometheus server can be accessed via port {{ .Values.server.service.service
{{ if .Values.server.ingress.enabled -}}
From outside the cluster, the server URL(s) are:
{{- range .Values.server.ingress.hosts }}
http://{{ . }}
http://{{ tpl . $ }}
{{- end }}
{{- else }}
Get the Prometheus server URL by running these commands in the same shell:
Expand Down
8 changes: 4 additions & 4 deletions charts/prometheus/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ spec:
rules:
{{- range .Values.server.ingress.hosts }}
{{- $url := splitList "/" . }}
- host: {{ first $url }}
- host: {{ tpl (first $url) $ }}
http:
paths:
{{ if $extraPaths }}
{{ toYaml $extraPaths | indent 10 }}
{{ tpl (toYaml $extraPaths | indent 10) $ }}
{{- end }}
- path: {{ $ingressPath }}
- path: {{ tpl ($ingressPath) $ }}
{{- if $ingressSupportsPathType }}
pathType: {{ $ingressPathType }}
{{- end }}
Expand All @@ -52,6 +52,6 @@ spec:
{{- end -}}
{{- if .Values.server.ingress.tls }}
tls:
{{ toYaml .Values.server.ingress.tls | indent 4 }}
{{ tpl (toYaml .Values.server.ingress.tls | indent 4) $ }}
{{- end -}}
{{- end -}}
6 changes: 3 additions & 3 deletions charts/prometheus/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ server:
## Redirect ingress to an additional defined port on the service
# servicePort: 8081

## Prometheus server Ingress hostnames with optional path
## Prometheus server Ingress hostnames with optional path (passed through tpl)
## Must be provided if Ingress is enabled
##
hosts: []
Expand All @@ -389,14 +389,14 @@ server:
# pathType is only for k8s >= 1.18
pathType: Prefix

## Extra paths to prepend to every host configuration. This is useful when working with annotation based services.
## Extra paths to prepend to every host configuration. This is useful when working with annotation based services. (passed through tpl)
extraPaths: []
# - path: /*
# backend:
# serviceName: ssl-redirect
# servicePort: use-annotation

## Prometheus server Ingress TLS configuration
## Prometheus server Ingress TLS configuration (hosts passed through tpl)
## Secrets must be manually created in the namespace
##
tls: []
Expand Down

0 comments on commit a6a4d8d

Please sign in to comment.