Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions charts/pulsar/templates/_bookkeeper.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,25 @@ PULSAR_PREFIX_tlsTrustStore: {{ ternary "/pulsar/certs/cacerts/ca-combined.pem"
{{- end }}
{{- end }}

{{/*
Render BookKeeper indexDirectories as comma-separated string.
Accepts either a string or a list of strings.
*/}}
{{- define "pulsar.bookkeeper.indexDirectories" -}}
{{- $v := .Values.bookkeeper.indexDirectories -}}
{{- if $v -}}
{{- if kindIs "string" $v -}}
{{- $v -}}
{{- else -}}
{{- $v | join "," -}}
{{- end -}}
{{- else if and .Values.bookkeeper.volumes.index.enabled .Values.bookkeeper.volumes.index.mountPath -}}
{{- .Values.bookkeeper.volumes.index.mountPath -}}
{{- else -}}
{{- "" -}}
{{- end -}}
{{- end -}}

{{/*
Define bookie init container : verify cluster id
*/}}
Expand Down
5 changes: 5 additions & 0 deletions charts/pulsar/templates/bookkeeper-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ data:
{{- else }}
ledgerDirectories: "/pulsar/data/bookkeeper/ledgers"
{{- end }}
{{- $indexDirs := include "pulsar.bookkeeper.indexDirectories" . }}
{{- if $indexDirs }}
# Configure RocksDB/index location for DbLedgerStorage. When unset, BookKeeper falls back to ledgerDirectories.
indexDirectories: {{ $indexDirs | quote }}
{{- end }}
{{- if .Values.functions.useBookieAsStateStore }}
# Stateful function config
extraServerComponents: "org.apache.bookkeeper.stream.server.StreamStorageLifecycleComponent"
Expand Down
64 changes: 64 additions & 0 deletions charts/pulsar/templates/bookkeeper-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,18 @@ spec:
nohup /pulsar/bin/certs-combine-pem-infinity.sh /pulsar/certs/cacerts/ca-combined.pem {{ template "pulsar.certs.cacerts" (dict "certs" .Values.tls.bookie.cacerts.certs) }} > /pulsar/certs/cacerts/certs-combine-pem-infinity.log 2>&1 &
cd /pulsar;
{{- end }}
{{- $indexDirs := include "pulsar.bookkeeper.indexDirectories" . -}}
{{- if $indexDirs }}
INDEX_DIRS={{ $indexDirs | quote }}
if [ -n "$INDEX_DIRS" ]; then
oldIFS=$IFS
IFS=','
for dir in $INDEX_DIRS; do
mkdir -p "$dir"
done
IFS=$oldIFS
fi
{{- end }}
bin/apply-config-from-env.py conf/bookkeeper.conf;
{{- include "pulsar.bookkeeper.zookeeper.tls.settings" . | nindent 10 }}
OPTS="${OPTS} -Dlog4j2.formatMsgNoLookups=true" exec bin/pulsar bookie;
Expand All @@ -227,6 +239,10 @@ spec:
{{- if .Values.bookkeeper.volumes.useSingleCommonVolume }}
- name: "{{ template "pulsar.fullname" . }}-{{ .Values.bookkeeper.component }}-{{ .Values.bookkeeper.volumes.common.name }}"
mountPath: /pulsar/data/bookkeeper
{{- if .Values.bookkeeper.volumes.index.enabled }}
- name: "{{ template "pulsar.fullname" . }}-{{ .Values.bookkeeper.component }}-{{ .Values.bookkeeper.volumes.index.name }}"
mountPath: {{ .Values.bookkeeper.volumes.index.mountPath }}
{{- end }}
{{- else }}
{{- if .Values.bookkeeper.volumes.journal.useMultiVolumes }}
{{- $fullname := include "pulsar.fullname" . -}}
Expand All @@ -250,6 +266,10 @@ spec:
- name: "{{ template "pulsar.fullname" . }}-{{ .Values.bookkeeper.component }}-{{ .Values.bookkeeper.volumes.ledgers.name }}"
mountPath: /pulsar/data/bookkeeper/ledgers
{{- end }}
{{- if .Values.bookkeeper.volumes.index.enabled }}
- name: "{{ template "pulsar.fullname" . }}-{{ .Values.bookkeeper.component }}-{{ .Values.bookkeeper.volumes.index.name }}"
mountPath: {{ .Values.bookkeeper.volumes.index.mountPath }}
{{- end }}
{{- end }}
{{- if .Values.bookkeeper.extraVolumeMounts }}
{{ toYaml .Values.bookkeeper.extraVolumeMounts | indent 8 }}
Expand All @@ -261,6 +281,10 @@ spec:
emptyDir: {}
- name: "{{ template "pulsar.fullname" . }}-{{ .Values.bookkeeper.component }}-{{ .Values.bookkeeper.volumes.ledgers.name }}"
emptyDir: {}
{{- if .Values.bookkeeper.volumes.index.enabled }}
- name: "{{ template "pulsar.fullname" . }}-{{ .Values.bookkeeper.component }}-{{ .Values.bookkeeper.volumes.index.name }}"
emptyDir: {}
{{- end }}
{{- end }}
{{- include "pulsar.bookkeeper.certs.volumes" . | nindent 6 }}
{{- if .Values.bookkeeper.extraVolumes }}
Expand Down Expand Up @@ -288,6 +312,26 @@ spec:
selector:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- if .Values.bookkeeper.volumes.index.enabled }}
- metadata:
name: "{{ template "pulsar.fullname" . }}-{{ .Values.bookkeeper.component }}-{{ .Values.bookkeeper.volumes.index.name }}"
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: {{ .Values.bookkeeper.volumes.index.size }}
{{- if .Values.bookkeeper.volumes.index.storageClassName }}
storageClassName: "{{ .Values.bookkeeper.volumes.index.storageClassName }}"
{{- else if and (not (and .Values.volumes.local_storage .Values.bookkeeper.volumes.index.local_storage)) .Values.bookkeeper.volumes.index.storageClass }}
storageClassName: "{{ template "pulsar.fullname" . }}-{{ .Values.bookkeeper.component }}-{{ .Values.bookkeeper.volumes.index.name }}"
{{- else if and .Values.volumes.local_storage .Values.bookkeeper.volumes.index.local_storage }}
storageClassName: "local-storage"
{{- end }}
{{- with .Values.bookkeeper.volumes.index.selector }}
selector:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- end }}
{{- else }}
{{- if .Values.bookkeeper.volumes.journal.useMultiVolumes }}
{{- $fullname := include "pulsar.fullname" . -}}
Expand Down Expand Up @@ -367,6 +411,26 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- if .Values.bookkeeper.volumes.index.enabled }}
- metadata:
name: "{{ template "pulsar.fullname" . }}-{{ .Values.bookkeeper.component }}-{{ .Values.bookkeeper.volumes.index.name }}"
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: {{ .Values.bookkeeper.volumes.index.size }}
{{- if .Values.bookkeeper.volumes.index.storageClassName }}
storageClassName: "{{ .Values.bookkeeper.volumes.index.storageClassName }}"
{{- else if and (not (and .Values.volumes.local_storage .Values.bookkeeper.volumes.index.local_storage)) .Values.bookkeeper.volumes.index.storageClass }}
storageClassName: "{{ template "pulsar.fullname" . }}-{{ .Values.bookkeeper.component }}-{{ .Values.bookkeeper.volumes.index.name }}"
{{- else if and .Values.volumes.local_storage .Values.bookkeeper.volumes.index.local_storage }}
storageClassName: "local-storage"
{{- end }}
{{- with .Values.bookkeeper.volumes.index.selector }}
selector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
30 changes: 30 additions & 0 deletions charts/pulsar/templates/bookkeeper-storageclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ parameters:
type: {{ .Values.bookkeeper.volumes.common.storageClass.type }}
fsType: {{ .Values.bookkeeper.volumes.common.storageClass.fsType }}
{{- end }}
{{- if and .Values.bookkeeper.volumes.index.enabled (not .Values.bookkeeper.volumes.index.local_storage) .Values.bookkeeper.volumes.index.storageClass }}
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: "{{ template "pulsar.fullname" . }}-{{ .Values.bookkeeper.component }}-{{ .Values.bookkeeper.volumes.index.name }}"
namespace: {{ template "pulsar.namespace" . }}
labels:
{{- include "pulsar.standardLabels" . | nindent 4 }}
component: {{ .Values.bookkeeper.component }}
provisioner: {{ .Values.bookkeeper.volumes.index.storageClass.provisioner }}
parameters:
type: {{ .Values.bookkeeper.volumes.index.storageClass.type }}
fsType: {{ .Values.bookkeeper.volumes.index.storageClass.fsType }}
{{- end }}
{{- else }}

{{- if and (not .Values.bookkeeper.volumes.journal.local_storage) .Values.bookkeeper.volumes.journal.storageClass }}
Expand Down Expand Up @@ -67,6 +82,21 @@ parameters:
type: {{ .Values.bookkeeper.volumes.ledgers.storageClass.type }}
fsType: {{ .Values.bookkeeper.volumes.ledgers.storageClass.fsType }}
{{- end }}
{{- if and .Values.bookkeeper.volumes.index.enabled (not .Values.bookkeeper.volumes.index.local_storage) .Values.bookkeeper.volumes.index.storageClass }}
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: "{{ template "pulsar.fullname" . }}-{{ .Values.bookkeeper.component }}-{{ .Values.bookkeeper.volumes.index.name }}"
namespace: {{ template "pulsar.namespace" . }}
labels:
{{- include "pulsar.standardLabels" . | nindent 4 }}
component: {{ .Values.bookkeeper.component }}
provisioner: {{ .Values.bookkeeper.volumes.index.storageClass.provisioner }}
parameters:
type: {{ .Values.bookkeeper.volumes.index.storageClass.type }}
fsType: {{ .Values.bookkeeper.volumes.index.storageClass.fsType }}
{{- end }}
{{- end }}

{{- end }}
Expand Down
21 changes: 21 additions & 0 deletions charts/pulsar/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,19 @@ bookkeeper:
size: 10Gi
# storageClassName: existent-storage-class
mountPath: /pulsar/data/bookkeeper/ledgers1
# Optional dedicated volume for BookKeeper indexes / RocksDB (`indexDirectories`).
# Useful when ledgers are on HDD but you want indexes on NVMe.
index:
enabled: false
name: index
size: 10Gi
local_storage: true
# storageClassName: existent-storage-class
# storageClass:
# ...
# selector:
# ...
mountPath: /pulsar/data/bookkeeper/index

## use a single common volume for both journal and ledgers
useSingleCommonVolume: false
Expand All @@ -830,6 +843,14 @@ bookkeeper:
# ...
# selector:
# ...

# Configure BookKeeper `indexDirectories` (RocksDB/index location for DbLedgerStorage).
# When empty/unset, BookKeeper falls back to `ledgerDirectories`.
# If `bookkeeper.volumes.index.enabled=true` and this is empty, it defaults to `bookkeeper.volumes.index.mountPath`.
# Example: place indexes on NVMe by reusing the journal volume mount:
# indexDirectories:
# - /pulsar/data/bookkeeper/journal/index
indexDirectories:
## Bookkeeper service account
## templates/bookkeeper-service-account.yaml
service_account:
Expand Down
Loading