---
apiVersion: v1
kind: Service
metadata:
  name: rvps
  labels:
    {{- include "coco-kbs.labels" . | nindent 4 }}
spec:
  type: ClusterIP
  ports:
    - port: {{ .Values.rvps.service.port }}
      targetPort: tcp
      protocol: TCP
      name: tcp
  selector:
    app: reference-value-provider-service
    {{- include "coco-kbs.selectorLabels" . | nindent 4 }}

{{- if eq .Values.rvps.service.type "LoadBalancer" }}
---
apiVersion: v1
kind: Service
metadata:
  name: rvps-slb-intranet
  labels:
    {{- include "coco-kbs.labels" . | nindent 4 }}
  {{- if eq .Values.rvps.service.type "LoadBalancer" }}
    {{- if eq .Values.rvps.service.loadBalancerType "intranet" }}
  annotations:
    service.beta.kubernetes.io/alibaba-cloud-loadbalancer-address-type: "intranet"
    {{- end }}
  {{- end }}
spec:
  type: {{ .Values.rvps.service.type }}
  ports:
    - port: {{ .Values.rvps.service.port }}
      targetPort: tcp
      protocol: TCP
      name: tcp
  selector:
    app: reference-value-provider-service
    {{- include "coco-kbs.selectorLabels" . | nindent 4 }}
{{- end }}

{{- if eq .Values.rvps.service.type "LoadBalancer" }}
  {{- if eq .Values.rvps.service.loadBalancerType "public" }}
---
apiVersion: v1
kind: Service
metadata:
  name: rvps-slb-public
  labels:
    {{- include "coco-kbs.labels" . | nindent 4 }}
spec:
  type: {{ .Values.rvps.service.type }}
  ports:
    - port: {{ .Values.rvps.service.port }}
      targetPort: tcp
      protocol: TCP
      name: tcp
  selector:
    app: reference-value-provider-service
    {{- include "coco-kbs.selectorLabels" . | nindent 4 }}
  {{- end }}
{{- end }}
