{{- if .Values.kubecostMetrics }} {{- if .Values.kubecostMetrics.exporter }} {{- if .Values.kubecostMetrics.exporter.enabled }} {{- $prometheusScrape := ternary .Values.kubecostMetrics.exporter.prometheusScrape true (kindIs "bool" .Values.kubecostMetrics.exporter.prometheusScrape) }} apiVersion: v1 kind: Service metadata: name: {{ template "kubecost.kubeMetricsName" . }} namespace: {{ .Release.Namespace }} labels: {{ unset (include "cost-analyzer.commonLabels" . | fromYaml) "app" | toYaml | nindent 4 }} app: {{ template "kubecost.kubeMetricsName" . }} {{- if (or .Values.kubecostMetrics.exporter.service.annotations $prometheusScrape) }} annotations: {{- if .Values.kubecostMetrics.exporter.service.annotations }} {{ toYaml .Values.kubecostMetrics.exporter.service.annotations | indent 4 }} {{- end }} {{- if $prometheusScrape }} prometheus.io/scrape: "true" prometheus.io/port: {{ (quote .Values.kubecostMetrics.exporter.port) | default (quote 9005) }} {{- end }} {{- end }} spec: ports: - name: tcp-metrics port: {{ .Values.kubecostMetrics.exporter.port | default 9005 }} protocol: TCP targetPort: {{ .Values.kubecostMetrics.exporter.port | default 9005 }} selector: app: {{ template "kubecost.kubeMetricsName" . }} type: ClusterIP {{- end }} {{- end }} {{- end }}