Quickstart: Kind¶
This guide walks you through deploying a DocumentDB cluster on a local Kind (Kubernetes in Docker) cluster. Kind is ideal for development, testing, and CI pipelines.
Prerequisites¶
| Tool | Version | Purpose |
|---|---|---|
| Docker | 20.10+ | Container runtime for Kind |
| Kind | v0.31+ | Local Kubernetes cluster |
| kubectl | 1.35+ | Kubernetes CLI |
| Helm | 3.x | Package manager |
| mongosh | Latest | MongoDB shell for connecting |
Important
The DocumentDB operator requires Kubernetes 1.35+ for ImageVolume GA support. Kind v0.31+ ships images for Kubernetes 1.35.
Create a Kind Kubernetes cluster¶
Verify the Kubernetes cluster is running:
Install cert-manager¶
The operator uses cert-manager to manage TLS certificates.
helm repo add jetstack https://charts.jetstack.io
helm repo update
helm install cert-manager jetstack/cert-manager \
--namespace cert-manager \
--create-namespace \
--set installCRDs=true \
--wait
Verify that cert-manager is running:
All three pods (cert-manager, cert-manager-cainjector, cert-manager-webhook) should show Running.
Install the DocumentDB operator¶
The operator Helm chart automatically installs the CloudNativePG operator as a dependency.
helm repo add documentdb https://documentdb.github.io/documentdb-kubernetes-operator
helm repo update
helm install documentdb-operator documentdb/documentdb-operator \
--namespace documentdb-operator \
--create-namespace \
--wait
Verify:
Deploy a DocumentDB cluster¶
Create credentials¶
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Namespace
metadata:
name: documentdb-ns
---
apiVersion: v1
kind: Secret
metadata:
name: documentdb-credentials
namespace: documentdb-ns
type: Opaque
stringData:
username: dev_user
password: DevPassword123
EOF
Tip
The operator expects a Secret with username and password keys. The default Secret name is documentdb-credentials. To use a different name, set spec.documentDbCredentialSecret in your DocumentDB resource.
Create the DocumentDB cluster¶
cat <<EOF | kubectl apply -f -
apiVersion: documentdb.io/preview
kind: DocumentDB
metadata:
name: my-documentdb
namespace: documentdb-ns
spec:
nodeCount: 1
instancesPerNode: 1
documentDbCredentialSecret: documentdb-credentials
resource:
storage:
pvcSize: 10Gi
exposeViaService:
serviceType: ClusterIP
EOF
Wait for the DocumentDB cluster to become healthy:
Verify all pods are running (each pod runs a PostgreSQL container and a DocumentDB Gateway sidecar):
Connect to DocumentDB¶
Set up port forwarding to access the DocumentDB Gateway (port 10260):
In a new terminal, retrieve the connection string from the DocumentDB cluster status and connect:
# Get the connection string (contains embedded kubectl commands to resolve credentials)
kubectl get documentdb my-documentdb -n documentdb-ns -o jsonpath='{.status.connectionString}'
Use mongosh with the resolved credentials:
mongosh "mongodb://dev_user:DevPassword123@127.0.0.1:10260/?directConnection=true&authMechanism=SCRAM-SHA-256&tls=true&tlsAllowInvalidCertificates=true&replicaSet=rs0"
Tip
The CONNECTION STRING column in kubectl get documentdb output contains embedded kubectl commands that extract the username and password from the credentials Secret at runtime. You can copy and eval the full string, or substitute your known credentials directly as shown above.
Try inserting and querying data:
For more connection options including application drivers in Python, Node.js, Go, and Java, see Connecting to DocumentDB.
Local high availability¶
To test high availability locally, deploy with multiple instances:
cat <<EOF | kubectl apply -f -
apiVersion: documentdb.io/preview
kind: DocumentDB
metadata:
name: my-documentdb
namespace: documentdb-ns
spec:
nodeCount: 1
instancesPerNode: 3
documentDbCredentialSecret: documentdb-credentials
resource:
storage:
pvcSize: 10Gi
exposeViaService:
serviceType: ClusterIP
EOF
This creates one primary instance and two replicas with automatic failover.
NAME READY STATUS RESTARTS AGE
my-documentdb-1 2/2 Running 0 3m
my-documentdb-2 2/2 Running 0 2m
my-documentdb-3 2/2 Running 0 1m
Development with a local registry¶
For operator development, you can create a Kind Kubernetes cluster with a local Docker registry. This allows you to build and push custom operator images without an external registry.
This script:
- Creates a Kind Kubernetes cluster with a local registry (
localhost:5001) - Builds and pushes the operator and sidecar-injector images
- Installs cert-manager and the DocumentDB operator
- Optionally deploys a DocumentDB cluster
See the Development Environment Guide for more details.
Clean up¶
# Delete the DocumentDB cluster
kubectl delete documentdb my-documentdb -n documentdb-ns
# Uninstall the operator
helm uninstall documentdb-operator -n documentdb-operator
# Delete the Kind Kubernetes cluster
kind delete cluster --name documentdb-dev
Next steps¶
- Connecting to DocumentDB — driver examples and connection pooling
- Quickstart: K3s — lightweight alternative to Kind
- Networking — LoadBalancer and service configuration
- TLS — certificate management options
- Storage — persistent volume configuration