The scripts and configurations in this directory create a 3-node MongoDB replica set in a local Kind cluster with authentication and TLS enabled. Kind is a tool for running a local Kubernetes cluster in a Docker container.
IMPORTANT: If you're using Docker on macOS or Windows, you need to increase the Docker VM memory to at least 6GB (8GB recommended). See the Settings for Docker Desktop section of the Kind setup for instructions.
Create a Cluster
To create a cluster, make sure Docker is running, then run the create Bash script:
./create.sh
The create script will create a Kind cluster and start a 3-node MongoDB
replica set listening on localhost
ports 31181-31183 with
user:password user:12345
. It will write the TLS certificate to
mongodb_tls_cert.pem
in the current directory.
Connect to a Cluster
To connect to the MongoDB cluster with mongosh
, run the following
command:
mongosh \
"mongodb://user:12345@localhost:31181,localhost:31182,localhost:31183/admin" \
--tls \
--tlsCAFile kubernetes/kind/rootCA.pem \
--tlsCertificateKeyFile mongodb_tls_cert.pem
Delete a Cluster
To delete the MongoDB cluster and Kind cluster, run the delete Bash script:
./delete.sh