Quickstart: Evaluate DocumentDB on Azure Local (preview)

In this quickstart, you install the open-source DocumentDB operator with Helm on an existing AKS cluster on Azure Local. You create a small database and use mongosh to insert and query a document. Azure Arc cluster connect provides Kubernetes access; these steps install the operator directly, not through the DocumentDB Arc extension.

Important

This DocumentDB capability is in preview. Microsoft provides no support for it during preview. Don't use it for production workloads. This restriction doesn't change the support terms for the underlying Azure Local, Azure Arc, or Kubernetes hosting services.

Prerequisites

  • An existing, Arc-connected AKS cluster on Azure Local reserved for evaluation, with cluster-admin access and Arc cluster connect permissions and connectivity.
  • Kubernetes 1.33 or later for this evaluation. Check the platform validation results for the exact tested configuration; a minimum version isn't a conformance result.
  • At least one Linux worker with 4 vCPUs and 16 GiB of memory, a default StorageClass, and capacity for a 10-GiB database volume.
  • Outbound access for Azure Arc and image pulls, including ghcr.io and quay.io. Mirroring images alone isn't a complete disconnected installation procedure.
  • A local Bash terminal on Linux or Windows Subsystem for Linux (WSL), with Linux versions of Azure CLI 2.70 or later, Helm 3.x, kubectl within one minor version of the cluster, and MongoDB Shell (mongosh). Run these commands locally, not in Azure Cloud Shell.
  • A cluster without an existing DocumentDB operator or Arc extension, or a separately installed CloudNativePG operator. This chart includes CloudNativePG; don't install overlapping controllers. Check with the cluster owner before proceeding.

Use test data and the same Bash terminal throughout, except where another terminal is specified. Stop and resolve any failed command before proceeding.

Connect to the cluster

Sign in and select the subscription that contains your existing cluster:

az extension add --name connectedk8s --upgrade
az login
az account set --subscription "<subscription-id>"
az account show --query "{subscription:name,id:id}" --output table

Before starting the proxy, record your current context so you can switch back after the evaluation:

kubectl config current-context

In a second local terminal, start the proxy for that cluster and keep it running:

az connectedk8s proxy --name "<arc-cluster-name>" --resource-group "<resource-group>"

The proxy adds the cluster to your default kubeconfig (~/.kube/config) and makes it the current context. The kubeconfig entry remains after you stop the proxy.

Back in your first terminal, confirm that the current context is the intended evaluation cluster, then capture it for subsequent commands:

kubectl config current-context
export EVAL_CONTEXT="$(kubectl config current-context)"
kubectl --context "$EVAL_CONTEXT" get nodes -o wide
kubectl --context "$EVAL_CONTEXT" get storageclass
helm list --all-namespaces --kube-context "$EVAL_CONTEXT"
kubectl --context "$EVAL_CONTEXT" get deployments --all-namespaces

Check that the workers are Ready, a default StorageClass is available, and no existing DocumentDB or CloudNativePG installation conflicts with this evaluation. Helm releases alone don't identify every controller, so also review the deployments with the cluster owner. Use a new documentdb-ns namespace, not one containing other workloads.

Install cert-manager and the operator

Check for running cert-manager deployments, not just its CRDs:

kubectl --context "$EVAL_CONTEXT" get deployments --namespace cert-manager
kubectl --context "$EVAL_CONTEXT" get pods --namespace cert-manager

The usual deployments are cert-manager, cert-manager-cainjector, and cert-manager-webhook. Names and namespaces can differ for an existing installation; use the earlier cluster-wide inventory and check with the cluster owner.

If cert-manager is installed, verify that all its deployments have their desired replicas available, its pods have ready containers, and its version meets the operator prerequisites. Reuse a healthy installation. If it's unhealthy, repair it before proceeding; don't install a second copy.

CRDs can remain after uninstall and don't prove that cert-manager is running. Skipping installation based only on CRD presence can cause the operator installation to time out. If no running installation exists and the cluster owner confirms cert-manager was removed or isn't installed, install it below. Don't treat an access or connection error as absence, and don't delete retained CRDs to resolve an installation conflict without checking their ownership and resources.

helm repo add jetstack https://charts.jetstack.io
helm repo update jetstack
helm install cert-manager jetstack/cert-manager \
  --kube-context "$EVAL_CONTEXT" \
  --version v1.21.3 \
  --namespace cert-manager --create-namespace \
  --set crds.enabled=true --wait --timeout 10m
kubectl --context "$EVAL_CONTEXT" get pods --namespace cert-manager
kubectl --context "$EVAL_CONTEXT" rollout status deployment/cert-manager \
  --namespace cert-manager --timeout=10m
kubectl --context "$EVAL_CONTEXT" rollout status deployment/cert-manager-cainjector \
  --namespace cert-manager --timeout=10m
kubectl --context "$EVAL_CONTEXT" rollout status deployment/cert-manager-webhook \
  --namespace cert-manager --timeout=10m

Wait for the cert-manager, cainjector, and webhook pods to run with ready containers.

Install the operator with the published Helm chart version 1.1.0. The chart's version compatibility guidance identifies its default engine as 1.0.0. This chart pin is standalone, not a mapping inferred from the similarly numbered Arc extension.

helm install documentdb-operator oci://ghcr.io/documentdb/documentdb-operator \
  --kube-context "$EVAL_CONTEXT" \
  --version 1.1.0 \
  --namespace documentdb-operator --create-namespace \
  --wait --timeout 10m
kubectl --context "$EVAL_CONTEXT" get deployments --namespace documentdb-operator
kubectl --context "$EVAL_CONTEXT" get pods --namespace documentdb-operator
kubectl --context "$EVAL_CONTEXT" get deployments --namespace cnpg-system
kubectl --context "$EVAL_CONTEXT" get pods --namespace cnpg-system
kubectl --context "$EVAL_CONTEXT" rollout status deployment/documentdb-operator \
  --namespace documentdb-operator --timeout=10m
kubectl --context "$EVAL_CONTEXT" rollout status deployment/documentdb-operator-cloudnative-pg \
  --namespace cnpg-system --timeout=10m
kubectl --context "$EVAL_CONTEXT" rollout status deployment/sidecar-injector \
  --namespace cnpg-system --timeout=10m

The DocumentDB operator runs in documentdb-operator. The bundled CloudNativePG operator and sidecar injector run in cnpg-system. Confirm that all three deployments have their desired replicas available before creating a database.

An initial DocumentDB operator restart can occur while cert-manager issues its webhook certificate. Continue only after the readiness checks succeed. Investigate repeated restarts or unavailable deployments rather than treating them as normal.

Create a database

Create a namespace used only by this evaluation:

kubectl --context "$EVAL_CONTEXT" create namespace documentdb-ns

Create a Secret with username and password keys. This Bash subshell prompts without displaying the password and passes it over standard input, not a command-line argument. Keep the password for the later mongosh prompt. Don't enable shell tracing or record the terminal while entering credentials.

(
  set +x
  set -euo pipefail
  trap 'unset DOCUMENTDB_PASSWORD' EXIT
  DOCUMENTDB_PASSWORD=""
  while [[ -z "$DOCUMENTDB_PASSWORD" ]]; do
    IFS= read -r -s -p "Enter a nonempty evaluation password: " DOCUMENTDB_PASSWORD
    printf '\n'
  done
  printf '%s' "$DOCUMENTDB_PASSWORD" |
    kubectl --context "$EVAL_CONTEXT" create secret generic documentdb-credentials \
      --namespace documentdb-ns \
      --from-literal=username=evaluation_user \
      --from-file=password=/dev/stdin
)

Apply a single-instance database with a 10-GiB volume and an internal ClusterIP service:

kubectl --context "$EVAL_CONTEXT" apply -f - <<'EOF'
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 reported healthy status and pod readiness, with a 10-minute timeout for each check. If either wait fails, the subshell prints diagnostics and returns an error. Don't continue to the connection step until both checks succeed.

(
  set -euo pipefail
  if ! kubectl --context "$EVAL_CONTEXT" wait \
    --namespace documentdb-ns documentdb/my-documentdb \
    --for=jsonpath='{.status.status}'='Cluster in healthy state' --timeout=10m ||
    ! kubectl --context "$EVAL_CONTEXT" wait \
      --namespace documentdb-ns pod/my-documentdb-1 \
      --for=condition=Ready --timeout=10m; then
    kubectl --context "$EVAL_CONTEXT" describe documentdb my-documentdb --namespace documentdb-ns
    kubectl --context "$EVAL_CONTEXT" get pods,pvc --namespace documentdb-ns
    kubectl --context "$EVAL_CONTEXT" get events --namespace documentdb-ns --sort-by=.metadata.creationTimestamp
    exit 1
  fi
  kubectl --context "$EVAL_CONTEXT" get pods --namespace documentdb-ns
)

On nodes running containerd 1.7 without ImageVolume support, this operator version automatically uses a combined PostgreSQL and DocumentDB image. Don't assume every Azure Local cluster uses that runtime. Check the selected mode on the CloudNativePG cluster:

kubectl --context "$EVAL_CONTEXT" get clusters.postgresql.cnpg.io my-documentdb \
  --namespace documentdb-ns \
  -o jsonpath='{.metadata.annotations.documentdb\.io/image-mode}{"\n"}'

The output is combined when the fallback is selected.

Insert and query a document

In the first terminal, forward the database service to IPv4 loopback only and leave the command running:

kubectl --context "$EVAL_CONTEXT" port-forward \
  --address 127.0.0.1 --namespace documentdb-ns \
  service/documentdb-service-my-documentdb 10260:10260

In a third local terminal, connect with mongosh and enter the password when prompted. The gateway uses a self-signed certificate by default. --tlsAllowInvalidCertificates bypasses server identity validation; use it only for this disposable evaluation through the localhost-only port forward, never for remote or production connections.

mongosh "mongodb://127.0.0.1:10260/?directConnection=true&tls=true" \
  --tlsAllowInvalidCertificates \
  --username evaluation_user \
  --authenticationMechanism SCRAM-SHA-256 \
  --password

At the mongosh prompt, insert and read a test document:

use evaluation
db.items.insertOne({ name: "azure-local-evaluation", message: "Hello from DocumentDB" })
db.items.find({ name: "azure-local-evaluation" })

Check that the insert is acknowledged and the query returns the document. Operator installation alone doesn't verify these database operations.

Review Azure Local considerations

  • High availability: This example uses one instance. To evaluate local HA, provide capacity on three workers and use instancesPerNode: 3. See Local high availability.
  • External access: A LoadBalancer service requires infrastructure support, such as MetalLB on AKS on Azure Local. Availability depends on your cluster configuration. This quickstart doesn't expose a remote endpoint.
  • Storage and backups: The default StorageClass supplies storage unless you set spec.resource.storage.storageClass. With the AKS on Azure Local disk driver that lacks volume snapshot support, Backup, ScheduledBackup, and snapshot restore aren't available. Evaluate logical backups with mongodump and mongorestore and verify a restore before relying on them. See Storage configuration.
  • Connection failures: Check that the proxy and port-forward terminals are still running. Stop your own proxy with Ctrl+C and allow its helper process to exit before restarting it. Run only one proxy at a time. If restarting fails, confirm that your previous helper exited rather than starting more proxies or terminating other users' processes. For database failures, inspect the resource, pods, PVCs, and events from the readiness step.

Clean up resources

Warning

These steps delete the evaluation database and credentials. Changing a retained volume's reclaim policy to Delete can permanently destroy its data and backing disk. Confirm the cluster, namespace, and exact volume ownership before deleting anything.

Exit mongosh and stop your port forward with Ctrl+C. Keep the Arc proxy running until Kubernetes cleanup is complete. In the first terminal, inspect the PVC-to-volume mapping and record the exact volume names belonging to this database:

printf 'Evaluation context: %s\n' "$EVAL_CONTEXT"
kubectl --context "$EVAL_CONTEXT" get pvc --namespace documentdb-ns \
  -o custom-columns=CLAIM:.metadata.name,VOLUME:.spec.volumeName
kubectl --context "$EVAL_CONTEXT" get pv \
  -o custom-columns=VOLUME:.metadata.name,NAMESPACE:.spec.claimRef.namespace,CLAIM:.spec.claimRef.name,POLICY:.spec.persistentVolumeReclaimPolicy,STATUS:.status.phase

After confirming that the namespace contains only this evaluation, delete the named database and namespace:

kubectl --context "$EVAL_CONTEXT" delete documentdb my-documentdb \
  --namespace documentdb-ns --timeout=5m
kubectl --context "$EVAL_CONTEXT" delete namespace documentdb-ns --timeout=5m

The operator defaults to retaining data volumes. Check their actual reclaim policies rather than assuming namespace deletion removed the disks. To remove an evaluation volume, repeat the following block for each exact volume recorded earlier. Proceed only when the displayed claim is one you recorded and its status is Released.

(
  set -euo pipefail
  IFS= read -r -p "Exact evaluation volume name: " EVAL_PV
  test -n "$EVAL_PV"
  kubectl --context "$EVAL_CONTEXT" get pv "$EVAL_PV" \
    -o custom-columns=VOLUME:.metadata.name,NAMESPACE:.spec.claimRef.namespace,CLAIM:.spec.claimRef.name,POLICY:.spec.persistentVolumeReclaimPolicy,STATUS:.status.phase
  test "$(kubectl --context "$EVAL_CONTEXT" get pv "$EVAL_PV" -o jsonpath='{.spec.claimRef.namespace}')" = "documentdb-ns"
  test "$(kubectl --context "$EVAL_CONTEXT" get pv "$EVAL_PV" -o jsonpath='{.status.phase}')" = "Released"
  IFS= read -r -p "Confirm permanent deletion by entering the same volume name: " CONFIRM_PV
  test "$CONFIRM_PV" = "$EVAL_PV"
  kubectl --context "$EVAL_CONTEXT" patch pv "$EVAL_PV" \
    --type merge -p '{"spec":{"persistentVolumeReclaimPolicy":"Delete"}}'
  kubectl --context "$EVAL_CONTEXT" wait --for=delete "pv/$EVAL_PV" --timeout=5m
)

Verify backing-disk cleanup with your storage administrator. Don't delete a retained PV object as a substitute for deleting its backing disk.

Only if you installed the operator solely for this evaluation and no other workloads depend on it, uninstall the release:

helm uninstall documentdb-operator --namespace documentdb-operator \
  --kube-context "$EVAL_CONTEXT" --wait --timeout 5m

Only if you installed cert-manager here and no other workloads depend on it, uninstall that release:

helm uninstall cert-manager --namespace cert-manager \
  --kube-context "$EVAL_CONTEXT" --wait --timeout 5m

Helm can leave namespaces, CRDs, and other cluster-scoped resources behind. Inspect documentdb-operator, cnpg-system, and cert-manager with the cluster owner before removing any remaining resources. Delete a namespace only after confirming that it contains no resources needed by other workloads. Deleting a CRD deletes every custom resource of that type across the cluster, not just this evaluation. Don't bulk-delete DocumentDB, CloudNativePG, or cert-manager CRDs; leave shared resources intact.

Stop your Arc proxy with Ctrl+C and allow its helper process to exit. If you recorded a previous context, switch back to it:

kubectl config use-context "<previous-context>"

The proxy's kubeconfig entry remains until you remove it separately. Leave the existing AKS cluster, Arc connection, and Azure resource group intact.