apiVersion: v1
kind: Service
metadata:
  name: {{ template "lamp.fullname" . }}
  labels:
    app: {{ template "lamp.name" . }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
spec:
  {{- if .Values.ingress.enabled }}
  type: ClusterIP
  {{- else }}
  type: {{ .Values.service.type }}
  {{- end }}
  ports:
  - port: {{ .Values.service.HTTPPort }}
    targetPort: 80
    protocol: TCP
    name: httpd
  {{ if .Values.mysql.rootPassword }}
  - port: 3306
    targetPort: 3306
    protocol: TCP
    name: mysql
  {{ end }}
  {{ if and .Values.sftp.enabled (not .Values.ingress.enabled) }}
  - port: {{ .Values.sftp.port }}
    targetPort: 22
    protocol: TCP
    name: sftp
  {{ end }}
  {{ if .Values.webdav.enabled }}
  - port: {{ .Values.webdav.port }}
    targetPort: 8001
    protocol: TCP
    name: webdav
  {{ end }}
  {{ if .Values.phpmyadmin.enabled }}
  - port: {{ .Values.phpmyadmin.port }}
    targetPort: 8080
    protocol: TCP
    name: phpmyadmin
  {{ end }}
  selector:
    app: {{ template "lamp.name" . }}
    release: {{ .Release.Name }}
