blob: 20b347fd1db6390749735deabc58a496f2aa00e7 [file] [log] [blame]
gio07eb1082024-10-25 14:35:56 +04001{{- /*
2Copyright Broadcom, Inc. All Rights Reserved.
3SPDX-License-Identifier: APACHE-2.0
4*/}}
5
6{{- if and (eq .Values.architecture "replicaset") .Values.externalAccess.enabled (eq .Values.externalAccess.service.type "ClusterIP") }}
7
8{{- $fullName := include "mongodb.fullname" . }}
9{{- $replicaCount := .Values.replicaCount | int }}
10{{- $root := . }}
11
12{{- range $i, $e := until $replicaCount }}
13{{- $targetPod := printf "%s-%d" (printf "%s" $fullName) $i }}
14{{- $_ := set $ "targetPod" $targetPod }}
15apiVersion: v1
16kind: Service
17metadata:
18 name: {{ printf "%s-%d" $fullName $i }}
19 namespace: {{ include "mongodb.namespace" $ }}
20 labels: {{- include "common.labels.standard" ( dict "customLabels" $root.Values.commonLabels "context" $ ) | nindent 4 }}
21 app.kubernetes.io/component: mongodb
22 {{- if or $root.Values.service.annotations $root.Values.commonAnnotations }}
23 {{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list $root.Values.service.annotations $root.Values.commonAnnotations ) "context" $ ) }}
24 annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
25 {{- end }}
26spec:
27 type: ClusterIP
28 ports:
29 - name: {{ $root.Values.service.portName | quote }}
30 port: {{ $root.Values.service.ports.mongodb }}
31 targetPort: mongodb
32 {{- if $root.Values.service.extraPorts }}
33 {{- include "common.tplvalues.render" (dict "value" $root.Values.service.extraPorts "context" $) | nindent 4 }}
34 {{- end }}
35 {{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list $root.Values.podLabels $root.Values.commonLabels ) "context" $ ) }}
36 selector: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 4 }}
37 app.kubernetes.io/component: mongodb
38 statefulset.kubernetes.io/pod-name: {{ $targetPod }}
39---
40{{- end }}
41{{- end }}