apiVersion: v1
kind: Service
metadata:
  name: {{ template "locust.master-svc" . }}
  labels:
    heritage: {{ .Release.Service | quote }}
    release: {{ .Release.Name | quote }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    app: {{ template "locust.fullname" . }}
    component: "master"
    {{- range $key, $value :=  .Values.service.extraLabels }}
    {{ $key }}: {{ $value | quote }}
    {{- end }}
  {{- if .Values.service.annotations }}
  annotations:
  {{- range $key, $value :=  .Values.service.annotations }}
    {{ $key }}: {{ $value | quote }}
  {{- end }}
  {{- end }}
spec:
  type: {{ .Values.service.type }}
  ports:
  - name: {{ .Values.service.name }}
    port: {{ .Values.service.externalPort }}
    targetPort: {{ .Values.service.internalPort }}
    nodePort: {{ .Values.service.nodePort }}
    protocol: TCP
  - name: master-p1
    port: 5557
    protocol: TCP
    targetPort: 5557
  - name: master-p2
    port: 5558
    protocol: TCP
    targetPort: 5558
  selector:
    app: {{ template "locust.fullname" . }}
    component: "master"
  sessionAffinity: None
