MongoDB (Percona Operator) Component

Sharded or non-sharded MongoDB cluster using Percona Operator with automatic backup to S3-compatible storage and dynamic shard management.

Architecture

PerconaServerMongoDB CR - Cluster definition
Replica Set - Non-sharded mode (default)
Sharded Cluster - mongos + config servers + shards
Percona Operator - Manages lifecycle

Quick Reference

REQUIRED = Must be defined by user
Attribute Example Generated In Effect
namespace REQ mongodb all files K8s namespace
replicas REQ 3 cluster.yaml Number of replicas
storage_size REQ 10Gi cluster.yaml Storage per replica
chart_version_mongodb REQ 1.15.0 operator Percona operator version
cpu_request / cpu_limit 500m / 2000m cluster.yaml CPU resources
mem_request / mem_limit 1Gi / 4Gi cluster.yaml Memory resources
antiaffinity true cluster.yaml Pod anti-affinity
sidecar_metrics true cluster.yaml MongoDB exporter sidecar
config_replicas 3 cluster.yaml Config server replicas (sharded)

Link Variables

Variable Link Type Purpose
__prometheus prometheus-mongodb Metrics collection
__bucket mongodb-bucket MinIO backup destination
__swbucket mongodb-swbucket SeaweedFS backup destination
__mongo_db (sub-component) Database sub-components
__shard (sub-component) Shard sub-components
__shard_link mongo_db-shard DB to shard mapping

Sub-Components

mongo_db - Individual database
  database - Database name
  username - Database user
  password - User password
  collector_name - Change stream collector

shard - Shard configuration
  replicas - Shard replicas
  cpu_request / cpu_limit
  mem_request / mem_limit
  storage_size

Generated Files

File Condition Contains
cluster.yaml Always PerconaServerMongoDB CR
crd.yaml Always CRD definitions
service-monitor.yaml __prometheus Prometheus ServiceMonitor
secret/cluster-secret.yaml Always Cluster auth secrets
sub_comp_db-job.yaml __mongo_db Database creation jobs

Ports

Port Purpose Service
27017 MongoDB protocol [cluster]-mongos (sharded) or [cluster]-rs0 (replica)
9216 Metrics exporter If sidecar_metrics enabled

Sharding Mode

Enabled when: shard sub-components exist

Components created:
- mongos routers (route_cpu/mem resources)
- Config servers (config_replicas)
- Data shards (per shard sub-component)

Connect via: [cluster]-mongos:27017