| {{- $zoo := .Values.zookeeper -}} |
| {{- if $zoo.enabled }} |
| apiVersion: v1 |
| kind: ConfigMap |
| metadata: |
| name: {{ template "zoo.name" . }}-scripts |
| namespace: {{ template "zoo.namespace" . }} |
| labels: |
| {{- include "zoo.labels" . | nindent 4 }} |
| {{- with $zoo.labels }} |
| {{- toYaml . | nindent 4 }} |
| {{- end }} |
| annotations: |
| {{- with $zoo.annotations }} |
| {{- toYaml . | nindent 4 }} |
| {{- end }} |
| data: |
| init-certs.sh: |- |
| #!/bin/bash |
| setup.sh: |- |
| #!/bin/bash |
| # Execute entrypoint as usual after obtaining ZOO_SERVER_ID |
| # check ZOO_SERVER_ID in persistent volume via myid |
| # if not present, set based on POD hostname |
| if [[ -f "/bitnami/zookeeper/data/myid" ]]; then |
| export ZOO_SERVER_ID="$(cat /bitnami/zookeeper/data/myid)" |
| else |
| HOSTNAME="$(hostname -s)" |
| if [[ $HOSTNAME =~ (.*)-([0-9]+)$ ]]; then |
| ORD=${BASH_REMATCH[2]} |
| export ZOO_SERVER_ID="$((ORD + 1 ))" |
| else |
| echo "Failed to get index from hostname $HOST" |
| exit 1 |
| fi |
| fi |
| exec /entrypoint.sh /run.sh |
| {{- end -}} |