{{- if or (eq (include "opentelemetry-collector.serviceEnabled" .) "true") (.Values.ingress.enabled) -}} apiVersion: v1 kind: Service metadata: name: {{ include "opentelemetry-collector.fullname" . }} namespace: {{ template "opentelemetry-collector.namespace" . }} labels: {{- include "opentelemetry-collector.labels" . | nindent 4 }} {{- include "opentelemetry-collector.component" . | nindent 4 }} {{- if .Values.service.annotations }} annotations: {{- range $key, $value := .Values.service.annotations }} {{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }} {{- end }} {{- end }} spec: type: {{ .Values.service.type }} {{- if .Values.service.clusterIP }} clusterIP: {{ .Values.service.clusterIP }} {{- end }} {{- if and .Values.service.loadBalancerIP (eq .Values.service.type "LoadBalancer") }} loadBalancerIP: {{ .Values.service.loadBalancerIP }} {{- end }} {{- if and .Values.service.loadBalancerSourceRanges (eq .Values.service.type "LoadBalancer") }} loadBalancerSourceRanges: {{- range .Values.service.loadBalancerSourceRanges }} - {{ . }} {{- end }} {{- end }} {{- $ports := include "opentelemetry-collector.servicePortsConfig" . }} {{- if $ports }} ports: {{- $ports | nindent 4}} {{- end }} selector: {{- include "opentelemetry-collector.selectorLabels" . | nindent 4 }} {{- include "opentelemetry-collector.component" . | nindent 4 }} internalTrafficPolicy: {{ include "opentelemetry-collector.serviceInternalTrafficPolicy" . }} {{- if and (eq .Values.service.type "LoadBalancer") (.Values.service.externalTrafficPolicy) }} externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy }} {{- end }} {{- end }}