{{ if .Values.deployment.enabled }}
apiVersion: v1
kind: Service
metadata:
  name: {{ template "datadog.fullname" . }}
  labels:
    app: "{{ template "datadog.fullname" . }}"
    chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
    release: {{ .Release.Name | quote }}
    heritage: {{ .Release.Service | quote }}
  {{- if .Values.service.annotations }}
  annotations:
  {{ toYaml .Values.service.annotations | indent 4 }}
  {{- end }}
spec:
  type: {{ .Values.serviceType }}
  selector:
    app: {{ template "datadog.fullname" . }}
    type: deployment
  ports:
  - port: 8125
    name: dogstatsdport
    protocol: UDP
  {{- if .Values.deployment.dogstatsdNodePort }}
    nodePort: {{ .Values.deployment.dogstatsdNodePort }}
  {{- end }}
  {{- if .Values.datadog.apmEnabled }}
  - port: 8126
    name: traceport
    protocol: TCP
  {{- if .Values.deployment.traceNodePort }}
    nodePort: {{ .Values.deployment.traceNodePort }}
  {{- end }}
  {{- end }}
{{ end }}
