-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cfa3ade
commit a2db87c
Showing
5 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# MongoDB Operator Terraform module | ||
|
||
This folder contains a base [Terraform][Terraform] module for the `mongodb-k8s` charm. | ||
|
||
The module uses the [Terraform Juju provider][Terraform Juju provider] to model the charm deployment onto any Kubernetes environment managed by [Juju][Juju]. | ||
|
||
The base module is not intended to be deployed in separation (it is possible though), but should rather serve as a building block for higher level modules. | ||
|
||
## Module structure | ||
|
||
- **main.tf** - Defines the Juju application to be deployed. | ||
- **variables.tf** - Allows customization of the deployment such as Juju model name, channel or application name and charm configuration. | ||
- **output.tf** - Responsible for integrating the module with other Terraform modules, primarily by defining potential integration endpoints (charm integrations), but also by exposing the application name. | ||
- **terraform.tf** - Defines the Terraform provider. | ||
|
||
## Using mongodb-k8s base module in higher level modules | ||
|
||
If you want to use `mongodb-operator` base module as part of your Terraform module, import it like shown below. | ||
|
||
```text | ||
module "mongodb-operator" { | ||
source = "git::https://github.com/canonical/mongodb-operator.git//terraform" | ||
model_name = "juju_model_name" | ||
(Customize configuration variables here if needed) | ||
} | ||
``` | ||
|
||
Please see the link to customize the Grafana configuration variables if needed. | ||
|
||
- [MongoDB configuration options][MongoDB configuration options] | ||
|
||
Create the integrations, for instance: | ||
|
||
```text | ||
resource "juju_integration" "amf-db" { | ||
model = var.model_name | ||
application { | ||
name = module.amf.app_name | ||
endpoint = module.amf.database_endpoint | ||
} | ||
application { | ||
name = module.mongodb.app_name | ||
endpoint = module.mongodb.database_endpoint | ||
} | ||
} | ||
``` | ||
|
||
Please check the available [integration pairs][integration pairs]. | ||
|
||
[Terraform]: https://www.terraform.io/ | ||
[Juju]: https://juju.is | ||
[Terraform Juju provider]: https://registry.terraform.io/providers/juju/juju/latest | ||
[MongoDB configuration options]: https://charmhub.io/mongodb-k8s/configure?channel=6/edge | ||
[integration pairs]: https://charmhub.io/mongodb-k8s/integrations?channel=6/edge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright 2024 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
|
||
resource "juju_application" "mongodb-k8s" { | ||
name = var.app_name | ||
model = var.model_name | ||
|
||
charm { | ||
name = "mongodb-k8s" | ||
channel = var.channel | ||
base = "[email protected]" | ||
} | ||
config = var.mongo-config | ||
units = 1 | ||
trust = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Copyright 2024 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
|
||
output "app_name" { | ||
description = "Name of the deployed application." | ||
value = juju_application.mongodb-k8s.name | ||
} | ||
|
||
# Provided integration endpoints | ||
|
||
output "database_endpoint" { | ||
description = "Name of the endpoint to provide the mongodb_client interface." | ||
value = "database" | ||
} | ||
|
||
output "obsolete_endpoint" { | ||
description = "Name of the endpoint to provide the mongodb interface." | ||
value = "obsolete" | ||
} | ||
|
||
output "cos_agent_endpoint" { | ||
description = "Name of the endpoint to provide the cos_agent interface." | ||
value = "cos-agent" | ||
} | ||
|
||
output "config_server_endpoint" { | ||
description = "Name of the endpoint to provide the shards interface." | ||
value = "config-server" | ||
} | ||
|
||
output "cluster_endpoint" { | ||
description = "Name of the endpoint to provide the config-server interface." | ||
value = "cluster" | ||
} | ||
|
||
# Required integration endpoints | ||
|
||
output "certificates_endpoint" { | ||
description = "Name of the endpoint to provide the tls-certificates interface." | ||
value = "certificates" | ||
} | ||
|
||
output "s3_credentials_endpoint" { | ||
description = "Name of the endpoint to provide the s3 interface." | ||
value = "s3-credentials" | ||
} | ||
|
||
output "sharding_endpoint" { | ||
description = "Name of the endpoint to provide the shards interface." | ||
value = "sharding" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Copyright 2024 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
|
||
terraform { | ||
required_providers { | ||
juju = { | ||
source = "juju/juju" | ||
version = "~> 0.10.1" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright 2024 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
|
||
variable "model_name" { | ||
description = "Name of Juju model to deploy application to" | ||
type = string | ||
default = "" | ||
} | ||
|
||
variable "app_name" { | ||
description = "Name of the application in the Juju model" | ||
type = string | ||
default = "mongodb" | ||
} | ||
|
||
variable "channel" { | ||
description = "The channel to use when deploying a charm" | ||
type = string | ||
default = "6/beta" | ||
} | ||
|
||
variable "mongo-config" { | ||
description = "Additional configuration for the MongoDB" | ||
default = {} | ||
} |