Files
charts/bitnami/postgresql/templates/svc-read-set.yaml
deef 3d76ba751a [bitnami/postgresql] Add option to create services for each read replica (#6990)
* [bitnami/postgresql] Add option to create services for each read replica

Adds option to disable the service that connects to all read replicas.
Read-Replica unique services do not have options for LoadBalancers, Node Ports, or Setting ClusterIP.
Fixes bitnami/charts#6954

* [bitnami/postgresql] Update values.yaml comments

Added proper comments so that replication.singleService and replication.uniqueServices are bitnami-labs/readme-generator-for-helm compatible

* [bitnami/postgresql] remove unused varaibles

* [bitnami/postgresql] delete test file

* [bitnami/postgresql] bump chart version

Co-authored-by: Javier J. Salmerón-García <jsalmeron@bitnami.com>
2021-07-21 09:37:38 +02:00

39 lines
1.3 KiB
YAML

{{- if and .Values.replication.enabled .Values.replication.uniqueServices }}
{{- $serviceAnnotations := coalesce .Values.readReplicas.service.annotations .Values.service.annotations -}}
{{- $fullName := include "common.names.fullname" . }}
{{- $replicaCount := .Values.replication.readReplicas | int }}
{{- $root := . }}
{{- range $i, $e := until $replicaCount }}
{{- $targetPod := printf "%s-read-%d" (printf "%s" $fullName) $i }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ $fullName }}-read-{{ $i }}
labels:
pod: {{ $targetPod }}
{{- include "common.labels.standard" $root | nindent 4 }}
annotations:
{{- if $root.Values.commonAnnotations }}
{{- include "common.tplvalues.render" ( dict "value" $root.Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
{{- if $serviceAnnotations }}
{{- include "common.tplvalues.render" (dict "value" $serviceAnnotations "context" $) | nindent 4 }}
{{- end }}
namespace: {{ $root.Release.Namespace }}
spec:
type: ClusterIP
ports:
- name: tcp-postgresql
port: {{ template "postgresql.port" $root }}
targetPort: tcp-postgresql
selector:
{{- include "common.labels.matchLabels" $root | nindent 4 }}
role: read
statefulset.kubernetes.io/pod-name: {{ $targetPod }}
{{- end }}
{{- end }}