MongoDB

On-premise MongoDB deployment using Percona’s MongoDB Operator. Covering both sharded and unsharded deployments.

Requirements

Name

Version

terraform

>= 1.0

helm

>= 2.10.1, < 3.0.0

kubectl

>=1.14.0

kubernetes

>= 2.21.1

local

>= 2.4.0

random

>= 3.5.1

tls

>= 4.0.0

Providers

Name

Version

helm

>= 2.10.1, < 3.0.0

kubectl

>=1.14.0

kubernetes

>= 2.21.1

local

>= 2.4.0

random

>= 3.5.1

tls

>= 4.0.0

Modules

No modules.

Resources

Name

Type

helm_release.operator

resource

kubectl_manifest.cluster

resource

kubernetes_job.wait_for_percona

resource

kubernetes_secret.application_user_password

resource

kubernetes_secret.mongodb_connection_string

resource

kubernetes_secret.mongodb_monitoring_connection_string

resource

kubernetes_secret.ssl

resource

kubernetes_secret.ssl_internal

resource

kubernetes_storage_class.configsvr

resource

kubernetes_storage_class.shards

resource

local_sensitive_file.mongodb_client_certificate

resource

random_password.app_user_password

resource

tls_cert_request.internal

resource

tls_cert_request.server

resource

tls_locally_signed_cert.internal

resource

tls_locally_signed_cert.server

resource

tls_private_key.ca

resource

tls_private_key.internal

resource

tls_private_key.server

resource

tls_self_signed_cert.ca

resource

kubernetes_secret.percona_cluster_secrets

data source

Inputs

Name

Description

Type

Default

Required

cluster

Parameters for the Percona Server for MongoDB cluster

object({
image = optional(string, “percona/percona-server-mongodb”)
tag = optional(string)
database_name = optional(string, “database”)
replicas = optional(number, 1)
node_selector = optional(map(string), {})
annotations = optional(map(string), {})
})

{}

no

name

Name used for the helm chart release and the associated resources

string

"percona-mongodb"

no

namespace

Namespace of ArmoniK resources

string

"default"

no

operator

Parameters for the Percona PSMDB Operator deployment

object({
helm_chart_repository = optional(string, “https://percona.github.io/percona-helm-charts/”)
helm_chart_name = optional(string, “psmdb-operator”)
helm_chart_version = optional(string)
image = optional(string, “percona/percona-server-mongodb-operator”)
tag = optional(string)
node_selector = optional(map(string), {})
annotations = optional(map(string), {})
})

{}

no

persistence

Persistence parameters for MongoDB pods

object({
shards = optional(object({
mount_options = optional(string)
storage_size = optional(string, “8Gi”)
storage_class_name = optional(string) # Use existing StorageClass
storage_provisioner = optional(string) # Or create one
reclaim_policy = optional(string, “Delete”)
volume_binding_mode = optional(string, “WaitForFirstConsumer”)
access_modes = optional(list(string), [“ReadWriteOnce”])
parameters = optional(map(string), {})
}), {})

configsvr = optional(object({
mount_options = optional(string)
storage_size = optional(string, “3Gi”)
storage_class_name = optional(string)
storage_provisioner = optional(string)
reclaim_policy = optional(string, “Delete”)
volume_binding_mode = optional(string, “WaitForFirstConsumer”)
access_modes = optional(list(string), [“ReadWriteOnce”])
parameters = optional(map(string), {})
}), {})
})

null

no

resources

Resource requests and limits per component

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

{}

no

sharding

Sharding configuration. Set to null to disable sharding.

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

null

no

timeout

Timeout in seconds for the helm release creation

number

600

no

tls

TLS configuration for the Percona MongoDB cluster.

self_managed – When true (default), Terraform generates the CA and server
certificates using the tls provider and pre-creates
the ssl / ssl-internal Kubernetes secrets. The
Percona operator then uses those secrets directly
without invoking cert-manager.
When false, the operator delegates
certificate generation to cert-manager; cert-manager
must therefore be installed in the cluster.

validity_period_hours – Lifetime of the generated certificates in hours.
Only relevant when self_managed = true.
Defaults to 8760h (1 year).

object({
self_managed = optional(bool, true)
validity_period_hours = optional(number, 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 in the MongoDB replica set

port

Port of MongoDB server

url

URL of MongoDB server

user_credentials

User credentials of MongoDB