{{- if and .Values.prometheus.enabled .Values.prometheus.thanosIngress.enabled }} {{- $pathType := .Values.prometheus.thanosIngress.pathType | default "" }} {{- $serviceName := printf "%s-%s" (include "kube-prometheus-stack.fullname" .) "prometheus" }} {{- $thanosPort := .Values.prometheus.thanosIngress.servicePort -}} {{- $routePrefix := list .Values.prometheus.prometheusSpec.routePrefix }} {{- $paths := .Values.prometheus.thanosIngress.paths | default $routePrefix -}} {{- $apiIsStable := eq (include "kube-prometheus-stack.ingress.isStable" .) "true" -}} apiVersion: {{ include "kube-prometheus-stack.ingress.apiVersion" . }} kind: Ingress metadata: {{- if .Values.prometheus.thanosIngress.annotations }} annotations: {{ toYaml .Values.prometheus.thanosIngress.annotations | indent 4 }} {{- end }} name: {{ template "kube-prometheus-stack.fullname" . }}-thanos-gateway labels: app: {{ template "kube-prometheus-stack.name" . }}-prometheus {{ include "kube-prometheus-stack.labels" . | indent 4 }} {{- if .Values.prometheus.thanosIngress.labels }} {{ toYaml .Values.prometheus.thanosIngress.labels | indent 4 }} {{- end }} spec: {{- if $apiIsStable }} {{- if .Values.prometheus.thanosIngress.ingressClassName }} ingressClassName: {{ .Values.prometheus.thanosIngress.ingressClassName }} {{- end }} {{- end }} rules: {{- if .Values.prometheus.thanosIngress.hosts }} {{- range $host := .Values.prometheus.thanosIngress.hosts }} - host: {{ tpl $host $ }} http: paths: {{- range $p := $paths }} - path: {{ tpl $p $ }} {{- if $pathType }} pathType: {{ $pathType }} {{- end }} backend: {{- if $apiIsStable }} service: name: {{ $serviceName }} port: number: {{ $thanosPort }} {{- else }} serviceName: {{ $serviceName }} servicePort: {{ $thanosPort }} {{- end }} {{- end -}} {{- end -}} {{- else }} - http: paths: {{- range $p := $paths }} - path: {{ tpl $p $ }} {{- if $pathType }} pathType: {{ $pathType }} {{- end }} backend: {{- if $apiIsStable }} service: name: {{ $serviceName }} port: number: {{ $thanosPort }} {{- else }} serviceName: {{ $serviceName }} servicePort: {{ $thanosPort }} {{- end }} {{- end -}} {{- end -}} {{- if .Values.prometheus.thanosIngress.tls }} tls: {{ toYaml .Values.prometheus.thanosIngress.tls | indent 4 }} {{- end -}} {{- end -}}