Skip to content

Commit

Permalink
Add initContainers to templates (#516)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodePrometheus authored Aug 5, 2024
1 parent 7675e42 commit 093fa27
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 2 deletions.
3 changes: 3 additions & 0 deletions charts/pulsar/templates/autorecovery-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ spec:
volumeMounts:
{{- include "pulsar.autorecovery.certs.volumeMounts" . | nindent 8 }}
{{- end }}
{{- if .Values.autorecovery.initContainers }}
{{- toYaml .Values.autorecovery.initContainers | nindent 6 }}
{{- end }}
containers:
- name: "{{ template "pulsar.fullname" . }}-{{ .Values.autorecovery.component }}"
image: "{{ template "pulsar.imageFullName" (dict "image" .Values.images.autorecovery "root" .) }}"
Expand Down
5 changes: 4 additions & 1 deletion charts/pulsar/templates/bookkeeper-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ spec:
{{- end}}
volumeMounts:
{{- include "pulsar.bookkeeper.certs.volumeMounts" . | nindent 8 }}
{{- end}}
{{- end }}
{{- if .Values.bookkeeper.initContainers }}
{{- toYaml .Values.bookkeeper.initContainers | nindent 6 }}
{{- end }}
containers:
- name: "{{ template "pulsar.fullname" . }}-{{ .Values.bookkeeper.component }}"
image: "{{ template "pulsar.imageFullName" (dict "image" .Values.images.bookie "root" .) }}"
Expand Down
3 changes: 3 additions & 0 deletions charts/pulsar/templates/broker-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ spec:
volumeMounts:
{{- include "pulsar.broker.certs.volumeMounts" . | nindent 10 }}
{{- end }}
{{- if .Values.broker.initContainers }}
{{- toYaml .Values.broker.initContainers | nindent 6 }}
{{- end }}
containers:
- name: "{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}"
image: "{{ template "pulsar.imageFullName" (dict "image" .Values.images.broker "root" .) }}"
Expand Down
3 changes: 3 additions & 0 deletions charts/pulsar/templates/proxy-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ spec:
brokerServiceNumber="$(nslookup -timeout=10 {{ template "pulsar.fullname" . }}-{{ .Values.broker.component }} | grep Name | wc -l)";
done;
{{- end}}
{{- if .Values.proxy.initContainers }}
{{- toYaml .Values.proxy.initContainers | nindent 6 }}
{{- end }}
containers:
- name: "{{ template "pulsar.fullname" . }}-{{ .Values.proxy.component }}"
image: "{{ template "pulsar.imageFullName" (dict "image" .Values.images.proxy "root" .) }}"
Expand Down
4 changes: 4 additions & 0 deletions charts/pulsar/templates/pulsar-manager-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ spec:
{{ toYaml .Values.pulsar_manager.tolerations | indent 8 }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.pulsar_manager.gracePeriod }}
{{- if .Values.pulsar_manager.initContainers }}
initContainers:
{{- toYaml .Values.pulsar_manager.initContainers | nindent 6 }}
{{- end }}
containers:
- name: "{{ template "pulsar.fullname" . }}-{{ .Values.pulsar_manager.component }}"
image: "{{ .Values.images.pulsar_manager.repository }}:{{ .Values.images.pulsar_manager.tag }}"
Expand Down
4 changes: 4 additions & 0 deletions charts/pulsar/templates/toolset-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ spec:
{{- end }}
terminationGracePeriodSeconds: {{ .Values.toolset.gracePeriod }}
serviceAccountName: "{{ template "pulsar.fullname" . }}-{{ .Values.toolset.component }}"
{{- if .Values.toolset.initContainers }}
initContainers:
{{- toYaml .Values.toolset.initContainers | nindent 6 }}
{{- end }}
containers:
- name: "{{ template "pulsar.fullname" . }}-{{ .Values.toolset.component }}"
{{- if (and .Values.images.toolset .Values.images.toolset.repository) }}
Expand Down
4 changes: 4 additions & 0 deletions charts/pulsar/templates/zookeeper-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ spec:
securityContext:
{{ toYaml .Values.zookeeper.securityContext | indent 8 }}
{{- end }}
{{- if .Values.zookeeper.initContainers }}
initContainers:
{{- toYaml .Values.zookeeper.initContainers | nindent 6 }}
{{- end }}
containers:
- name: "{{ template "pulsar.fullname" . }}-{{ .Values.zookeeper.component }}"
image: "{{ template "pulsar.imageFullName" (dict "image" .Values.images.zookeeper "root" .) }}"
Expand Down
9 changes: 8 additions & 1 deletion charts/pulsar/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ zookeeper:
updateStrategy:
type: RollingUpdate
podManagementPolicy: Parallel
initContainers: []
# This is how prometheus discovers this component
podMonitor:
enabled: true
Expand Down Expand Up @@ -488,6 +489,7 @@ bookkeeper:
updateStrategy:
type: RollingUpdate
podManagementPolicy: Parallel
initContainers: []
# This is how prometheus discovers this component
podMonitor:
enabled: true
Expand Down Expand Up @@ -696,6 +698,7 @@ autorecovery:
# so the metrics are correctly rendered in grafana dashboard
component: recovery
replicaCount: 1
initContainers: []
# This is how prometheus discovers this component
podMonitor:
enabled: true
Expand Down Expand Up @@ -802,6 +805,7 @@ broker:
maxReplicas: 3
metrics: ~
behavior: ~
initContainers: []
# This is how prometheus discovers this component
podMonitor:
enabled: true
Expand Down Expand Up @@ -1044,6 +1048,7 @@ proxy:
maxReplicas: 3
metrics: ~
behavior: ~
initContainers: []
# This is how prometheus discovers this component
podMonitor:
enabled: true
Expand Down Expand Up @@ -1192,12 +1197,13 @@ proxy:
maxUnavailable: 1

## Pulsar ToolSet
## templates/toolset-deployment.yaml
## templates/toolset-statefulset.yaml
##
toolset:
component: toolset
useProxy: true
replicaCount: 1
initContainers: []
# True includes annotation for statefulset that contains hash of corresponding configmap, which will cause pods to restart on configmap change
restartPodsOnConfigMapChange: false
# nodeSelector:
Expand Down Expand Up @@ -1331,6 +1337,7 @@ kube-prometheus-stack:
pulsar_manager:
component: pulsar-manager
replicaCount: 1
initContainers: []
# True includes annotation for statefulset that contains hash of corresponding configmap, which will cause pods to restart on configmap change
restartPodsOnConfigMapChange: false
# nodeSelector:
Expand Down
79 changes: 79 additions & 0 deletions examples/values-init-containers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

## start
components:
# zookeeper
zookeeper: true
# bookkeeper
bookkeeper: true
# bookkeeper - autorecovery
autorecovery: true
# broker
broker: true
# functions
functions: true
# proxy
proxy: true
# toolset
toolset: true
# pulsar manager
pulsar_manager: true

zookeeper:
initContainers:
- name: pre-startup-checks
image: busybox:1.28
command: ['sh', '-c', 'echo "The zookeeper initContainers work as expected"']

bookkeeper:
initContainers:
- name: pre-startup-checks
image: busybox:1.28
command: ['sh', '-c', 'echo "The bookkeeper initContainers work as expected"']

autorecovery:
initContainers:
- name: pre-startup-checks
image: busybox:1.28
command: ['sh', '-c', 'echo "The autorecovery initContainers work as expected"']

broker:
initContainers:
- name: pre-startup-checks
image: busybox:1.28
command: ['sh', '-c', 'echo "The broker initContainers work as expected"']

proxy:
initContainers:
- name: pre-startup-checks
image: busybox:1.28
command: ['sh', '-c', 'echo "The proxy initContainers work as expected"']

toolset:
initContainers:
- name: pre-startup-checks
image: busybox:1.28
command: ['sh', '-c', 'echo "The toolset initContainers work as expected"']

pulsar_manager:
initContainers:
- name: pre-startup-checks
image: busybox:1.28
command: ['sh', '-c', 'echo "The pulsar_manager initContainers work as expected"']

0 comments on commit 093fa27

Please sign in to comment.