apiVersion: v1
kind: Service
metadata:
  name: {{ include "keydb.fullname" . }}
  labels:
    {{- include "keydb.labels" . | nindent 4 }}
  annotations:
    {{- toYaml .Values.service.annotations | nindent 4 }}
spec:
  type: ClusterIP
  ports:
  - name: {{ .Values.portName | quote }}
    port: {{ .Values.port | int }}
    protocol: TCP
    targetPort: {{ .Values.internalPortName | quote }}
    {{- if .Values.service.appProtocol.enabled }}
    appProtocol: redis
    {{- end }}
  - name: {{ .Values.exporter.portName | quote }}
    port: {{ .Values.exporter.port | int }}
    protocol: TCP
    targetPort: {{ .Values.exporter.portName | quote }}
    {{- if .Values.service.appProtocol.enabled }}
    appProtocol: http
    {{- end }}
  selector:
    {{- include "keydb.selectorLabels" . | nindent 4 }}
  sessionAffinity: ClientIP
