Andreas Geissler | cde4a78 | 2024-02-28 16:08:06 +0100 | [diff] [blame] | 1 | {{- /* |
| 2 | Copyright VMware, Inc. |
| 3 | SPDX-License-Identifier: APACHE-2.0 |
| 4 | */}} |
| 5 | |
| 6 | {{- if not (eq .Values.architecture "replicaset") }} |
| 7 | apiVersion: v1 |
| 8 | kind: Service |
| 9 | metadata: |
| 10 | name: {{ include "mongodb.service.nameOverride" . }} |
| 11 | namespace: {{ include "mongodb.namespace" . | quote }} |
| 12 | labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }} |
| 13 | app.kubernetes.io/component: mongodb |
| 14 | {{- if or .Values.service.annotations .Values.commonAnnotations }} |
| 15 | {{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.service.annotations .Values.commonAnnotations ) "context" . ) }} |
| 16 | annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }} |
| 17 | {{- end }} |
| 18 | spec: |
| 19 | type: {{ .Values.service.type }} |
| 20 | {{- if and (eq .Values.service.type "ClusterIP") .Values.service.clusterIP }} |
| 21 | clusterIP: {{ .Values.service.clusterIP }} |
| 22 | {{- end }} |
| 23 | {{- if and (eq .Values.service.type "LoadBalancer") .Values.service.loadBalancerIP }} |
| 24 | loadBalancerIP: {{ .Values.service.loadBalancerIP }} |
| 25 | {{- end }} |
| 26 | {{- if and (eq .Values.service.type "LoadBalancer") .Values.service.loadBalancerClass }} |
| 27 | loadBalancerClass: {{ .Values.service.loadBalancerClass }} |
| 28 | {{- end }} |
| 29 | {{- if .Values.service.externalIPs }} |
| 30 | externalIPs: {{ toYaml .Values.service.externalIPs | nindent 4 }} |
| 31 | {{- end }} |
| 32 | {{- if .Values.service.loadBalancerSourceRanges }} |
| 33 | loadBalancerSourceRanges: {{- toYaml .Values.service.loadBalancerSourceRanges | nindent 4 }} |
| 34 | {{- end }} |
| 35 | {{- if (eq .Values.service.type "LoadBalancer") }} |
| 36 | allocateLoadBalancerNodePorts: {{ .Values.service.allocateLoadBalancerNodePorts }} |
| 37 | {{- end }} |
| 38 | {{- if .Values.service.sessionAffinity }} |
| 39 | sessionAffinity: {{ .Values.service.sessionAffinity }} |
| 40 | {{- end }} |
| 41 | {{- if .Values.service.sessionAffinityConfig }} |
| 42 | sessionAffinityConfig: {{- include "common.tplvalues.render" (dict "value" .Values.service.sessionAffinityConfig "context" $) | nindent 4 }} |
| 43 | {{- end }} |
| 44 | {{- if (or (eq .Values.service.type "LoadBalancer") (eq .Values.service.type "NodePort")) }} |
| 45 | externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy | quote }} |
| 46 | {{- end }} |
| 47 | ports: |
| 48 | - name: {{ .Values.service.portName | quote }} |
| 49 | port: {{ .Values.service.ports.mongodb }} |
| 50 | targetPort: mongodb |
| 51 | {{- if and (or (eq .Values.service.type "LoadBalancer") (eq .Values.service.type "NodePort")) .Values.service.nodePorts.mongodb }} |
| 52 | nodePort: {{ .Values.service.nodePorts.mongodb }} |
| 53 | {{- else if eq .Values.service.type "ClusterIP" }} |
| 54 | nodePort: null |
| 55 | {{- end }} |
| 56 | {{- if .Values.service.extraPorts }} |
| 57 | {{- include "common.tplvalues.render" (dict "value" .Values.service.extraPorts "context" $) | nindent 4 }} |
| 58 | {{- end }} |
| 59 | {{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.podLabels .Values.commonLabels ) "context" . ) }} |
| 60 | selector: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 4 }} |
| 61 | app.kubernetes.io/component: mongodb |
| 62 | {{- end }} |