kubezero/charts/kubezero-metrics/charts/kube-prometheus-stack/templates/prometheus/ingressThanosSidecar.yaml

81 lines
2.9 KiB
YAML

{{- 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 -}}
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1" -}}
apiVersion: networking.k8s.io/v1
{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
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 or (.Capabilities.APIVersions.Has "networking.k8s.io/v1") (.Capabilities.APIVersions.Has "networking.k8s.io/v1beta1") }}
{{- 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 $.Capabilities.APIVersions.Has "networking.k8s.io/v1" }}
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 $.Capabilities.APIVersions.Has "networking.k8s.io/v1" }}
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 -}}