diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 942a65e41..96a46cd32 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,7 +9,7 @@ concurrency: on: pull_request: schedule: - - cron: '53 0 * * *' # Daily at 00:53 UTC + - cron: "53 0 * * *" # Daily at 00:53 UTC # Triggered on push to branch "main" by .github/workflows/release.yaml workflow_call: outputs: @@ -37,7 +37,7 @@ jobs: - name: Check libs uses: canonical/charming-actions/check-libraries@2.6.2 with: - charmcraft-channel: latest/candidate # TODO: remove after charmcraft 3.3 stable release + charmcraft-channel: latest/candidate # TODO: remove after charmcraft 3.3 stable release credentials: ${{ secrets.CHARMHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }} use-labels: false @@ -76,7 +76,7 @@ jobs: terraform fmt terraform validate - name: lint test charm module - working-directory: ./terraform/tests + working-directory: ./terraform/modules run: | terraform init terraform fmt @@ -116,7 +116,7 @@ jobs: - tests/integration/ha_tests/application_charm - tests/integration/relation_tests/application-charm with: - charmcraft-snap-channel: latest/candidate # TODO: remove after charmcraft 3.3 stable release + charmcraft-snap-channel: latest/candidate # TODO: remove after charmcraft 3.3 stable release path-to-charm-directory: ${{ matrix.path }} integration-test: @@ -129,8 +129,8 @@ jobs: with: artifact-prefix: ${{ needs.build.outputs.artifact-prefix }} cloud: microk8s - microk8s-snap-channel: 1.29-strict/stable # renovate: latest microk8s - juju-agent-version: 3.6.1 # renovate: juju-agent-pin-minor + microk8s-snap-channel: 1.29-strict/stable # renovate: latest microk8s + juju-agent-version: 3.6.1 # renovate: juju-agent-pin-minor _beta_allure_report: true permissions: contents: write # Needed for Allure Report beta diff --git a/terraform/tests/preamble.tf b/terraform/modules/replica_set_module/preamble.tf similarity index 74% rename from terraform/tests/preamble.tf rename to terraform/modules/replica_set_module/preamble.tf index 5c0f8cb8d..cef81c628 100644 --- a/terraform/tests/preamble.tf +++ b/terraform/modules/replica_set_module/preamble.tf @@ -23,3 +23,12 @@ resource "juju_application" "data-integrator" { model = var.model_name depends_on = [null_resource.preamble] } + +resource "juju_application" "s3-integrator" { + charm { + name = "s3-integrator" + channel = "latest/stable" + } + model = var.model_name + depends_on = [null_resource.preamble] +} diff --git a/terraform/tests/providers.tf b/terraform/modules/replica_set_module/providers.tf similarity index 100% rename from terraform/tests/providers.tf rename to terraform/modules/replica_set_module/providers.tf diff --git a/terraform/tests/simple_deployment.tf b/terraform/modules/replica_set_module/simple_deployment.tf similarity index 58% rename from terraform/tests/simple_deployment.tf rename to terraform/modules/replica_set_module/simple_deployment.tf index 7b07c377a..871ecbe62 100644 --- a/terraform/tests/simple_deployment.tf +++ b/terraform/modules/replica_set_module/simple_deployment.tf @@ -6,7 +6,7 @@ module "mongodb-k8s" { channel = "6/edge" } -resource "juju_integration" "simple_deployment_tls-operator_mongodb-integration" { +resource "juju_integration" "tls-operator_mongodb-integration" { model = var.model_name application { @@ -22,7 +22,7 @@ resource "juju_integration" "simple_deployment_tls-operator_mongodb-integration" } -resource "juju_integration" "simple_deployment_data-integrator_mongodb-integration" { +resource "juju_integration" "data-integrator_mongodb-integration" { model = var.model_name application { @@ -38,12 +38,29 @@ resource "juju_integration" "simple_deployment_data-integrator_mongodb-integrati } -resource "null_resource" "simple_deployment_juju_wait_deployment" { +resource "juju_integration" "s3-integrator_mongodb-integration" { + model = var.model_name + + application { + name = juju_application.s3-integrator.name + } + application { + name = var.app_name + } + depends_on = [ + juju_application.s3-integrator, + module.mongodb-k8s + ] + +} + + +resource "null_resource" "juju_wait_deployment" { provisioner "local-exec" { command = <<-EOT juju-wait -v --model ${var.model_name} EOT } - depends_on = [juju_integration.simple_deployment_tls-operator_mongodb-integration] + depends_on = [juju_integration.tls-operator_mongodb-integration] } diff --git a/terraform/tests/variables.tf b/terraform/modules/replica_set_module/variables.tf similarity index 88% rename from terraform/tests/variables.tf rename to terraform/modules/replica_set_module/variables.tf index 57e5c86cd..5867f0611 100644 --- a/terraform/tests/variables.tf +++ b/terraform/modules/replica_set_module/variables.tf @@ -4,7 +4,7 @@ variable "model_name" { } variable "app_name" { - description = "MongoDB app name" + description = "mongodb app name" type = string default = "mongodb-k8s" } diff --git a/terraform/modules/sharded_module/.terraform.lock.hcl b/terraform/modules/sharded_module/.terraform.lock.hcl new file mode 100644 index 000000000..1a48a97c1 --- /dev/null +++ b/terraform/modules/sharded_module/.terraform.lock.hcl @@ -0,0 +1,74 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/external" { + version = "2.3.4" + constraints = "~> 2.3.4" + hashes = [ + "h1:XWkRZOLKMjci9/JAtE8X8fWOt7A4u+9mgXSUjc4Wuyo=", + "zh:037fd82cd86227359bc010672cd174235e2d337601d4686f526d0f53c87447cb", + "zh:0ea1db63d6173d01f2fa8eb8989f0809a55135a0d8d424b08ba5dabad73095fa", + "zh:17a4d0a306566f2e45778fbac48744b6fd9c958aaa359e79f144c6358cb93af0", + "zh:298e5408ab17fd2e90d2cd6d406c6d02344fe610de5b7dae943a58b958e76691", + "zh:38ecfd29ee0785fd93164812dcbe0664ebbe5417473f3b2658087ca5a0286ecb", + "zh:59f6a6f31acf66f4ea3667a555a70eba5d406c6e6d93c2c641b81d63261eeace", + "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", + "zh:ad0279dfd09d713db0c18469f585e58d04748ca72d9ada83883492e0dd13bd58", + "zh:c69f66fd21f5e2c8ecf7ca68d9091c40f19ad913aef21e3ce23836e91b8cbb5f", + "zh:d4a56f8c48aa86fc8e0c233d56850f5783f322d6336f3bf1916e293246b6b5d4", + "zh:f2b394ebd4af33f343835517e80fc876f79361f4688220833bc3c77655dd2202", + "zh:f31982f29f12834e5d21e010856eddd19d59cd8f449adf470655bfd19354377e", + ] +} + +provider "registry.terraform.io/hashicorp/http" { + version = "3.4.5" + constraints = "~> 3.4.5" + hashes = [ + "h1:ceAVZEuaQd7jQX13qf5w7hy3ioiXpuwUaaDRsnAiMLM=", + "zh:2072006c177efc101471f3d5eb8e1d8e6c68778cbfd6db3d3f22f59cfe6ce6ae", + "zh:3ac4cc0efe11ee054300769cfcc37491433937a8824621d1f8f7a18e7401da87", + "zh:63997e5457c9ddf9cfff17bd7bf9f083cbeff3105452045662109dd6be499ef9", + "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", + "zh:826819bb8ab7d6e3095f597083d5b1ab93d1854312b9e1b6c18288fff9664f34", + "zh:8ad74e7d8ec2e226a73d49c7c317108f61a4cb803972fb3f945d1709d5115fcd", + "zh:a609ca9e0c91d250ac80295e39d5f524e8c0872d33ba8fde3c3e41893b4b015d", + "zh:ae07d19babc452f63f6a6511b944990e819dc20687b6c8f01d1676812f5ada53", + "zh:b7c827dc32a1a5d77185a78cd391b01217894b384f58169f98a96d683730d8ce", + "zh:d045e3db9f5e39ce78860d3fd94e04604fcbe246f6fe346ee50a971f936e9ccd", + "zh:ec28f9b52c74edd47eebbb5c254a6df5706360cde5ccd65097976efca23a2977", + "zh:f24982eaa7d34fd66554c3cf94873713a0dff14da9ea4c4be0cc76f1a6146d59", + ] +} + +provider "registry.terraform.io/hashicorp/null" { + version = "3.2.3" + hashes = [ + "h1:+AnORRgFbRO6qqcfaQyeX80W0eX3VmjadjnUFUJTiXo=", + "zh:22d062e5278d872fe7aed834f5577ba0a5afe34a3bdac2b81f828d8d3e6706d2", + "zh:23dead00493ad863729495dc212fd6c29b8293e707b055ce5ba21ee453ce552d", + "zh:28299accf21763ca1ca144d8f660688d7c2ad0b105b7202554ca60b02a3856d3", + "zh:55c9e8a9ac25a7652df8c51a8a9a422bd67d784061b1de2dc9fe6c3cb4e77f2f", + "zh:756586535d11698a216291c06b9ed8a5cc6a4ec43eee1ee09ecd5c6a9e297ac1", + "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", + "zh:9d5eea62fdb587eeb96a8c4d782459f4e6b73baeece4d04b4a40e44faaee9301", + "zh:a6355f596a3fb8fc85c2fb054ab14e722991533f87f928e7169a486462c74670", + "zh:b5a65a789cff4ada58a5baffc76cb9767dc26ec6b45c00d2ec8b1b027f6db4ed", + "zh:db5ab669cf11d0e9f81dc380a6fdfcac437aea3d69109c7aef1a5426639d2d65", + "zh:de655d251c470197bcbb5ac45d289595295acb8f829f6c781d4a75c8c8b7c7dd", + "zh:f5c68199f2e6076bce92a12230434782bf768103a427e9bb9abee99b116af7b5", + ] +} + +provider "registry.terraform.io/juju/juju" { + version = "0.14.0" + constraints = "~> 0.14.0" + hashes = [ + "h1:iDpK9SR44XlKQS5s2fTp8s4uPMyqQXbWLViOKtkrw2U=", + "zh:1c6a4100537404e2b4e13fa46fc572ce8d43e19ed520c6062b4520fa4e127829", + "zh:753ad16d007180a77a147bd377de2fb334f409123f6fee36d4c50c7fe8b76a29", + "zh:7572a8915061fe29ccc3d229504e58f97d2c68efd7a24de940e53e88810aeb2a", + "zh:79866c449c3b1eae188333e48c2d9a30278650ffdae701b9f5a32d89c03d66e6", + "zh:db95f7cfc6f722d05c07bdbc077733e658af411621a754dd888630bc2e1a1f4d", + ] +} diff --git a/terraform/modules/sharded_module/preamble.tf b/terraform/modules/sharded_module/preamble.tf new file mode 100644 index 000000000..d100f7aed --- /dev/null +++ b/terraform/modules/sharded_module/preamble.tf @@ -0,0 +1,43 @@ +resource "null_resource" "preamble" { + provisioner "local-exec" { + command = <<-EOT + sudo snap install juju-wait --classic || true + EOT + } +} + +resource "juju_application" "self-signed-certificates" { + charm { + name = "self-signed-certificates" + channel = "latest/stable" + } + model = var.model_name + depends_on = [null_resource.preamble] +} + +resource "juju_application" "data-integrator" { + charm { + name = "data-integrator" + channel = "latest/stable" + } + model = var.model_name + depends_on = [null_resource.preamble] +} + +resource "juju_application" "s3-integrator" { + charm { + name = "s3-integrator" + channel = "latest/stable" + } + model = var.model_name + depends_on = [null_resource.preamble] +} + +resource "juju_application" "mongos-k8s" { + charm { + name = "mongos-k8s" + channel = "6/stable" + } + model = var.model_name + depends_on = [null_resource.preamble] +} \ No newline at end of file diff --git a/terraform/modules/sharded_module/providers.tf b/terraform/modules/sharded_module/providers.tf new file mode 100644 index 000000000..3be3d8566 --- /dev/null +++ b/terraform/modules/sharded_module/providers.tf @@ -0,0 +1,16 @@ +terraform { + required_providers { + juju = { + source = "juju/juju" + version = "~> 0.14.0" + } + http = { + source = "hashicorp/http" + version = "~> 3.4.5" + } + external = { + source = "hashicorp/external" + version = "~> 2.3.4" + } + } +} diff --git a/terraform/modules/sharded_module/simple_deployment.tf b/terraform/modules/sharded_module/simple_deployment.tf new file mode 100644 index 000000000..3ef2725b8 --- /dev/null +++ b/terraform/modules/sharded_module/simple_deployment.tf @@ -0,0 +1,146 @@ +locals { + mongodb_apps = { + "config-server" = { + app_name = var.config_server_app_name + units = var.config_server_units + role = "config-server" + } + "shard-one" = { + app_name = var.shard_one_app_name + units = var.shard_one_units + role = "shard" + } + "shard-two" = { + app_name = var.shard_two_app_name + units = var.shard_two_units + role = "shard" + } + } +} + +module "mongodb-k8s" { + for_each = local.mongodb_apps + source = "../../" + app_name = each.value.app_name + model = var.model_name + units = each.value.units + channel = "6/edge" + config = { + role = each.key + } +} + + +resource "juju_integration" "data-integrator_mongos-integration" { + model = var.model_name + + application { + name = juju_application.data-integrator.name + } + application { + name = juju_application.mongos-k8s.name + } + depends_on = [ + juju_application.data-integrator, + juju_application.mongos-k8s + ] + +} + +resource "juju_integration" "config-server_integrations" { + for_each = tomap({ + "shard-one" = { + app_name = var.shard_one_app_name + } + "shard-two" = { + app_name = var.shard_two_app_name + } + }) + + model = var.model_name + + application { + name = var.config_server_app_name + endpoint = "config-server" + } + + application { + name = each.value.app_name + endpoint = "sharding" + } + + depends_on = [ + module.mongodb-k8s, + ] +} + +resource "juju_integration" "mongodb_mongos-integration" { + model = var.model_name + + application { + name = juju_application.mongos-k8s.name + } + application { + name = var.config_server_app_name + } + depends_on = [ + juju_application.mongos-k8s, + module.mongodb-k8s, + juju_integration.data-integrator_mongos-integration + ] + +} + +resource "juju_integration" "tls-operator_mongodb-integration" { + for_each = merge( + local.mongodb_apps, + { + "mongos-k8s" = { + app_name = "mongos-k8s" + units = 1 + } + } + ) + + model = var.model_name + + application { + name = juju_application.self-signed-certificates.name + } + + application { + name = each.value.app_name + } + + depends_on = [ + juju_application.self-signed-certificates, + juju_integration.mongodb_mongos-integration, + juju_integration.config-server_integrations + ] +} + +resource "juju_integration" "s3-integrator_mongodb-integration" { + model = var.model_name + + application { + name = juju_application.s3-integrator.name + } + application { + name = var.config_server_app_name + } + depends_on = [ + juju_application.s3-integrator, + juju_integration.config-server_integrations, + ] + +} + +resource "null_resource" "juju_wait_deployment" { + provisioner "local-exec" { + command = <<-EOT + juju-wait -v --model ${var.model_name} + EOT + } + + depends_on = [juju_integration.tls-operator_mongodb-integration] +} diff --git a/terraform/modules/sharded_module/variables.tf b/terraform/modules/sharded_module/variables.tf new file mode 100644 index 000000000..e2849c84c --- /dev/null +++ b/terraform/modules/sharded_module/variables.tf @@ -0,0 +1,40 @@ +variable "model_name" { + description = "Model name" + type = string +} + +variable "config_server_app_name" { + description = "mongodb app name" + type = string + default = "config-server" +} + +variable "config_server_units" { + description = "Node count" + type = number + default = 1 +} + +variable "shard_one_app_name" { + description = "mongodb app name" + type = string + default = "shard-one" +} + +variable "shard_one_units" { + description = "Node count" + type = number + default = 1 +} + +variable "shard_two_app_name" { + description = "mongodb app name" + type = string + default = "shard-two" +} + +variable "shard_two_units" { + description = "Node count" + type = number + default = 1 +} \ No newline at end of file