github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/deploy/clickhouse/templates/scripts.yaml (about)

     1  apiVersion: v1
     2  kind: ConfigMap
     3  metadata:
     4    name: zookeeper-scripts-tpl
     5    labels: {{- include "common.labels.standard" . | nindent 4 }}
     6      {{- if .Values.commonLabels }}
     7      {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
     8      {{- end }}
     9    {{- if .Values.commonAnnotations }}
    10    annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
    11    {{- end }}
    12  data:
    13    init-certs.sh: |-
    14      #!/bin/bash
    15    setup.sh: |-
    16      #!/bin/bash
    17  
    18      # Execute entrypoint as usual after obtaining ZOO_SERVER_ID
    19      # check ZOO_SERVER_ID in persistent volume via myid
    20      # if not present, set based on POD hostname
    21      if [[ -f "/bitnami/zookeeper/data/myid" ]]; then
    22          export ZOO_SERVER_ID="$(cat /bitnami/zookeeper/data/myid)"
    23      else
    24          HOSTNAME="$(hostname -s)"
    25          if [[ $HOSTNAME =~ (.*)-([0-9]+)$ ]]; then
    26              ORD=${BASH_REMATCH[2]}
    27              export ZOO_SERVER_ID="$((ORD + 1 ))"
    28          else
    29              echo "Failed to get index from hostname $HOST"
    30              exit 1
    31          fi
    32      fi
    33      exec /entrypoint.sh /run.sh