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

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

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