[DMAAP] DMaaP ServiceMesh compatibility
[oom.git] / kubernetes / common / common / templates / _kafkaNodes.tpl
1 {{/*
2 # Copyright © 2021 Bell Canada
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 */}}
16 {{/*
17   Generate comma separated list of kafka or zookeper nodes to reuse in message router charts.
18   How to use:
19
20   zookeeper servers list: {{ include "common.kafkaNodes" (dict "dot" . "replicaCount" (index .Values "message-router-zookeeper" "replicaCount") "componentName" .Values.zookeeper.name "port" .Values.zookeeper.port ) }}
21   kafka servers list: {{ include "common.kafkaNodes" (dict "dot" . "replicaCount" (index .Values "message-router-kafka" "replicaCount") "componentName" .Values.kafka.name "port" .Values.kafka.port ) }}
22
23 */}}
24 {{- define "common.kafkaNodes" -}}
25 {{- $dot := .dot -}}
26 {{- $replicaCount := .replicaCount -}}
27 {{- $componentName := .componentName -}}
28 {{- $port := .port -}}
29 {{- $kafkaNodes := list -}}
30 {{- range $i, $e := until (int $replicaCount) -}}
31 {{- $kafkaNodes = print (include "common.release" $dot) "-" $componentName "-" $i "." $componentName "." (include "common.namespace" $dot) ".svc.cluster.local:" $port | append $kafkaNodes -}}
32 {{- end -}}
33 {{- $kafkaNodes | join "," -}}
34 {{- end -}}