MongoDB Sharded

MongoDB sharded cluster deployment for horizontal scaling and high availability.

Requirements

Name

Version

terraform

>= 1.3

helm

>= 2.10.1, < 3.0.0

kubernetes

>= 2.21.1

local

>= 2.4.0

random

>= 3.5.1

tls

>= 4.0.4

Providers

Name

Version

helm

>= 2.10.1, < 3.0.0

kubernetes

>= 2.21.1

local

>= 2.4.0

random

>= 3.5.1

tls

>= 4.0.4

Modules

No modules.

Resources

Name

Type

helm_release.mongodb

resource

kubernetes_secret.database_init_script

resource

kubernetes_secret.mongodb

resource

kubernetes_secret.mongodb_admin

resource

kubernetes_secret.mongodb_certificate

resource

kubernetes_secret.mongodb_connection_string

resource

kubernetes_secret.mongodb_monitoring_connection_string

resource

kubernetes_secret.mongodb_user

resource

kubernetes_storage_class.configsvr

resource

kubernetes_storage_class.shards

resource

local_sensitive_file.init_script_file

resource

local_sensitive_file.mongodb_client_certificate

resource

random_password.mongodb_application_password

resource

random_password.mongodb_monitoring_password

resource

random_string.mongodb_application_user

resource

random_string.mongodb_monitoring_user

resource

tls_cert_request.mongodb_cert_request

resource

tls_locally_signed_cert.mongodb_certificate

resource

tls_private_key.mongodb_private_key

resource

tls_private_key.root_mongodb

resource

tls_self_signed_cert.root_mongodb

resource

kubernetes_secret.mongodb_credentials

data source

Inputs

Name

Description

Type

Default

Required

default_labels

Default labels for the MongoDB-related Kubernetes pods

map(string)

{
“app”: “storage”,
“type”: “table”
}

no

labels

Custom labels for the different MongoDB entities

object({
shards = optional(map(string))
arbiter = optional(map(string))
configsvr = optional(map(string))
router = optional(map(string))
})

null

no

mongodb

Parameters of the MongoDB deployment

object({
database_name = optional(string, “database”)
helm_chart_repository = optional(string, “oci://registry-1.docker.io/bitnamicharts”)
helm_chart_name = optional(string, “mongodb-sharded”)
helm_chart_version = string
image = optional(string, “bitnamilegacy/mongodb-sharded”)
image_pull_secrets = optional(any, [“”]) # can be a string or a list of strings
node_selector = optional(map(string), {})
registry = optional(string)
service_port = optional(number, 27017)
tag = string
})

n/a

yes

name

Name used for the helm chart release and the associated resources, must be shorter than 54 characters

string

"mongodb-sharded"

no

namespace

Namespace of ArmoniK resources

string

"default"

no

persistence

Persistence parameters for MongoDB

object({
shards = optional(object({
access_mode = optional(list(string), [“ReadWriteOnce”])
reclaim_policy = optional(string, “Delete”)
storage_provisioner = optional(string)
volume_binding_mode = optional(string, “WaitForFirstConsumer”)
parameters = optional(map(string), {})

resources = optional(object({
limits = optional(object({
storage = string
}))
requests = optional(object({
storage = string
}))
}))
}))

configsvr = optional(object({
access_mode = optional(list(string), [“ReadWriteOnce”])
reclaim_policy = optional(string, “Delete”)
storage_provisioner = optional(string)
volume_binding_mode = optional(string, “WaitForFirstConsumer”)
parameters = optional(map(string), {})

resources = optional(object({
limits = optional(object({
storage = string
}))
requests = optional(object({
storage = string
}))
}))
}))
})

null

no

resources

Resources requests and limitations (cpu, memory, ephemeral-storage) for different types of MongoDB entities

object({
shards = optional(object({
limits = optional(map(string))
requests = optional(map(string))
}))

arbiter = optional(object({
limits = optional(map(string))
requests = optional(map(string))
}))

configsvr = optional(object({
limits = optional(map(string))
requests = optional(map(string))
}))

router = optional(object({
limits = optional(map(string))
requests = optional(map(string))
}))
})

{
“arbiter”: {},
“configsvr”: {},
“router”: {},
“shards”: {}
}

no

security_context

Security context for MongoDB pods

object({
run_as_user = number
fs_group = number
})

{
“fs_group”: 999,
“run_as_user”: 999
}

no

sharding

Parameters specific to the sharded architecture

object({
shards = optional(object({
quantity = optional(number, 2)
replicas = optional(number, 1)
node_selector = optional(map(string))
}))

arbiter = optional(object({
node_selector = optional(map(string))
}))

router = optional(object({
replicas = optional(number, 1)
node_selector = optional(map(string))
}))

configsvr = optional(object({
replicas = optional(number, 1)
node_selector = optional(map(string))
}))
})

{
“arbiter”: {},
“configsvr”: {},
“router”: {},
“shards”: {}
}

no

timeout

Timeout limit in seconds per shard for the helm release creation

number

180

no

validity_period_hours

Validity period of the TLS certificate in hours

string

"8760"

no

Outputs

Name

Description

endpoints

Endpoints of MongoDB

env

Elements to be set as environment variables

env_from_secret

Environment variables from secrets

host

Hostname or IP address of MongoDB server

mount_secret

Secrets to be mounted as volumes

number_of_replicas

Number of replicas for each shard

number_of_shards

Number of MongoDB shards

port

Port of MongoDB server

url

URL of MongoDB server

user_credentials

User credentials of MongoDB

Examples