common-helm-lib/templates/_service.tpl

30 lines
778 B
Smarty
Raw 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 }}
protocol: {{ default "HTTP" $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 -}}