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 ZooKeeper statefulset (#649) · apache/pulsar-helm-chart@57e2aec

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • README.md
  • charts/pulsar
    • templates
      • _zookeeper.tpl
      • bookkeeper-cluster-initialize.yaml
      • pulsar-cluster-initialize.yaml
      • zookeeper-headless-service.yaml
      • zookeeper-service.yaml
      • zookeeper-statefulset-upgrade.yaml
      • zookeeper-statefulset.yaml
    • values.yaml
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎README.md‎

Copy file name to clipboardExpand all lines: README.md
+6Lines changed: 6 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,12 @@ helm upgrade -n <namespace> -f values.yaml <pulsar-release-name> apachepulsar/pu
418418

419419
For more detailed information, see our [Upgrading](http://pulsar.apache.org/docs/helm-upgrade/) guide.
420420

421+
## Upgrading to Helm chart version 4.6.0 (upcoming release)
422+
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
425+
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.
426+
421427
## Upgrading to Helm chart version 4.2.0
422428

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

‎charts/pulsar/templates/_zookeeper.tpl‎

Copy file name to clipboardExpand all lines: charts/pulsar/templates/_zookeeper.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 zookeeper
21+
Define the pulsar zookeeper service (ordinary ClusterIP, used by brokers/bookies)
2222
*/}}
2323
{{- define "pulsar.zookeeper.service" -}}
2424
{{ template "pulsar.fullname" . }}-{{ .Values.zookeeper.component }}
2525
{{- end }}
2626

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

‎charts/pulsar/templates/bookkeeper-cluster-initialize.yaml‎

Copy file name to clipboardExpand all lines: charts/pulsar/templates/bookkeeper-cluster-initialize.yaml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ spec:
7575
echo "user provided zookeepers {{ $zk }} are unreachable... check in 3 seconds ..." && sleep 3;
7676
done;
7777
{{ else }}
78-
until nslookup {{ template "pulsar.fullname" . }}-{{ .Values.zookeeper.component }}-{{ add (.Values.zookeeper.replicaCount | int) -1 }}.{{ template "pulsar.fullname" . }}-{{ .Values.zookeeper.component }}.{{ template "pulsar.namespace" . }}; do
78+
until nslookup {{ template "pulsar.fullname" . }}-{{ .Values.zookeeper.component }}-{{ add (.Values.zookeeper.replicaCount | int) -1 }}.{{ template "pulsar.zookeeper.service.headless" . }}.{{ template "pulsar.namespace" . }}; do
7979
sleep 3;
8080
done;
8181
{{- end}}
Collapse file

‎charts/pulsar/templates/pulsar-cluster-initialize.yaml‎

Copy file name to clipboardExpand all lines: charts/pulsar/templates/pulsar-cluster-initialize.yaml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ spec:
8383
echo "user provided zookeepers {{ $zk }} are unreachable... check in 3 seconds ..." && sleep 3;
8484
done;
8585
{{ else if .Values.components.zookeeper }}
86-
until nslookup {{ template "pulsar.fullname" . }}-{{ .Values.zookeeper.component }}-{{ add (.Values.zookeeper.replicaCount | int) -1 }}.{{ template "pulsar.fullname" . }}-{{ .Values.zookeeper.component }}.{{ template "pulsar.namespace" . }}; do
86+
until nslookup {{ template "pulsar.fullname" . }}-{{ .Values.zookeeper.component }}-{{ add (.Values.zookeeper.replicaCount | int) -1 }}.{{ template "pulsar.zookeeper.service.headless" . }}.{{ template "pulsar.namespace" . }}; do
8787
sleep 3;
8888
done;
8989
{{- end }}
Collapse file

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

Copy file name to clipboard
+57Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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 zookeeper only when `components.zookeeper` is true
21+
{{- if .Values.components.zookeeper }}
22+
apiVersion: v1
23+
kind: Service
24+
metadata:
25+
name: "{{ template "pulsar.zookeeper.service.headless" . }}"
26+
namespace: {{ template "pulsar.namespace" . }}
27+
labels:
28+
{{- include "pulsar.standardLabels" . | nindent 4 }}
29+
component: {{ .Values.zookeeper.component }}
30+
{{- with .Values.zookeeper.headlessService.annotations }}
31+
annotations:
32+
{{ toYaml . | indent 4 }}
33+
{{- end }}
34+
spec:
35+
ports:
36+
- name: http
37+
port: {{ .Values.zookeeper.ports.http }}
38+
- name: "{{ .Values.tcpPrefix }}follower"
39+
port: {{ .Values.zookeeper.ports.follower }}
40+
- name: "{{ .Values.tcpPrefix }}leader-election"
41+
port: {{ .Values.zookeeper.ports.leaderElection }}
42+
- name: "{{ .Values.tcpPrefix }}client"
43+
port: {{ .Values.zookeeper.ports.client }}
44+
{{- if .Values.zookeeper.ports.admin }}
45+
- name: admin
46+
port: {{ .Values.zookeeper.ports.admin }}
47+
{{- end }}
48+
{{- if and .Values.tls.enabled .Values.tls.zookeeper.enabled }}
49+
- name: "{{ .Values.tlsPrefix }}client-tls"
50+
port: {{ .Values.zookeeper.ports.clientTls }}
51+
{{- end }}
52+
clusterIP: None
53+
publishNotReadyAddresses: true
54+
selector:
55+
{{- include "pulsar.matchLabels" . | nindent 4 }}
56+
component: {{ .Values.zookeeper.component }}
57+
{{- end }}
Collapse file

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

Copy file name to clipboardExpand all lines: charts/pulsar/templates/zookeeper-service.yaml
-7Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ metadata:
2727
labels:
2828
{{- include "pulsar.standardLabels" . | nindent 4 }}
2929
component: {{ .Values.zookeeper.component }}
30-
annotations:
3130
{{- with .Values.zookeeper.service.annotations }}
3231
annotations:
3332
{{ toYaml . | indent 4 }}
@@ -37,10 +36,6 @@ spec:
3736
# prometheus needs to access /metrics endpoint
3837
- name: http
3938
port: {{ .Values.zookeeper.ports.http }}
40-
- name: "{{ .Values.tcpPrefix }}follower"
41-
port: {{ .Values.zookeeper.ports.follower }}
42-
- name: "{{ .Values.tcpPrefix }}leader-election"
43-
port: {{ .Values.zookeeper.ports.leaderElection }}
4439
- name: "{{ .Values.tcpPrefix }}client"
4540
port: {{ .Values.zookeeper.ports.client }}
4641
{{- if .Values.zookeeper.ports.admin }}
@@ -51,8 +46,6 @@ spec:
5146
- name: "{{ .Values.tlsPrefix }}client-tls"
5247
port: {{ .Values.zookeeper.ports.clientTls }}
5348
{{- end }}
54-
clusterIP: None
55-
publishNotReadyAddresses: true
5649
selector:
5750
{{- include "pulsar.matchLabels" . | nindent 4 }}
5851
component: {{ .Values.zookeeper.component }}
Collapse file

‎charts/pulsar/templates/zookeeper-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.zookeeper` is true and `zookeeper.statefulsetUpgrade.enabled` is true,
21+
# this pre-upgrade hook job will be created to clean up the old zookeeper 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.zookeeper .Values.zookeeper.statefulsetUpgrade.enabled }}
25+
apiVersion: v1
26+
kind: ServiceAccount
27+
metadata:
28+
name: {{ .Release.Name }}-sts-cleanup
29+
namespace: {{ template "pulsar.namespace" . }}
30+
labels:
31+
{{- include "pulsar.standardLabels" . | nindent 4 }}
32+
component: {{ .Values.zookeeper.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: {{ .Release.Name }}-sts-cleanup
42+
namespace: {{ template "pulsar.namespace" . }}
43+
labels:
44+
{{- include "pulsar.standardLabels" . | nindent 4 }}
45+
component: {{ .Values.zookeeper.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: {{ .Release.Name }}-sts-cleanup
59+
namespace: {{ template "pulsar.namespace" . }}
60+
labels:
61+
{{- include "pulsar.standardLabels" . | nindent 4 }}
62+
component: {{ .Values.zookeeper.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: {{ .Release.Name }}-sts-cleanup
70+
roleRef:
71+
kind: Role
72+
name: {{ .Release.Name }}-sts-cleanup
73+
apiGroup: rbac.authorization.k8s.io
74+
---
75+
apiVersion: batch/v1
76+
kind: Job
77+
metadata:
78+
name: {{ .Release.Name }}-sts-cleanup
79+
namespace: {{ template "pulsar.namespace" . }}
80+
labels:
81+
{{- include "pulsar.standardLabels" . | nindent 4 }}
82+
component: {{ .Values.zookeeper.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: {{ .Release.Name }}-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.zookeeper.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/zookeeper-statefulset.yaml‎

Copy file name to clipboardExpand all lines: charts/pulsar/templates/zookeeper-statefulset.yaml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ metadata:
2929
{{- include "pulsar.standardLabels" . | nindent 4 }}
3030
component: {{ .Values.zookeeper.component }}
3131
spec:
32-
serviceName: "{{ template "pulsar.fullname" . }}-{{ .Values.zookeeper.component }}"
32+
serviceName: "{{ template "pulsar.zookeeper.service.headless" . }}"
3333
replicas: {{ .Values.zookeeper.replicaCount }}
3434
selector:
3535
matchLabels:
Collapse file

‎charts/pulsar/values.yaml‎

Copy file name to clipboardExpand all lines: charts/pulsar/values.yaml
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ images:
219219
repository: oxia/oxia
220220
tag: 0.15.3
221221
pullPolicy:
222+
kubectl:
223+
repository: alpine/k8s
224+
tag: 1.32.12
222225

223226
## TLS
224227
## templates/tls-certs.yaml
@@ -572,6 +575,14 @@ zookeeper:
572575
##
573576
service:
574577
annotations: {}
578+
## Zookeeper headless service
579+
## templates/zookeeper-headless-service.yaml
580+
##
581+
headlessService:
582+
annotations: {}
583+
## Zookeeper statefulset upgrade job
584+
statefulsetUpgrade:
585+
enabled: true
575586
## Zookeeper PodDisruptionBudget
576587
## templates/zookeeper-pdb.yaml
577588
##

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.