common-helm-lib/templates/_service.tpl
Jonas Forsberg 869a756e4b first commit
2024-10-15 16:19:57 +02:00

29 lines
742 B
Smarty

{{- define "lib.service" -}}
{{- $servicename := include "lib.fullname" . }}
{{- $labels := include "lib.labels" . }}
{{- $selectorlabels := include "lib.selectorLabels" . }}
{{- $ns := .Values.namespace }}
{{- range $name, $values := .Values.service }}
{{- if $values.enabled }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ $servicename }}-{{ $name }}
namespace: {{ $ns }}
labels:
{{- $labels | nindent 4 }}
spec:
type: {{ $values.type }}
ports:
{{- range $k, $v := $values.ports }}
- port: {{ $v.port }}
targetPort: {{ default $v.targetPort $v.port }}
protocol: {{ $v.protocol }}
name: {{ $k }}
{{- end }}
selector:
{{- $selectorlabels | nindent 4 }}
{{- end -}}
{{- end -}}
{{- end -}}