apiVersion: v1
data:
  replicaset-entrypoint.sh: |-
    #!/bin/bash

    sleep 5

    . /liblog.sh

    # Perform adaptations depending on the host name
    if [[ $HOSTNAME =~ (.*)-0$ ]]; then
      info "Setting node as primary"
      export MONGODB_REPLICA_SET_MODE=primary
    else
      info "Setting node as secondary"
      export MONGODB_REPLICA_SET_MODE=secondary
      export MONGODB_INITIAL_PRIMARY_ROOT_PASSWORD="$MONGODB_ROOT_PASSWORD"
      unset MONGODB_ROOT_PASSWORD
    fi

    exec /entrypoint.sh /run.sh
kind: ConfigMap
metadata:
  labels:
    app.kubernetes.io/instance: RELEASE-NAME
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: mongodb-sharded
    helm.sh/chart: mongodb-sharded-4.0.1
  name: RELEASE-NAME-mongodb-sharded-replicaset-entrypoint
