---
apiVersion: v1
kind: Service
metadata:
  name: {{ .Chart.Name }}-{{ .Values.search.serviceName }}
  labels:
    run: {{ .Chart.Name }}-{{ .Values.search.serviceName }}
  annotations:
  {{- if (eq .Values.provider "aws") }}
    external-dns.alpha.kubernetes.io/hostname: {{ .Chart.Name }}-{{ .Values.search.serviceName }}-{{ .Values.environment }}.{{ .Values.dnsZone }}
    service.beta.kubernetes.io/aws-load-balancer-internal: 0.0.0.0/0
    service.beta.kubernetes.io/aws-load-balancer-type: nlb 
  {{- end }}          
spec:
  type: LoadBalancer
  externalTrafficPolicy: Local
  ports:
    - port: 5001
      name: {{ .Chart.Name }}-{{ .Values.search.serviceName }}-{{ .Values.environment }}-http
      targetPort: 5001
  selector:
    run: {{ .Chart.Name }}-{{ .Values.search.serviceName }}
---  
apiVersion: v1
kind: Service
metadata:
  name: {{ .Chart.Name }}-{{ .Values.metadata.serviceName }}
  labels:
    run: {{ .Chart.Name }}-{{ .Values.metadata.serviceName }}
  annotations:
  {{- if (eq .Values.provider "aws") }}
    external-dns.alpha.kubernetes.io/hostname: {{ .Chart.Name }}-{{ .Values.metadata.serviceName }}-{{ .Values.environment }}.{{ .Values.dnsZone }}
    service.beta.kubernetes.io/aws-load-balancer-internal: 0.0.0.0/0
    service.beta.kubernetes.io/aws-load-balancer-type: nlb 
  {{- end }}              
spec:
  type: LoadBalancer
  externalTrafficPolicy: Local
  ports:
    - port: 5002
      name: {{ .Chart.Name }}-{{ .Values.metadata.serviceName }}-{{ .Values.environment }}-http
      targetPort: 5002
  selector:
    run: {{ .Chart.Name }}-{{ .Values.metadata.serviceName }}
---         
apiVersion: v1
kind: Service
metadata:
  name: {{ .Chart.Name }}-{{ .Values.frontEnd.serviceName }}
  labels:
    run: {{ .Chart.Name }}-{{ .Values.frontEnd.serviceName }}
  annotations:
  {{- if (eq .Values.provider "aws") }}
    external-dns.alpha.kubernetes.io/hostname: {{ .Chart.Name }}-{{ .Values.frontEnd.serviceName }}-{{ .Values.environment }}.{{ .Values.dnsZone }}
    service.beta.kubernetes.io/aws-load-balancer-internal: 0.0.0.0/0
    service.beta.kubernetes.io/aws-load-balancer-type: nlb 
  {{- end }}       
spec:
  type: LoadBalancer
  externalTrafficPolicy: Local
  ports:
    - port: {{ .Values.frontEnd.servicePort }}
      name: {{ .Chart.Name }}-{{ .Values.frontEnd.serviceName }}-{{ .Values.environment }}-http
      targetPort: 5000
  selector:
    run: {{ .Chart.Name }}-{{ .Values.frontEnd.serviceName }}
---            