apiVersion: v1
kind: Service
metadata:
  name: {{ template "fullname" . }}
  labels:
    app: {{ .Chart.Name }}
    release: {{ .Release.Name | quote }}
    heritage: {{ .Release.Service }}
{{- with .Values.service.annotations }}
  annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
  type: {{ .Values.service.type }}
  ports:
    - port: {{ .Values.service.port }}
{{- if .Values.service.nodePort }}
      nodePort: {{ .Values.service.nodePort }}
{{- end }}
      protocol: TCP
      name: http
      targetPort: {{ .Values.httpPort }}
  selector:
    app: {{ .Chart.Name }}
    release: {{ .Release.Name | quote }}
{{- if .Values.enableProxy }}
---
apiVersion: v1
kind: Service
metadata:
  name: kibana-http
  namespace: {{ .Release.Namespace }}
  labels:
    app: {{ .Chart.Name }}
    release: {{ .Release.Name | quote }}
    heritage: {{ .Release.Service }}
    kubernetes.io/cluster-service: "true"
spec:
  type: ClusterIP
  ports:
    - name: http-access-kibana
      protocol: TCP
      port: 80
  selector:
    app: {{ .Chart.Name }}
    release: {{ .Release.Name | quote }}
{{- end }}
