apiVersion: v1
kind: Service
metadata:
  name: {{ template "drone.fullname" . }}
  annotations:
  {{- range $key, $value := .Values.service.annotations }}
    {{ $key }}: {{ $value | quote }}
  {{- end }}
  labels:
    app: {{ template "drone.name" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
spec:
  type: {{ .Values.service.type }}
  {{- if and (hasKey .Values.service "loadBalancerIP") (eq .Values.service.type "LoadBalancer") }}
  loadBalancerIP: {{ .Values.service.loadBalancerIP }}
  {{- end }}
  ports:
  - name: http
    port: {{ .Values.service.httpPort }}
    targetPort: 80
{{- if hasKey .Values.service "nodePort" }}
    nodePort: {{ .Values.service.nodePort }}
{{- end }}
{{- if .Values.service.exposeGRPC }}
  - name: grpc
    port: 9000
    targetPort: 9000
{{- end }}
  selector:
    app: {{ template "drone.name" . }}
    release: {{ .Release.Name | quote }}
    component: server
