{{- if .Values.compactor.enabled -}}
apiVersion: v1
kind: Service
metadata:
  name: {{ include "thanos.fullname" . }}-compactor
  labels: {{- include "thanos.labels" . | nindent 4 }}
    app.kubernetes.io/component: compactor
  {{- if .Values.compactor.service.annotations }}
  annotations: {{- include "thanos.tplValue" (dict "value" .Values.compactor.service.annotations "context" $) | nindent 4 }}
  {{- end }}
spec:
  type: {{ .Values.compactor.service.type }}
  {{- if and .Values.compactor.service.clusterIP (eq .Values.compactor.service.type "ClusterIP") }}
  clusterIP: {{ .Values.compactor.service.clusterIP }}
  {{- end }}
  {{- if and .Values.compactor.service.loadBalancerIP (eq .Values.compactor.service.type "LoadBalancer") }}
  loadBalancerIP: {{ .Values.compactor.service.loadBalancerIP }}
  {{- end }}
  {{- if and (eq .Values.compactor.service.type "LoadBalancer") .Values.compactor.service.loadBalancerSourceRanges }}
  loadBalancerSourceRanges: {{- toYaml .Values.compactor.service.loadBalancerSourceRanges | nindent 4 }}
  {{- end }}
  ports:
    - port: {{ .Values.compactor.service.http.port }}
      targetPort: http
      protocol: TCP
      name: http
      {{- if (and (or (eq .Values.compactor.service.type "NodePort") (eq .Values.compactor.service.type "LoadBalancer")) .Values.compactor.service.http.nodePort) }}
      {{- else if eq .Values.compactor.service.type "ClusterIP" }}
      nodePort: null
      {{- end }}
  selector: {{- include "thanos.matchLabels" . | nindent 4 }}
    app.kubernetes.io/component: compactor
{{- end }}
