Skip to content

Commit

Permalink
Dbp 817 implement ha mariadb cluster privacyidea (#26)
Browse files Browse the repository at this point in the history
* DBP-817-add ionos-mariadb-cluster module

* DBP-817-create mariadb_lan

* DBP-817-correct naming conventions:lan_mariadb

* terraform-docs: automated action

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
sahassou and github-actions[bot] authored May 27, 2024
1 parent 64bd8c0 commit 054af4a
Show file tree
Hide file tree
Showing 11 changed files with 189 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/ionos-datacenter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ No modules.
| <a name="input_create_alb_target_lan"></a> [create\_alb\_target\_lan](#input\_create\_alb\_target\_lan) | Specifies whether a private target for the Application Load Balancer shall be created. | `bool` | `false` | no |
| <a name="input_create_backend_crossconnect"></a> [create\_backend\_crossconnect](#input\_create\_backend\_crossconnect) | Specifies whether crossconnect shall be created. Default: false. | `bool` | `false` | no |
| <a name="input_create_frontend_crossconnect"></a> [create\_frontend\_crossconnect](#input\_create\_frontend\_crossconnect) | Specifies whether crossconnect shall be created. Default: false. | `bool` | `false` | no |
| <a name="input_create_mariadb_lan"></a> [create\_mariadb\_lan](#input\_create\_mariadb\_lan) | Specifies whether a private lan to connect Mariadb shall be created. | `bool` | `false` | no |
| <a name="input_create_nat_lan"></a> [create\_nat\_lan](#input\_create\_nat\_lan) | Specifies whether a private lan to connect a NAT gateway shall be created. | `bool` | `false` | no |
| <a name="input_create_nfs_server_lan"></a> [create\_nfs\_server\_lan](#input\_create\_nfs\_server\_lan) | Specifies whether a private lan to connect an NFS server shall be created. | `bool` | `false` | no |
| <a name="input_create_nlb_target_lan"></a> [create\_nlb\_target\_lan](#input\_create\_nlb\_target\_lan) | Specifies whether a private target for the Network Load Balancer shall be created. | `bool` | `false` | no |
Expand All @@ -45,12 +46,14 @@ No modules.
| <a name="output_lan_alb_target"></a> [lan\_alb\_target](#output\_lan\_alb\_target) | n/a |
| <a name="output_lan_backend"></a> [lan\_backend](#output\_lan\_backend) | n/a |
| <a name="output_lan_frontend"></a> [lan\_frontend](#output\_lan\_frontend) | n/a |
| <a name="output_lan_mariadb"></a> [lan\_mariadb](#output\_lan\_mariadb) | n/a |
| <a name="output_lan_nat"></a> [lan\_nat](#output\_lan\_nat) | n/a |
| <a name="output_lan_nfs_server"></a> [lan\_nfs\_server](#output\_lan\_nfs\_server) | n/a |
| <a name="output_lan_nlb_target"></a> [lan\_nlb\_target](#output\_lan\_nlb\_target) | n/a |
| <a name="output_lan_postgres"></a> [lan\_postgres](#output\_lan\_postgres) | n/a |
| <a name="output_lan_service"></a> [lan\_service](#output\_lan\_service) | n/a |
| <a name="output_lans_custom"></a> [lans\_custom](#output\_lans\_custom) | n/a |
| <a name="output_mariadb_lan_id"></a> [mariadb\_lan\_id](#output\_mariadb\_lan\_id) | n/a |
| <a name="output_nat_lan_id"></a> [nat\_lan\_id](#output\_nat\_lan\_id) | n/a |
| <a name="output_nfs_server_lan_id"></a> [nfs\_server\_lan\_id](#output\_nfs\_server\_lan\_id) | n/a |
| <a name="output_nlb_target_lan_id"></a> [nlb\_target\_lan\_id](#output\_nlb\_target\_lan\_id) | n/a |
Expand All @@ -71,6 +74,7 @@ No modules.
| [ionoscloud_lan.backend_lan](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.3.6/docs/resources/lan) | resource |
| [ionoscloud_lan.custom_lan](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.3.6/docs/resources/lan) | resource |
| [ionoscloud_lan.frontend_lan](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.3.6/docs/resources/lan) | resource |
| [ionoscloud_lan.mariadb_lan](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.3.6/docs/resources/lan) | resource |
| [ionoscloud_lan.nat_lan](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.3.6/docs/resources/lan) | resource |
| [ionoscloud_lan.nfs_server_lan](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.3.6/docs/resources/lan) | resource |
| [ionoscloud_lan.nlb_target_lan](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.3.6/docs/resources/lan) | resource |
Expand Down
2 changes: 2 additions & 0 deletions modules/ionos-datacenter/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ locals {
service_crossconnect_shared_group_ids = (length(var.crossconnect_shared_group_ids) > 0 && local.create_frontend_crossconnect == true) ? var.crossconnect_shared_group_ids : []
routes_map = var.routes_map
create_postgres_lan = var.create_postgres_lan
create_mariadb_lan = var.create_mariadb_lan
custom_lans_to_create = var.custom_lans_to_create
# this saves the service/backend/frontend lans as an object in a list
# Example of an object:
Expand All @@ -34,6 +35,7 @@ locals {
lan_frontend = flatten([ for id in ionoscloud_lan.frontend_lan.*.id: { id = id, routes_list = lookup(local.routes_map, id , [{}]) }])
lan_nfs_server = flatten([ for id in ionoscloud_lan.nfs_server_lan.*.id: { id = id, routes_list = [{}] }])
lan_postgres = flatten([ for id in ionoscloud_lan.postgres_lan.*.id: { id = id, routes_list = [{}] }])
lan_mariadb = flatten([ for id in ionoscloud_lan.mariadb_lan.*.id: { id = id, routes_list = [{}] }])
lan_alb_target = flatten([ for id in ionoscloud_lan.alb_target_lan.*.id: { id = id, routes_list =[{}] }])
lan_nlb_target = flatten([ for id in ionoscloud_lan.nlb_target_lan.*.id: { id = id, routes_list =[{}] }])
lan_nat = flatten([ for id in ionoscloud_lan.nat_lan.*.id: { id = id, routes_list = [{}] }])
Expand Down
7 changes: 7 additions & 0 deletions modules/ionos-datacenter/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ resource "ionoscloud_lan" "postgres_lan" {
public = false
}

resource "ionoscloud_lan" "mariadb_lan" {
count = local.create_mariadb_lan ? 1 : 0
name = "${var.datacenter_name}-mariadb-lan"
datacenter_id = ionoscloud_datacenter.datacenter.id
public = false
}

resource "ionoscloud_lan" "alb_target_lan" {
count = local.create_alb_target_lan ? 1 : 0
name = "${var.datacenter_name}-alb-target-lan"
Expand Down
8 changes: 8 additions & 0 deletions modules/ionos-datacenter/output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ output "lan_postgres" {
value = local.lan_postgres
}

output "mariadb_lan_id" {
value = join("", ionoscloud_lan.mariadb_lan.*.id)
}

output "lan_mariadb" {
value = local.lan_mariadb
}

output "alb_target_lan_id" {
value = join("", ionoscloud_lan.alb_target_lan.*.id)
}
Expand Down
5 changes: 5 additions & 0 deletions modules/ionos-datacenter/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ variable "create_postgres_lan" {
type = bool
default = false
}
variable "create_mariadb_lan" {
description = "Specifies whether a private lan to connect Mariadb shall be created."
type = bool
default = false
}

variable "create_alb_target_lan" {
type = bool
Expand Down
48 changes: 48 additions & 0 deletions modules/ionos-mariadb-cluster/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!-- BEGIN_TF_DOCS -->

## Providers

| Name | Version |
|------|---------|
| <a name="provider_ionoscloud"></a> [ionoscloud](#provider\_ionoscloud) | 6.3.6 |
## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_cidr_workaround"></a> [cidr\_workaround](#module\_cidr\_workaround) | ../../modules/ionos-cidr-workaround | n/a |
## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_cores"></a> [cores](#input\_cores) | The number of CPU cores per instance | `number` | n/a | yes |
| <a name="input_datacenter_id"></a> [datacenter\_id](#input\_datacenter\_id) | The datacenter to connect your cluster to. | `string` | n/a | yes |
| <a name="input_display_name"></a> [display\_name](#input\_display\_name) | The friendly name of your cluster | `string` | n/a | yes |
| <a name="input_instances_count"></a> [instances\_count](#input\_instances\_count) | The total number of instances in the cluster (one primary and n-1 secondary) | `number` | n/a | yes |
| <a name="input_k8s_cluster_id"></a> [k8s\_cluster\_id](#input\_k8s\_cluster\_id) | n/a | `string` | n/a | yes |
| <a name="input_lan_id"></a> [lan\_id](#input\_lan\_id) | The LAN to connect your cluster to. | `string` | n/a | yes |
| <a name="input_mariadb_version"></a> [mariadb\_version](#input\_mariadb\_version) | The MariaDB version of your cluster | `string` | n/a | yes |
| <a name="input_memory"></a> [memory](#input\_memory) | The amount of memory per instance in gigabytes (GB) | `number` | n/a | yes |
| <a name="input_password"></a> [password](#input\_password) | The password for the initial MariaDB user | `string` | n/a | yes |
| <a name="input_username"></a> [username](#input\_username) | The username for the initial MariaDB user | `string` | n/a | yes |
| <a name="input_volume_size"></a> [volume\_size](#input\_volume\_size) | The amount of storage per instance in gigabytes (GB) | `number` | n/a | yes |
| <a name="input_ip_block"></a> [ip\_block](#input\_ip\_block) | The number to be set in the last ip block. (Default: 101) | `number` | `101` | no |
| <a name="input_maintenance_day"></a> [maintenance\_day](#input\_maintenance\_day) | The day of the week for the 4 hour-long maintenance window. (Default: Sunday) | `string` | `"Sunday"` | no |
| <a name="input_maintenance_hour"></a> [maintenance\_hour](#input\_maintenance\_hour) | The time of the day when the 4 hour-long maintenance window may start. (Default: 3) | `number` | `3` | no |
| <a name="input_subnet_mask"></a> [subnet\_mask](#input\_subnet\_mask) | The subnet mask to use for allowing connections from the LAN. (Default: 16) | `string` | `16` | no |
## Outputs

| Name | Description |
|------|-------------|
| <a name="output_dns_name"></a> [dns\_name](#output\_dns\_name) | The DNS name pointing to your cluster. |
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13 |
| <a name="requirement_ionoscloud"></a> [ionoscloud](#requirement\_ionoscloud) | 6.3.6 |
## Resources

| Name | Type |
|------|------|
| [ionoscloud_mariadb_cluster.mariadb_cluster](https://registry.terraform.io/providers/ionos-cloud/ionoscloud/6.3.6/docs/resources/mariadb_cluster) | resource |
<!-- END_TF_DOCS -->
12 changes: 12 additions & 0 deletions modules/ionos-mariadb-cluster/cidr-workaround.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module "cidr_workaround" {
source = "../../modules/ionos-cidr-workaround"
k8s_cluster_id = var.k8s_cluster_id
lan_id = var.lan_id
}

locals {
nicIndex = module.cidr_workaround.nicIndex
prefix = module.cidr_workaround.prefix
full_ip = cidrhost(local.prefix, var.ip_block)
cidr = format("%s/%s", local.full_ip, var.subnet_mask)
}
25 changes: 25 additions & 0 deletions modules/ionos-mariadb-cluster/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
resource "ionoscloud_mariadb_cluster" "mariadb_cluster" {
mariadb_version = var.mariadb_version
instances = var.instances_count
cores = var.cores
ram = var.memory
storage_size = var.volume_size

connections {
datacenter_id = var.datacenter_id
lan_id = var.lan_id
cidr = local.cidr
}
display_name = var.display_name

maintenance_window {
day_of_the_week = var.maintenance_day
time = format("%02d:00:00", var.maintenance_hour)
}

credentials {
username = var.username
password = var.password
}

}
4 changes: 4 additions & 0 deletions modules/ionos-mariadb-cluster/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "dns_name" {
description = "The DNS name pointing to your cluster."
value = ionoscloud_mariadb_cluster.mariadb_cluster.dns_name
}
65 changes: 65 additions & 0 deletions modules/ionos-mariadb-cluster/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
variable "mariadb_version" {
description = "The MariaDB version of your cluster"
type = string
}
variable "instances_count" {
description = "The total number of instances in the cluster (one primary and n-1 secondary)"
type = number
}
variable "cores" {
description = "The number of CPU cores per instance"
type = number
}
variable "memory" {
description = "The amount of memory per instance in gigabytes (GB)"
type = number
}
variable "volume_size" {
description = "The amount of storage per instance in gigabytes (GB)"
type = number
}
variable "display_name" {
description = "The friendly name of your cluster"
type = string
}
variable "maintenance_day" {
description = "The day of the week for the 4 hour-long maintenance window. (Default: Sunday)"
type = string
default = "Sunday"
}
variable "maintenance_hour" {
description = "The time of the day when the 4 hour-long maintenance window may start. (Default: 3)"
type = number
default = 3
}

variable "username" {
description = "The username for the initial MariaDB user"
type = string
}
variable "password" {
description = "The password for the initial MariaDB user"
type = string
}
variable "k8s_cluster_id" {
description = ""
type = string
}
variable "lan_id" {
description = "The LAN to connect your cluster to."
type = string
}
variable "datacenter_id" {
description = "The datacenter to connect your cluster to."
type = string
}
variable "ip_block" {
description = "The number to be set in the last ip block. (Default: 101)"
type = number
default = 101
}
variable "subnet_mask" {
description = "The subnet mask to use for allowing connections from the LAN. (Default: 16)"
type = string
default = 16
}
9 changes: 9 additions & 0 deletions modules/ionos-mariadb-cluster/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
terraform {
required_providers {
ionoscloud = {
source = "ionos-cloud/ionoscloud"
version = "6.3.6"
}
}
required_version = ">= 0.13"
}

0 comments on commit 054af4a

Please sign in to comment.