{{- if and (.Values.service.enabled) (eq .Values.application.track "stable") -}}
apiVersion: v1
kind: Service
metadata:
  name: {{ template "fullname" . }}
  annotations:
{{- if .Values.service.annotations }}
{{ toYaml .Values.service.annotations | indent 4 }}
{{- end }}
{{- if .Values.prometheus.metrics }}
    prometheus.io/scrape: "true"
    prometheus.io/port: "{{ .Values.service.internalPort }}"
{{- end }}
  labels:
    app: {{ template "appname" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
spec:
  type: {{ .Values.service.type }}
  ports:
  - port: {{ .Values.service.externalPort }}
    targetPort: {{ .Values.service.internalPort }}
    protocol: TCP
    name: {{ .Values.service.name }}
  selector:
    app: {{ template "appname" . }}
    tier: "{{ .Values.application.tier }}"
{{- end -}}
