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

47 lines
1.8 KiB
YAML

{{- if and .Values.prometheus.enabled .Values.prometheus.servicePerReplica.enabled }}
{{- $count := .Values.prometheus.prometheusSpec.replicas | int -}}
{{- $serviceValues := .Values.prometheus.servicePerReplica -}}
apiVersion: v1
kind: List
metadata:
name: {{ include "kube-prometheus-stack.fullname" $ }}-prometheus-serviceperreplica
namespace: {{ template "kube-prometheus-stack.namespace" . }}
items:
{{- range $i, $e := until $count }}
- apiVersion: v1
kind: Service
metadata:
name: {{ include "kube-prometheus-stack.fullname" $ }}-prometheus-{{ $i }}
namespace: {{ template "kube-prometheus-stack.namespace" $ }}
labels:
app: {{ include "kube-prometheus-stack.name" $ }}-prometheus
{{ include "kube-prometheus-stack.labels" $ | indent 8 }}
{{- if $serviceValues.annotations }}
annotations:
{{ toYaml $serviceValues.annotations | indent 8 }}
{{- end }}
spec:
{{- if $serviceValues.clusterIP }}
clusterIP: {{ $serviceValues.clusterIP }}
{{- end }}
{{- if $serviceValues.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{- range $cidr := $serviceValues.loadBalancerSourceRanges }}
- {{ $cidr }}
{{- end }}
{{- end }}
ports:
- name: {{ $.Values.prometheus.prometheusSpec.portName }}
{{- if eq $serviceValues.type "NodePort" }}
nodePort: {{ $serviceValues.nodePort }}
{{- end }}
port: {{ $serviceValues.port }}
targetPort: {{ $serviceValues.targetPort }}
selector:
app.kubernetes.io/name: prometheus
prometheus: {{ include "kube-prometheus-stack.fullname" $ }}-prometheus
statefulset.kubernetes.io/pod-name: prometheus-{{ include "kube-prometheus-stack.fullname" $ }}-prometheus-{{ $i }}
type: "{{ $serviceValues.type }}"
{{- end }}
{{- end }}