apiVersion: v1
kind: Service
metadata:
  name: {{ .Release.Name }}
  labels:
    app.kubernetes.io/component: {{ .Release.Name }}-web
spec:
  type: {{ .Values.app.service.type }}
  {{- if and .Values.app.service.clusterIP (eq .Values.app.service.type "ClusterIP") }}
  clusterIP: {{ .Values.app.service.clusterIP }}
  {{- end }}
  {{- if and (eq .Values.app.service.type "LoadBalancer") (not (empty .Values.app.service.loadBalancerIP)) }}
  loadBalancerIP: {{ .Values.app.service.loadBalancerIP }}
  {{- end }}
  ports:
    - name: http-web-svc
      port: {{ .Values.app.service.port }}
      protocol: TCP
      targetPort: http-web-svc
      {{- if (and (or (eq .Values.app.service.type "NodePort") (eq .Values.app.service.type "LoadBalancer")) .Values.app.service.nodePort) }}
      nodePort: {{ .Values.app.service.nodePort }}
      {{- end }}
  selector:
    app.kubernetes.io/name: {{ .Release.Name }}-web
