apiVersion: v1
kind: Service
metadata:
  name: {{ template "mssql.fullname" . }}
  labels:
    app: {{ template "mssql.name" . }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
{{- if .Values.service.labels }}
{{ toYaml .Values.service.labels | indent 4 }}
{{- end }}
{{- if .Values.service.annotations }}
  annotations:
{{ toYaml .Values.service.annotations | indent 4 }}
{{- end }}
spec:
  {{- if .Values.service.headless }}
  type: ClusterIP
  clusterIP: None
  {{- else }}
  type: {{ .Values.service.type }}
  {{- end }}
  ports:
  - name: mssql
    port: {{ .Values.service.port }}
    targetPort: mssql
    protocol: TCP
  selector:
    app: {{ template "mssql.name" . }}
    release: {{ .Release.Name }}
