Skip to main content
Version: 1.0.0

FerretDB

FerretDB is a MongoDB-compatible database that uses PostgreSQL as a backend. It offers the simplicity of MongoDB while leveraging the robustness of PostgreSQL.


Configuration Example

Here is a configuration example for FerretDB with enabled backups and custom replicas:

apiVersion: apps.cozystack.io/v1alpha1
kind: FerretDB
metadata:
name: ferretdb-example
spec:
external: true
size: 20Gi
replicas: 3
storageClass: "replicated"
quorum:
minSyncReplicas: 1
maxSyncReplicas: 2
backup:
enabled: false
users:
user1:
password: "securepassword"
# s3Region: "us-east-1"
# s3Bucket: "s3.tenant.hikube.cloud/postgres-backups"
# schedule: "0 2 * * *"
# cleanupStrategy: "--keep-last=5 --keep-daily=5 --keep-within-weekly=1m"
# s3AccessKey: "your-s3-access-key"
# s3SecretKey: "your-s3-secret-key"
# resticPassword: "your-restic-password"

Using the kubeconfig provided by Hikube and this example yaml, saved as a manifest.yaml file, you can easily test the application deployment using the following command:

kubectl apply -f manifest.yaml

Configurable Parameters

General Parameters

These parameters allow you to configure the fundamental aspects of FerretDB.

NameDescriptionDefault Value
externalAllows external access to FerretDB from outside the cluster.false
sizeSize of the main persistent volume.10Gi
replicasNumber of PostgreSQL replicas for FerretDB.2
storageClassKubernetes storage class used for data."replicated" or "local"
quorum.minSyncReplicasMinimum number of synchronous replicas required for a transaction to be considered validated.0
quorum.maxSyncReplicasMaximum number of synchronous replicas that can validate a transaction (must be less than the total number of instances).0

Configuration Parameters

NameDescriptionDefault Value
usersFerretDB users configuration. Each user can have custom permissions.{}

Example:

users:
user1:
password: strongpassword
user2:
readonly: true
password: hackme

Backup Parameters

These parameters allow you to configure periodic backups of FerretDB.

NameDescriptionDefault Value
backup.enabledEnables or disables periodic backups.false
backup.s3RegionAWS S3 region where backups are stored.us-east-1
backup.s3BucketS3 bucket name used for storing backups.s3.example.org/postgres-backups
backup.scheduleBackup schedule (in Cron format).0 2 * * *
backup.cleanupStrategyStrategy for cleaning up old backups.--keep-last=3 --keep-daily=3 --keep-within-weekly=1m
backup.s3AccessKeyAWS S3 access key for authentication.oobaiRus9pah8PhohL1ThaeTa4UVa7gu
backup.s3SecretKeyAWS S3 secret key for authentication.ju3eum4dekeich9ahM1te8waeGai0oog
backup.resticPasswordPassword used for encrypting Restic backups.ChaXoveekoh6eigh4siesheeda2quai0

Restoring a Backup

You can restore a FerretDB backup using Restic. Here are the main steps:

Finding a Snapshot

Use the following command to list available snapshots in your S3 bucket:

restic -r s3:s3.tenant.hikube.cloud/ferretdb-backups/table_name snapshots

Restoring the Snapshot

To restore the most recent snapshot, run the following command specifying a restoration target:

restic -r s3:s3.tenant.hikube.cloud/ferretdb-backups/table_name restore latest --target /tmp/

Additional Resources

To deepen your knowledge of FerretDB and its features, here are some useful resources:

  • Official FerretDB Documentation Discover technical details, configuration options, and usage examples for FerretDB.

  • Restic Guide Learn how to use Restic for backup management, including best practices for encryption and restoration.

  • Tutorial: Cron Format A practical tool for creating and understanding Cron expressions used for scheduled backups.