Skip to content

Commit 8885cf8

Browse files
authored
Support broker per-pod service and advertisedListeners (#1263)
## Summary Add `networking.podService` and `advertisedListeners` configuration to PulsarBroker CR for Istio Federation/Multi-cluster scenarios. - Add `networking.podService` config (enabled, type, annotations, labels, ports) - Add `advertisedListeners` config for custom broker advertisement - Update both sn-platform and sn-platform-slim charts ## Test Values Use the following values file to test the feature: ```yaml # Test Broker Pod Service functionality # Simulates Istio Federation scenario broker: pulsarBroker: networking: podService: enabled: true type: ClusterIP annotations: sidecar.istio.io/inject: "true" test.streamnative.io/feature: "broker-pod-service" labels: app.kubernetes.io/managed-by: "pulsar-operator" test.streamnative.io/scenario: "istio-federation" # Use non-default port (6660) to avoid conflict with brokerServicePort (6650) advertisedListeners: - name: pod hostTemplate: "$(POD_NAME).test-namespace.svc.cluster.local" protocols: pulsar: advertisedPort: 6660 containerPort: 6660 ``` ## Verification 1. Deploy with the test values: ```bash helm install test-pulsar ./sn-platform-slim -n test-namespace -f test-values.yaml ``` 2. Verify PulsarBroker CR contains correct config: ```bash kubectl get pulsarbroker -n test-namespace -o yaml | grep -A 20 "networking:" ``` 3. Verify per-pod Services are created: ```bash kubectl get svc -n test-namespace | grep broker ``` 4. Expected per-pod Services: - `{cluster}-broker-0` with correct annotations/labels - `{cluster}-broker-1` with correct annotations/labels - Services should include port 6660 ## Test plan - [x] `helm template` renders correct YAML - [x] Per-pod Services created with correct selector (`statefulset.kubernetes.io/pod-name`) - [x] Custom annotations and labels applied to Services - [x] Broker starts on configured listener port (6660) - [x] Both sn-platform and sn-platform-slim charts work correctly
1 parent 03835b8 commit 8885cf8

4 files changed

Lines changed: 136 additions & 0 deletions

File tree

charts/sn-platform-slim/templates/broker/broker-cluster.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,32 @@ spec:
190190
mode: "passthrough"
191191
{{- end }}
192192
{{- end }}
193+
{{- if and .Values.broker.pulsarBroker.networking .Values.broker.pulsarBroker.networking.podService .Values.broker.pulsarBroker.networking.podService.enabled }}
194+
networking:
195+
{{- with .Values.broker.pulsarBroker.networking.podService }}
196+
podService:
197+
enabled: {{ .enabled }}
198+
{{- if .type }}
199+
type: {{ .type }}
200+
{{- end }}
201+
{{- with .annotations }}
202+
annotations:
203+
{{- toYaml . | nindent 8 }}
204+
{{- end }}
205+
{{- with .labels }}
206+
labels:
207+
{{- toYaml . | nindent 8 }}
208+
{{- end }}
209+
{{- with .ports }}
210+
ports:
211+
{{- toYaml . | nindent 8 }}
212+
{{- end }}
213+
{{- end }}
214+
{{- end }}
215+
{{- with .Values.broker.pulsarBroker.advertisedListeners }}
216+
advertisedListeners:
217+
{{- toYaml . | nindent 4 }}
218+
{{- end }}
193219
{{- if .Values.broker.dnsNames }}
194220
dnsNames:
195221
{{ toYaml .Values.broker.dnsNames | indent 2}}

charts/sn-platform-slim/values.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,48 @@ broker:
11431143
labels: {}
11441144
# annotations that will be added on the PulsarBroker CR only.
11451145
annotations: {}
1146+
# networking configures per-pod Service creation for broker pods
1147+
# When enabled, creates a dedicated Service for each broker pod
1148+
# Essential for Istio Federation/Multi-cluster scenarios
1149+
networking:
1150+
podService:
1151+
# enabled controls whether per-pod Services are created
1152+
enabled: false
1153+
# type specifies the Service type: ClusterIP, LoadBalancer, or NodePort
1154+
type: ClusterIP
1155+
# annotations to add to each pod Service
1156+
annotations: {}
1157+
# labels to add to each pod Service
1158+
labels: {}
1159+
# ports to expose on each pod Service
1160+
# If not specified, uses default broker ports (6650, 8080, etc.)
1161+
# Example:
1162+
# ports:
1163+
# - name: pulsar
1164+
# port: 6650
1165+
# targetPort: 6650
1166+
# - name: http
1167+
# port: 8080
1168+
# targetPort: 8080
1169+
ports: []
1170+
# advertisedListeners defines how brokers are advertised to clients
1171+
# Used with networking.podService for Istio Federation/Multi-cluster scenarios
1172+
#
1173+
# Available hostTemplate variables (interpolated by Kubernetes at runtime):
1174+
# - $(POD_NAME): Full pod name, e.g., "pulsar-broker-0"
1175+
# - $(POD_ID): Pod ordinal from StatefulSet, e.g., "0", "1", "2"
1176+
#
1177+
# IMPORTANT: Use a non-default port (e.g., 6660) to avoid conflict with brokerServicePort (6650)
1178+
#
1179+
# Example for Istio Federation:
1180+
# advertisedListeners:
1181+
# - name: pod
1182+
# hostTemplate: "$(POD_NAME).my-namespace.svc.cluster.local"
1183+
# protocols:
1184+
# pulsar:
1185+
# advertisedPort: 6660
1186+
# containerPort: 6660
1187+
advertisedListeners: []
11461188

11471189
# The field autoScaling will track the average metrics usage of the Pulsar nodes and adjusts the nodes to keep at the target metrics usage level.
11481190
# If the average metrics usage for nodes is over the target, scaling controller will scale out to bring more nodes and if the average metrics for the nodes is less than the target, scaling controller will downscale nodes to save resources.

charts/sn-platform/templates/broker/broker-cluster.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,32 @@ spec:
191191
mode: "passthrough"
192192
{{- end }}
193193
{{- end }}
194+
{{- if and .Values.broker.pulsarBroker.networking .Values.broker.pulsarBroker.networking.podService .Values.broker.pulsarBroker.networking.podService.enabled }}
195+
networking:
196+
{{- with .Values.broker.pulsarBroker.networking.podService }}
197+
podService:
198+
enabled: {{ .enabled }}
199+
{{- if .type }}
200+
type: {{ .type }}
201+
{{- end }}
202+
{{- with .annotations }}
203+
annotations:
204+
{{- toYaml . | nindent 8 }}
205+
{{- end }}
206+
{{- with .labels }}
207+
labels:
208+
{{- toYaml . | nindent 8 }}
209+
{{- end }}
210+
{{- with .ports }}
211+
ports:
212+
{{- toYaml . | nindent 8 }}
213+
{{- end }}
214+
{{- end }}
215+
{{- end }}
216+
{{- with .Values.broker.pulsarBroker.advertisedListeners }}
217+
advertisedListeners:
218+
{{- toYaml . | nindent 4 }}
219+
{{- end }}
194220
{{- if .Values.broker.dnsNames }}
195221
dnsNames:
196222
{{ toYaml .Values.broker.dnsNames | indent 2}}

charts/sn-platform/values.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,48 @@ broker:
12181218
labels: {}
12191219
# annotations that will be added on the PulsarBroker CR only.
12201220
annotations: {}
1221+
# networking configures per-pod Service creation for broker pods
1222+
# When enabled, creates a dedicated Service for each broker pod
1223+
# Essential for Istio Federation/Multi-cluster scenarios
1224+
networking:
1225+
podService:
1226+
# enabled controls whether per-pod Services are created
1227+
enabled: false
1228+
# type specifies the Service type: ClusterIP, LoadBalancer, or NodePort
1229+
type: ClusterIP
1230+
# annotations to add to each pod Service
1231+
annotations: {}
1232+
# labels to add to each pod Service
1233+
labels: {}
1234+
# ports to expose on each pod Service
1235+
# If not specified, uses default broker ports (6650, 8080, etc.)
1236+
# Example:
1237+
# ports:
1238+
# - name: pulsar
1239+
# port: 6650
1240+
# targetPort: 6650
1241+
# - name: http
1242+
# port: 8080
1243+
# targetPort: 8080
1244+
ports: []
1245+
# advertisedListeners defines how brokers are advertised to clients
1246+
# Used with networking.podService for Istio Federation/Multi-cluster scenarios
1247+
#
1248+
# Available hostTemplate variables (interpolated by Kubernetes at runtime):
1249+
# - $(POD_NAME): Full pod name, e.g., "pulsar-broker-0"
1250+
# - $(POD_ID): Pod ordinal from StatefulSet, e.g., "0", "1", "2"
1251+
#
1252+
# IMPORTANT: Use a non-default port (e.g., 6660) to avoid conflict with brokerServicePort (6650)
1253+
#
1254+
# Example for Istio Federation:
1255+
# advertisedListeners:
1256+
# - name: pod
1257+
# hostTemplate: "$(POD_NAME).my-namespace.svc.cluster.local"
1258+
# protocols:
1259+
# pulsar:
1260+
# advertisedPort: 6660
1261+
# containerPort: 6660
1262+
advertisedListeners: []
12211263

12221264
# The field autoScaling will track the average metrics usage of the Pulsar nodes and adjusts the nodes to keep at the target metrics usage level.
12231265
# If the average metrics usage for nodes is over the target, scaling controller will scale out to bring more nodes and if the average metrics for the nodes is less than the target, scaling controller will downscale nodes to save resources.

0 commit comments

Comments
 (0)