This module is for deploying a highly available MongoDB cluster on Kubernetes using Helm charts. This module provides flexible configuration options to customize the MongoDB deployment such as setting the volume size, architecture, replica count, and more. It also includes options to enable MongoDB backups and restores, and to deploy MongoDB exporters for getting metrics in Grafana. Additionally, this module provides options to create a new namespace, and to configure recovery windows for AWS Secrets Manager, Azure key vault & GCP secrets manager. With this module, users can easily deploy a highly available MongoDB cluster on AWS EKS, Azure AKS & GCP GKE Kubernetes clusters with the flexibility to customize their configurations according to their needs.
MongoDB Helm Chart Version | K8s supported version (EKS, AKS & GKE) |
---|---|
13.1.5 | 1.23,1.24,1.25,1.26,1.27 |
locals {
name = "mongo"
region = "us-east-2"
environment = "prod"
additional_tags = {
Owner = "organization_name"
Expires = "Never"
Department = "Engineering"
}
create_namespace = true
namespace = "mongodb"
store_password_to_secret_manager = true
mongodb_custom_credentials_enabled = true
mongodb_custom_credentials_config = {
root_user = "root"
root_password = "NCPFUKEMd7rrWuvMAa73"
metric_exporter_user = "mongodb_exporter"
metric_exporter_password = "nvAHhm1uGQNYWVw6ZyAH"
}
}
module "aws" {
source = "squareops/mongodb/kubernetes//modules/resources/aws"
environment = local.environment
name = local.name
namespace = local.namespace
store_password_to_secret_manager = local.store_password_to_secret_manager
cluster_name = ""
mongodb_custom_credentials_enabled = local.mongodb_custom_credentials_enabled
mongodb_custom_credentials_config = local.mongodb_custom_credentials_config
}
module "mongodb" {
source = "squareops/mongodb/kubernetes"
namespace = local.namespace
create_namespace = local.create_namespace
mongodb_config = {
name = local.name
namespace = local.namespace
values_yaml = ""
environment = local.environment
volume_size = "10Gi"
architecture = "replicaset"
custom_databases = "['db1', 'db2']"
custom_databases_usernames = "['admin', 'admin']"
custom_databases_passwords = "['pass1', 'pass2']"
replica_count = 2
storage_class_name = "gp2"
store_password_to_secret_manager = local.store_password_to_secret_manager
}
mongodb_custom_credentials_enabled = local.mongodb_custom_credentials_enabled
mongodb_custom_credentials_config = local.mongodb_custom_credentials_config
root_password = local.mongodb_custom_credentials_enabled ? "" : module.aws.root_password
metric_exporter_password = local.mongodb_custom_credentials_enabled ? "" : module.aws.metric_exporter_password
bucket_provider_type = "s3"
mongodb_backup_enabled = true
iam_role_arn_backup = module.aws.iam_role_arn_backup
mongodb_backup_config = {
bucket_uri = "s3://mongo-demo-backup"
s3_bucket_region = "us-east-2"
cron_for_full_backup = "* * * * *"
}
mongodb_restore_enabled = true
iam_role_arn_restore = module.aws.iam_role_arn_restore
mongodb_restore_config = {
bucket_uri = "s3://mongo-demo-backup/mongodumpfull_20230523_092110.gz"
s3_bucket_region = "us-east-2"
file_name = "mongodumpfull_20230523_092110.gz"
}
mongodb_exporter_enabled = true
mongodb_exporter_values = file("./helm/exporter.yaml")
}
The required IAM permissions to create resources from this module can be found here
This module provides functionality to automate the backup and restore process for mongo databases using AWS S3 buckets. It allows users to easily schedule backups, restore databases from backups stored in S3, and manage access permissions using AWS IAM roles. Features
No requirements.
Name | Version |
---|---|
helm | n/a |
kubernetes | n/a |
random | n/a |
No modules.
Name | Type |
---|---|
helm_release.mongodb | resource |
helm_release.mongodb_backup | resource |
helm_release.mongodb_exporter | resource |
helm_release.mongodb_restore | resource |
kubernetes_namespace.mongodb | resource |
random_password.mongodb_exporter_password | resource |
random_password.mongodb_root_password | resource |
Name | Description | Type | Default | Required |
---|---|---|---|---|
app_version | Version of the Mongodb application that will be deployed. | string |
"5.0.8-debian-10-r9" |
no |
az_account_backup | Azure user managed account backup identity | string |
"" |
no |
az_account_restore | Azure user managed account restore identity | string |
"" |
no |
azure_container_name | Azure container name | string |
"" |
no |
azure_storage_account_key | Azure storage account key | string |
"" |
no |
azure_storage_account_name | Azure storage account name | string |
"" |
no |
bucket_provider_type | Choose what type of provider you want (s3, gcs) | string |
"gcs" |
no |
chart_version | Version of the Mongodb chart that will be used to deploy Mongodb application. | string |
"13.1.5" |
no |
cluster_name | Specifies the name of the EKS cluster to deploy the Mongodb application on. | string |
"" |
no |
create_namespace | Specify whether or not to create the namespace if it does not already exist. Set it to true to create the namespace. | string |
false |
no |
iam_role_arn_backup | IAM role ARN for backup (AWS) | string |
"" |
no |
iam_role_arn_restore | IAM role ARN for restore (AWS) | string |
"" |
no |
metric_exporter_password | Metric exporter password for MongoDB | string |
"" |
no |
mongodb_backup_config | Configuration options for Mongodb database backups. It includes properties such as the S3 bucket URI, the S3 bucket region, and the cron expression for full backups. | any |
{ |
no |
mongodb_backup_enabled | Specifies whether to enable backups for Mongodb database. | bool |
false |
no |
mongodb_config | Specify the configuration settings for Mongodb, including the name, environment, storage options, replication settings, and custom YAML values. | any |
{ |
no |
mongodb_custom_credentials_config | Specify the configuration settings for Mongodb to pass custom credentials during creation. | any |
{ |
no |
mongodb_custom_credentials_enabled | Specifies whether to enable custom credentials for MongoDB database. | bool |
false |
no |
mongodb_exporter_config | Specify whether or not to deploy Mongodb exporter to collect Mongodb metrics for monitoring in Grafana. | any |
{ |
no |
mongodb_exporter_enabled | Specify whether or not to deploy Mongodb exporter to collect Mongodb metrics for monitoring in Grafana. | bool |
false |
no |
mongodb_exporter_values | Mongo DB prometheus exporter values file | any |
"" |
no |
mongodb_restore_config | Configuration options for restoring dump to the Mongodb database. | any |
{ |
no |
mongodb_restore_enabled | Specifies whether to enable restoring dump to the Mongodb database. | bool |
false |
no |
namespace | Name of the Kubernetes namespace where the Mongodb deployment will be deployed. | string |
"mongodb" |
no |
project_id | Google Cloud project ID | string |
"" |
no |
recovery_window_aws_secret | Number of days that AWS Secrets Manager will wait before deleting a secret. This value can be set to 0 to force immediate deletion, or to a value between 7 and 30 days to allow for recovery. | number |
0 |
no |
resource_group_location | Azure region | string |
"East US" |
no |
resource_group_name | Azure Resource Group name | string |
"" |
no |
root_password | Root password for MongoDB | string |
"" |
no |
service_account_backup | Service account for backup (GCP) | string |
"" |
no |
service_account_restore | Service account for restore (GCP) | string |
"" |
no |
Name | Description |
---|---|
mongodb_credential | MongoDB credentials used for accessing the MongoDB database. |
mongodb_endpoints | MongoDB endpoints in the Kubernetes cluster. |
To report an issue with a project:
Apache License, Version 2.0, January 2004 (http://www.apache.org/licenses/).
To support a GitHub project by liking it, you can follow these steps:
Visit the repository: Navigate to the GitHub repository.
Click the "Star" button: On the repository page, you'll see a "Star" button in the upper right corner. Clicking on it will star the repository, indicating your support for the project.
Optionally, you can also leave a comment on the repository or open an issue to give feedback or suggest changes.
Starring a repository on GitHub is a simple way to show your support and appreciation for the project. It also helps to increase the visibility of the project and make it more discoverable to others.
We believe that the key to success in the digital age is the ability to deliver value quickly and reliably. That’s why we offer a comprehensive range of DevOps & Cloud services designed to help your organization optimize its systems & Processes for speed and agility.
We provide support on all of our projects, no matter how small or large they may be.
To find more information about our company, visit squareops.com, follow us on Linkedin, or fill out a job application. If you have any questions or would like assistance with your cloud strategy and implementation, please don't hesitate to contact us.