common-helm-lib/templates/_service.tpl

30 lines
777 B
Smarty
Raw Permalink Normal View History

2024-10-15 14:19:57 +00:00
{{- 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:
2024-10-19 09:00:59 +00:00
type: {{ default "ClusterIP" $values.type }}
2024-10-15 14:19:57 +00:00
ports:
{{- range $k, $v := $values.ports }}
- port: {{ $v.port }}
2024-10-19 09:00:59 +00:00
targetPort: {{ default $v.port $v.targetPort }}
2024-10-19 09:23:43 +00:00
protocol: {{ default "TCP" $v.protocol }}
2024-10-15 14:19:57 +00:00
name: {{ $k }}
{{- end }}
selector:
{{- $selectorlabels | nindent 4 }}
{{- end -}}
{{- end -}}
2024-10-19 09:00:59 +00:00
{{- end -}}