GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add separate headless service for brokers with publishNotReadyAddress… · apache/pulsar-helm-chart@85c7235

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .ci
    • helm.sh
  • README.md
  • charts/pulsar
    • templates
      • _broker.tpl
      • _certs.tpl
      • broker-headless-service.yaml
      • broker-service.yaml
      • broker-statefulset-upgrade.yaml
      • broker-statefulset.yaml
      • zookeeper-statefulset-upgrade.yaml
    • values.yaml
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.ci/helm.sh‎

Copy file name to clipboardExpand all lines: .ci/helm.sh
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ PULSAR_CHART_VERSION=${PULSAR_CHART_VERSION:-"local"}
2525
OUTPUT_BIN=${CHARTS_HOME}/output/bin
2626
KIND_BIN=$OUTPUT_BIN/kind
2727
HELM=${OUTPUT_BIN}/helm
28-
KUBECTL=${OUTPUT_BIN}/kubectl
29-
NAMESPACE=pulsar
28+
: ${KUBECTL:=$OUTPUT_BIN/kubectl}
29+
: ${NAMESPACE:=pulsar}
3030
CLUSTER=pulsar-ci
3131
: ${CLUSTER_ID:=$(uuidgen)}
3232
K8S_LOGS_DIR="${K8S_LOGS_DIR:-/tmp/k8s-logs}"
Collapse file

‎README.md‎

Copy file name to clipboardExpand all lines: README.md
+6-2Lines changed: 6 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -420,10 +420,14 @@ For more detailed information, see our [Upgrading](http://pulsar.apache.org/docs
420420

421421
## Upgrading to Helm chart version 4.6.0 (upcoming release)
422422

423-
The ZooKeeper StatefulSet has been modified to use a separate headless service and a separate ClusterIP service.
424-
The StatefulSet will be deleted and re-created during an upgrade. Deleting the StatefulSet will not delete data. The pods will
423+
The ZooKeeper StatefulSet and Broker StatefulSet have been modified to use a separate headless service and a separate ClusterIP service.
424+
The StatefulSet will be deleted and re-created during an upgrade. Deleting the StatefulSet will not delete data for ZooKeeper. The pods will
425425
remain running until the upgrade has replaced them. The deletion is handled using a Helm pre-upgrade hook, which runs a Kubernetes job using a container that contains `kubectl`. The image is `alpine/k8s` by default and is configurable under the `images.kubectl` key in values.yaml.
426426

427+
When TLS is enabled for ZooKeeper and Brokers, it is recommended to perform a rolling restart after the new certificates have been issued by cert-manager. The hostnames of the broker and zookeeper pods have changed and the certificate CRDs reflect this change.
428+
429+
In addition, the default for the main Broker service has been changed from headless to default ClusterIP service.
430+
427431
## Upgrading to Helm chart version 4.2.0
428432

429433
### TLS configuration for ZooKeeper has changed
Collapse file

‎charts/pulsar/templates/_broker.tpl‎

Copy file name to clipboardExpand all lines: charts/pulsar/templates/_broker.tpl
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,19 @@ under the License.
1818
*/}}
1919

2020
{{/*
21-
Define the pulsar brroker service
21+
Define the pulsar broker service (ordinary ClusterIP, used by clients)
2222
*/}}
2323
{{- define "pulsar.broker.service" -}}
2424
{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}
2525
{{- end }}
2626

27+
{{/*
28+
Define the pulsar broker headless service (used as the StatefulSet serviceName for pod DNS)
29+
*/}}
30+
{{- define "pulsar.broker.service.headless" -}}
31+
{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}-headless
32+
{{- end }}
33+
2734
{{/*
2835
Define the hostname
2936
*/}}
Collapse file

‎charts/pulsar/templates/_certs.tpl‎

Copy file name to clipboardExpand all lines: charts/pulsar/templates/_certs.tpl
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ spec:
102102
{{- if .tlsConfig.dnsNames }}
103103
{{ toYaml .tlsConfig.dnsNames | indent 4 }}
104104
{{- end }}
105+
{{- if or (eq .componentConfig.component "broker") (eq .componentConfig.component "zookeeper") }}
106+
- {{ printf "*.%s-%s-headless.%s.svc.%s" (include "pulsar.fullname" .root) .componentConfig.component (include "pulsar.namespace" .root) .root.Values.clusterDomain | quote }}
107+
{{- end }}
105108
- {{ printf "*.%s-%s.%s.svc.%s" (include "pulsar.fullname" .root) .componentConfig.component (include "pulsar.namespace" .root) .root.Values.clusterDomain | quote }}
106109
- {{ printf "%s-%s" (include "pulsar.fullname" .root) .componentConfig.component | quote }}
107110
# Issuer references are always required.
Collapse file

‎charts/pulsar/templates/broker-headless-service.yaml‎

Copy file name to clipboard
+53Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
# deploy broker only when `components.broker` is true
21+
{{- if .Values.components.broker }}
22+
apiVersion: v1
23+
kind: Service
24+
metadata:
25+
name: "{{ template "pulsar.broker.service.headless" . }}"
26+
namespace: {{ template "pulsar.namespace" . }}
27+
labels:
28+
{{- include "pulsar.standardLabels" . | nindent 4 }}
29+
component: {{ .Values.broker.component }}
30+
{{- with .Values.broker.headlessService.annotations }}
31+
annotations:
32+
{{ toYaml . | indent 4 }}
33+
{{- end }}
34+
spec:
35+
ports:
36+
- name: http
37+
port: {{ .Values.broker.ports.http }}
38+
{{- if not (and .Values.tls.enabled .Values.tls.broker.enabled .Values.tls.function_instance.enabled) }}
39+
- name: "{{ .Values.tcpPrefix }}pulsar"
40+
port: {{ .Values.broker.ports.pulsar }}
41+
{{- end }}
42+
{{- if and .Values.tls.enabled .Values.tls.broker.enabled }}
43+
- name: https
44+
port: {{ .Values.broker.ports.https }}
45+
- name: "{{ .Values.tlsPrefix }}pulsarssl"
46+
port: {{ .Values.broker.ports.pulsarssl }}
47+
{{- end }}
48+
clusterIP: None
49+
publishNotReadyAddresses: true
50+
selector:
51+
{{- include "pulsar.matchLabels" . | nindent 4 }}
52+
component: {{ .Values.broker.component }}
53+
{{- end }}
Collapse file

‎charts/pulsar/templates/broker-service.yaml‎

Copy file name to clipboardExpand all lines: charts/pulsar/templates/broker-service.yaml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ spec:
3636
# prometheus needs to access /metrics endpoint
3737
- name: http
3838
port: {{ .Values.broker.ports.http }}
39-
{{- if or (not .Values.tls.enabled) (not .Values.tls.broker.enabled) }}
39+
{{- if not (and .Values.tls.enabled .Values.tls.broker.enabled .Values.tls.function_instance.enabled) }}
4040
- name: "{{ .Values.tcpPrefix }}pulsar"
4141
port: {{ .Values.broker.ports.pulsar }}
4242
{{- end }}
Collapse file

‎charts/pulsar/templates/broker-statefulset-upgrade.yaml‎

Copy file name to clipboard
+115Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
# only when `components.broker` is true and `broker.statefulsetUpgrade.enabled` is true,
21+
# this pre-upgrade hook job will be created to clean up the old broker statefulset if the existing statefulset is created
22+
# by a chart older than 4.6.0, which has a different headless service name and will cause issue if not deleted before
23+
# the new statefulset is created.
24+
{{- if and .Values.components.broker .Values.broker.statefulsetUpgrade.enabled }}
25+
apiVersion: v1
26+
kind: ServiceAccount
27+
metadata:
28+
name: "{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}-sts-cleanup"
29+
namespace: {{ template "pulsar.namespace" . }}
30+
labels:
31+
{{- include "pulsar.standardLabels" . | nindent 4 }}
32+
component: {{ .Values.broker.component }}-sts-cleanup
33+
annotations:
34+
"helm.sh/hook": pre-upgrade
35+
"helm.sh/hook-weight": "-10"
36+
"helm.sh/hook-delete-policy": hook-succeeded
37+
---
38+
apiVersion: rbac.authorization.k8s.io/v1
39+
kind: Role
40+
metadata:
41+
name: "{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}-sts-cleanup"
42+
namespace: {{ template "pulsar.namespace" . }}
43+
labels:
44+
{{- include "pulsar.standardLabels" . | nindent 4 }}
45+
component: {{ .Values.broker.component }}-sts-cleanup
46+
annotations:
47+
"helm.sh/hook": pre-upgrade
48+
"helm.sh/hook-weight": "-10"
49+
"helm.sh/hook-delete-policy": hook-succeeded
50+
rules:
51+
- apiGroups: ["apps"]
52+
resources: ["statefulsets"]
53+
verbs: ["list", "get", "delete"]
54+
---
55+
apiVersion: rbac.authorization.k8s.io/v1
56+
kind: RoleBinding
57+
metadata:
58+
name: "{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}-sts-cleanup"
59+
namespace: {{ template "pulsar.namespace" . }}
60+
labels:
61+
{{- include "pulsar.standardLabels" . | nindent 4 }}
62+
component: {{ .Values.broker.component }}-sts-cleanup
63+
annotations:
64+
"helm.sh/hook": pre-upgrade
65+
"helm.sh/hook-weight": "-10"
66+
"helm.sh/hook-delete-policy": hook-succeeded
67+
subjects:
68+
- kind: ServiceAccount
69+
name: "{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}-sts-cleanup"
70+
roleRef:
71+
kind: Role
72+
name: "{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}-sts-cleanup"
73+
apiGroup: rbac.authorization.k8s.io
74+
---
75+
apiVersion: batch/v1
76+
kind: Job
77+
metadata:
78+
name: "{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}-sts-cleanup"
79+
namespace: {{ template "pulsar.namespace" . }}
80+
labels:
81+
{{- include "pulsar.standardLabels" . | nindent 4 }}
82+
component: {{ .Values.broker.component }}-sts-cleanup
83+
annotations:
84+
"helm.sh/hook": pre-upgrade
85+
"helm.sh/hook-weight": "0"
86+
"helm.sh/hook-delete-policy": hook-succeeded
87+
spec:
88+
backoffLimit: 1
89+
template:
90+
spec:
91+
serviceAccountName: "{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}-sts-cleanup"
92+
restartPolicy: Never
93+
containers:
94+
- name: sts-cleanup
95+
image: "{{ template "pulsar.imageFullName" (dict "image" .Values.images.kubectl "root" .) }}"
96+
command:
97+
- sh
98+
- -c
99+
- |
100+
STS="{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}"
101+
CHART_LABEL=$(kubectl get statefulset "$STS" -o jsonpath='{.metadata.labels.chart}' 2>/dev/null || true)
102+
if [ -z "$CHART_LABEL" ]; then
103+
echo "StatefulSet $STS not found or has no chart label, skipping delete"
104+
exit 0
105+
fi
106+
VERSION="${CHART_LABEL#pulsar-}"
107+
MAJOR="$(echo "$VERSION" | cut -d. -f1)"
108+
MINOR="$(echo "$VERSION" | cut -d. -f2)"
109+
if [ "$MAJOR" -lt 4 ] || { [ "$MAJOR" -eq 4 ] && [ "$MINOR" -lt 6 ]; }; then
110+
echo "Chart version $CHART_LABEL is older than pulsar-4.6.0, deleting StatefulSet $STS"
111+
kubectl delete statefulset "$STS" --cascade=orphan --ignore-not-found
112+
else
113+
echo "Chart version $CHART_LABEL is 4.6.0 or newer, skipping delete"
114+
fi
115+
{{- end }}
Collapse file

‎charts/pulsar/templates/broker-statefulset.yaml‎

Copy file name to clipboardExpand all lines: charts/pulsar/templates/broker-statefulset.yaml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ metadata:
3030
{{- include "pulsar.standardLabels" . | nindent 4 }}
3131
component: {{ .Values.broker.component }}
3232
spec:
33-
serviceName: "{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}"
33+
serviceName: "{{ template "pulsar.broker.service.headless" . }}"
3434
{{- if not .Values.broker.autoscaling.enabled }}
3535
replicas: {{ .Values.broker.replicaCount }}
3636
{{- end }}
Collapse file

‎charts/pulsar/templates/zookeeper-statefulset-upgrade.yaml‎

Copy file name to clipboardExpand all lines: charts/pulsar/templates/zookeeper-statefulset-upgrade.yaml
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
apiVersion: v1
2626
kind: ServiceAccount
2727
metadata:
28-
name: {{ .Release.Name }}-sts-cleanup
28+
name: "{{ template "pulsar.fullname" . }}-{{ .Values.zookeeper.component }}-sts-cleanup"
2929
namespace: {{ template "pulsar.namespace" . }}
3030
labels:
3131
{{- include "pulsar.standardLabels" . | nindent 4 }}
@@ -38,7 +38,7 @@ metadata:
3838
apiVersion: rbac.authorization.k8s.io/v1
3939
kind: Role
4040
metadata:
41-
name: {{ .Release.Name }}-sts-cleanup
41+
name: "{{ template "pulsar.fullname" . }}-{{ .Values.zookeeper.component }}-sts-cleanup"
4242
namespace: {{ template "pulsar.namespace" . }}
4343
labels:
4444
{{- include "pulsar.standardLabels" . | nindent 4 }}
@@ -55,7 +55,7 @@ rules:
5555
apiVersion: rbac.authorization.k8s.io/v1
5656
kind: RoleBinding
5757
metadata:
58-
name: {{ .Release.Name }}-sts-cleanup
58+
name: "{{ template "pulsar.fullname" . }}-{{ .Values.zookeeper.component }}-sts-cleanup"
5959
namespace: {{ template "pulsar.namespace" . }}
6060
labels:
6161
{{- include "pulsar.standardLabels" . | nindent 4 }}
@@ -66,16 +66,16 @@ metadata:
6666
"helm.sh/hook-delete-policy": hook-succeeded
6767
subjects:
6868
- kind: ServiceAccount
69-
name: {{ .Release.Name }}-sts-cleanup
69+
name: "{{ template "pulsar.fullname" . }}-{{ .Values.zookeeper.component }}-sts-cleanup"
7070
roleRef:
7171
kind: Role
72-
name: {{ .Release.Name }}-sts-cleanup
72+
name: "{{ template "pulsar.fullname" . }}-{{ .Values.zookeeper.component }}-sts-cleanup"
7373
apiGroup: rbac.authorization.k8s.io
7474
---
7575
apiVersion: batch/v1
7676
kind: Job
7777
metadata:
78-
name: {{ .Release.Name }}-sts-cleanup
78+
name: "{{ template "pulsar.fullname" . }}-{{ .Values.zookeeper.component }}-sts-cleanup"
7979
namespace: {{ template "pulsar.namespace" . }}
8080
labels:
8181
{{- include "pulsar.standardLabels" . | nindent 4 }}
@@ -88,7 +88,7 @@ spec:
8888
backoffLimit: 1
8989
template:
9090
spec:
91-
serviceAccountName: {{ .Release.Name }}-sts-cleanup
91+
serviceAccountName: "{{ template "pulsar.fullname" . }}-{{ .Values.zookeeper.component }}-sts-cleanup"
9292
restartPolicy: Never
9393
containers:
9494
- name: sts-cleanup
Collapse file

‎charts/pulsar/values.yaml‎

Copy file name to clipboardExpand all lines: charts/pulsar/values.yaml
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1229,8 +1229,17 @@ broker:
12291229
# 2. '' -> non-headless service, k8s picks an IPv4 address
12301230
# 3. 'None' -> headless
12311231
# Ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-clusterip
1232-
clusterIP: "None"
1232+
clusterIP: ""
12331233
annotations: {}
1234+
## Broker headless service with publishNotReadyAddresses set to true and used for statefulset's pod hostname resolution
1235+
## This service is used for broker pod DNS names in the broker statefulset.
1236+
## templates/broker-headless-service.yaml
1237+
##
1238+
headlessService:
1239+
annotations: {}
1240+
## Broker statefulset upgrade job
1241+
statefulsetUpgrade:
1242+
enabled: true
12341243
## Broker PodDisruptionBudget
12351244
## templates/broker-pdb.yaml
12361245
##

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.