common-helm-lib/templates/_service.tpl
Jonas Forsberg 4f2a9ba9b7 .
2024-10-19 11:23:43 +02:00

30 lines
777 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: {{ default "ClusterIP" $values.type }}
ports:
{{- range $k, $v := $values.ports }}
- port: {{ $v.port }}
targetPort: {{ default $v.port $v.targetPort }}
protocol: {{ default "TCP" $v.protocol }}
name: {{ $k }}
{{- end }}
selector:
{{- $selectorlabels | nindent 4 }}
{{- end -}}
{{- end -}}
{{- end -}}