Merge "[AAI] Add model-loader tracing config"
[oom.git] / kubernetes / common / mongodb / templates / replicaset / svc.yaml
1 {{- /*
2 Copyright VMware, Inc.
3 SPDX-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 }}
15 apiVersion: v1
16 kind: Service
17 metadata:
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 }}
26 spec:
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 }}