AWS Builder Center
Running Open Source DocumentDB on EKS with Graviton: Cost-Optimized and Observable

Running Open Source DocumentDB on EKS with Graviton: Cost-Optimized and Observable

Deploy Open Source DocumentDB on Amazon EKS with AWS best practices. This post covers contributions to the DocumentDB Kubernetes Operator project (PRs #349 and #352) that add Graviton-based compute for ~20% cost savings, configurable AZ count, S3 Gateway VPC endpoints, CloudWatch Container Insights observability, control-plane logging with retention controls, and cost allocation tags.

Series: Open source databases on AWS (1 article)

  1. 1
    Running Open Source DocumentDB on EKS with Graviton: Cost-Optimized and Observable This article
Principal Solutions Architect @ AWS
Open Source DocumentDB lets you run a MongoDB-compatible document database on your own Kubernetes cluster. In this post, I walk through a contribution I made to the  DocumentDB Kubernetes Operator  project that deploys Open Source DocumentDB on Amazon EKS following AWS best practices - Graviton instances for cost savings, CloudWatch for observability, and sensible defaults that keep your bill low. You'll go from zero to a running cluster in a single command.


Which DocumentDB?

There are two distinct technologies that share a similar DocumentDB name:  Amazon DocumentDB (with MongoDB compatibility)  and  Open Source DocumentDB . These are separate technologies with independent codebases - they do not share an engine or source code. They both provide MongoDB compatibility, but through different implementations and tradeoffs. Amazon DocumentDB is a world-class managed database service by AWS that we recommend for mission-critical production workloads requiring enterprise-grade durability, compliance, and reduced operational overhead.
Open Source DocumentDB is a Linux Foundation project that implements MongoDB wire-protocol compatibility as a PostgreSQL extension. It allows developers to use familiar MongoDB drivers and query syntax while leveraging PostgreSQL as the underlying storage engine. The  DocumentDB Kubernetes Operator  makes it easy to deploy and manage Open Source DocumentDB on Kubernetes.
Review the table below to understand some high-level differences between the two projects.

Amazon DocumentDB (managed service)
Open Source DocumentDB
What
Fully managed, MongoDB-compatible document database service on AWS
Linux Foundation project - PostgreSQL extension providing MongoDB wire-protocol compatibility
Architecture
Purpose-built distributed database engine with separated compute and storage
PostgreSQL with a compatibility layer that understands MongoDB's BSON/wire protocol
Runs on
AWS-managed infrastructure (serverless or provisioned)
Any Kubernetes cluster - EKS, self-managed, on-premises
Operated by
AWS (patching, backups, scaling handled for you)
self-managed, via the DocumentDB Kubernetes Operator
High availability
6 copies of data across 3 AZs, automatic failover to up to 15 read replicas
Kubernetes-level HA via the operator (pod restart, node failover)
Backup & recovery
Continuous backup to S3, point-in-time restore (PITR) to any second within 35-day window
Operator-managed snapshots (VolumeSnapshot); PITR depends on your WAL/backup configuration
Encryption
At-rest (AWS KMS), in-transit (TLS), encrypted snapshots — all enabled by default
TLS via cert-manager; at-rest encryption depends on your storage layer
Scaling
Auto-scaling (serverless), or add read replicas; storage scales automatically to 128 TiB
Manual — resize PVCs, add replicas via CRD, manage storage yourself
Maintenance & patching
Managed rolling patches with minimal downtime (read availability preserved on engine 5.0+ with multiple instances); automated scheduling
You manage OS, PostgreSQL, and extension upgrades
Compliance
SOC 1/2/3, PCI DSS, HIPAA eligible, FedRAMP, ISO certified
Inherits your cluster's compliance posture — you own the audit burden
Global clusters
Built-in cross-region replication (sub-second lag, sub-minute RTO) with up to 10 secondary regions
Not built-in; requires external tooling (e.g., cross-cluster replication)
Best for
Mission-critical production workloads requiring enterprise-grade durability, compliance, and reduced operational overhead
Self-managed deployments, dev/test, or when you need full control
This post focuses on Open Source DocumentDB running on EKS and applying AWS best practices shown here with improvements to the operator for Graviton, CloudWatch, cost-tagging.
As the community builds around this project, we want to ensure that AWS best practices - cost optimization, observability, and operational excellence - are available to those running it on EKS.

Overview

The  DocumentDB Kubernetes Operator  is an open-source project that deploys and manages Open Source DocumentDB instances on Kubernetes. This work spans two contributions:
  •  PR #349  - Added cost-optimization options ( --node-type ,  --eks-version ,  --spot ,  --tags ) to the base EKS setup scripts, making Graviton the default and enabling Spot instances and cost allocation tags.
  •  PR #352  - Added the telemetry-and-cost-optimized-eks variant under  contrib/ , layering CloudWatch observability, VPC endpoint savings, control-plane logging, and automated diagnostics on top of the base options.
Together, these let you deploy a fully observable, cost-optimized Open Source DocumentDB workload on Amazon EKS with a single command.
This variant layers AWS best practices on top of the base deployment:
Optimization
Impact
Graviton (m7g.large) default
~20% compute cost savings vs. x86
Configurable AZ count
2-AZ for dev/test (lower cost), 3-AZ for production (higher availability)
S3 Gateway VPC endpoint
Eliminates NAT Gateway costs for S3 traffic (free)
CloudWatch Container Insights
Full pod, node, and control-plane observability out of the box
Log retention controls
3-day default keeps CloudWatch bills bounded
Cost allocation tags
Built-in tagging for Cost Explorer breakdown
For dev/test workloads using  --spot , the total infrastructure cost lands in the low tens of dollars per month.

Requirements

  • An AWS account with permissions to create EKS clusters, VPC endpoints, CloudWatch log groups, and EKS add-ons
  • A GitHub account (for Helm chart access during operator installation)

Prerequisites

Install the following CLI tools before running the scripts:
Tool
Purpose
AWS CLI v2
AWS resource management
eksctl
EKS cluster lifecycle
kubectl
Kubernetes interaction
Helm 3
Operator chart installation
jq
JSON parsing in scripts
mongosh
(Optional) Endpoint validation
Verify your AWS credentials are configured:
aws sts get-caller-identity


Quick Start

1. Clone the repository

git clone https://github.com/documentdb/documentdb-kubernetes-operator.git
cd documentdb-kubernetes-operator/documentdb-playground/contrib/telemetry-and-cost-optimized-eks


2. Deploy the cluster and Open Source DocumentDB instance

./scripts/create-cluster.sh --deploy-instance

This single command will:
  • Create an EKS cluster on Graviton ( m7g.large ) nodes across 2 availability zones
  • Attach an S3 Gateway VPC endpoint to reduce NAT costs
  • Enable EKS control-plane logging with 3-day retention
  • Install the Amazon CloudWatch Observability add-on (Container Insights)
  • Deploy the Open Source DocumentDB operator and a sample instance
  • Run post-deploy diagnostics and print troubleshooting guidance
The full deployment takes approximately 20-25 minutes.

3. Verify the deployment

# Check pods are running
kubectl get pods -n documentdb-instance-ns

# Tail application logs via CloudWatch
aws logs tail /aws/containerinsights/documentdb-contrib-cluster/application \
--region us-west-2 --since 5m --follow

# Validate the endpoint (optional)
kubectl port-forward -n documentdb-instance-ns \
svc/documentdb-service-sample-documentdb 10260:10260 &
mongosh "mongodb://localhost:10260"


4. Customize (optional)

# Use Spot instances for dev/test (~70% savings)
./scripts/create-cluster.sh --deploy-instance --spot

# Use a different instance type or EKS version
./scripts/create-cluster.sh --deploy-instance --node-type m7g.xlarge --eks-version 1.35

# Add cost allocation tags
./scripts/create-cluster.sh --deploy-instance --tags "team=data,project=docdb-poc"


Cleanup

When you're done, tear down all resources to stop incurring charges:
./scripts/delete-cluster.sh -y

This removes everything cleanly:
  • Open Source DocumentDB instances and operator Helm releases
  • CloudWatch Observability add-on (waits for full deletion)
  • VPC endpoints
  • All CloudWatch log groups for the cluster
  • The EKS cluster and underlying CloudFormation stacks
No orphan resources are left behind.

What's Next

 Open Source DocumentDB goes beyond basic CRUD operations, it supports full-text search, geospatial queries, and vector embeddings via pgvector, making it a flexible foundation for workloads ranging from traditional document storage to AI-powered similarity search. Take next step in trying it out. If you are at the beginning of your Document database exploration check out  Amazon DocumentDB  for fully managed production deployments - see the  Developer Guide  for details.
  • Check out the  base aws-setup  if you want a simpler deployment without observability
  • Contribute back - the project welcomes PRs for additional cloud variants and optimizations

Series: Open source databases on AWS (1 article)

  1. 1
    Running Open Source DocumentDB on EKS with Graviton: Cost-Optimized and Observable This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article