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

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

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