scripts-configmap.yaml 1.3 KB

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