Prepare the terraform files for dev.

This commit is contained in:
Andrea Dell'Amico 2023-11-14 18:52:30 +01:00
parent 437de33c4f
commit 9c9e4bed7b
Signed by untrusted user: andrea.dellamico
GPG Key ID: 147ABE6CEB9E20FF
26 changed files with 491 additions and 26 deletions

View File

@ -60,12 +60,12 @@ locals {
}
resource "openstack_dns_recordset_v2" "acme_challenge_recordset" {
zone_id = var.dns_zone_id
zone_id = openstack_dns_zone_v2.primary_project_dns_zone.id
name = local.acme_challenge_recordset_name
description = "ACME challenge delegation"
ttl = 8600
type = "CNAME"
records = [local.acme_challenge_delegation]
records = ["_acme-challenge.d4science.net."]
}
output "main_private_network_id" {

View File

@ -0,0 +1 @@
../../common_variables/00-terraform-provider.tf

View File

@ -0,0 +1 @@
../variables/00-variables.tf

View File

@ -0,0 +1 @@
../../common_variables/01-external-network-and-resolvers.tf

View File

@ -0,0 +1 @@
../../common_variables/05-projects-and-users-vars.tf

View File

@ -0,0 +1 @@
../../common_setups/15-security-groups.tf

View File

@ -0,0 +1 @@
../../common_setups/20-octavia.tf

View File

@ -0,0 +1 @@
../../common_setups/25-ssh-jump-proxy.tf

View File

@ -0,0 +1 @@
../../common_setups/30-internal-ca.tf

View File

@ -0,0 +1 @@
../../common_setups/35-prometheus.tf

View File

@ -0,0 +1 @@
../../common_setups/40-postgresql.tf

View File

@ -0,0 +1 @@
../../common_setups/45-haproxy.tf

View File

@ -0,0 +1,9 @@
# Docker Swarm
Docker Swarm cluster behind a Octavia balancer L4
* One Octavia Load balancer
* 3 VMs for the master nodes with their server group (soft anti affinity)
* 7 VMs for the worker nodes with their server group (soft anti affinity)
* 1 VM for the NFS service
* 1 dedicated network, for the traffic of the NFS exports

View File

@ -0,0 +1,11 @@
# Main services
* Load balancer as a service (openstack), L4.
> * Main Octavia load balancer
* Two VMs as HAPROXY L7 instances for the main services. The dataminers will be also served by this load balancer.
* A shell server, with floating IP address, that will be used as a proxy to reach all the other VMs.
* A internal CA service.
* A Prometheus instance.
* A PostgreSQL server instance, with a dedicated network

View File

@ -0,0 +1,33 @@
shared_postgresql_server_data = {
name ="postgresql-server"
flavor = "m1.large"
vol_data_name = "postgresql-server-data"
vol_data_size = "200"
vol_data_device = "/dev/vdb"
network_name = "postgresql-srv-net"
network_description = "Network used to communicate with the shared postgresql service"
network_cidr = "192.168.2.0/24"
allocation_pool_start = "192.168.2.10"
allocation_pool_end = "192.168.3.254"
server_ip = "192.168.2.153"
server_cidr = "192.168.2.153/22"
}
# Provided in the output of the project setup
main_private_network_id = "e0af5eba-f24a-4d0d-8184-bc654b980c4a"
main_private_subnet_id = "2aa977f2-80b4-447c-a6b0-dfa06bf68751"
dns_zone_id = "cbae638a-9d99-44aa-946c-0f5ffb7fc488"
octavia_information = {
main_lb_name = "lb-dev-l4"
main_lb_description = "Main L4 load balancer for the D4Science DEV"
octavia_flavor = "octavia_amphora-mvcpu-ha"
octavia_flavor_id = "394988b5-6603-4a1e-a939-8e177c6681c7"
main_lb_hostname = "main-lb"
# The following aren't available when the module runs so we have to get them with the command
# openstack --os-cloud d4s-pre port list -f value | grep octavia-lb-vrrp
# This means that the execution will fail
octavia_vrrp_ip_1 = "10.1.29.161/32"
octavia_vrrp_ip_2 = "10.1.30.180/32"
}

View File

@ -0,0 +1,38 @@
octavia_swarm_data = {
swarm_lb_name = "l4-swarm-dev"
swarm_lb_description = "L4 balancer that serves the D4Science DEV Docker Swarm cluster"
octavia_flavor = "octavia_amphora-mvcpu-ha"
octavia_flavor_id = "394988b5-6603-4a1e-a939-8e177c6681c7"
swarm_lb_hostname = "swarm-lb"
swarm_octavia_main_ip = "10.1.31.70"
swarm_octavia_main_cidr = "10.1.31.70/32"
# The following aren't available when the module runs so we have to get them with the command
# openstack --os-cloud d4s-pre port list -f value | grep octavia-lb-vrrp
# This means that the execution will fail
octavia_vrrp_ip_1 = "10.1.31.246/32"
octavia_vrrp_ip_2 = "10.1.31.69/32"
}
docker_swarm_data = {
mgr_name = "swarm-mgr"
mgr1_ip = "10.1.29.205"
mgr1_cidr = "10.1.29.205/32"
mgr2_ip = "10.1.30.212"
mgr2_cidr = "10.1.30.212/32"
mgr3_ip = "10.1.30.206"
mgr3_cidr = "10.1.30.206/32"
mgr_count = 3
mgr_flavor = "m1.large"
mgr_data_disk_size = 100
worker_name = "swarm-worker"
worker_count = 5
worker_flavor = "m1.xlarge"
worker_data_disk_size = 100
nfs_server_name = "swarm-nfs-server"
nfs_server_flavor = "m1.medium"
nfs_server_data_disk_name = "Swarm NFS server data Disk"
nfs_server_data_disk_size = 100
nfs_server_data_disk_device = "/dev/vdb"
}
swarm_managers_ip = ["10.1.29.205", "10.1.30.212", "10.1.30.206"]

View File

@ -0,0 +1 @@
../../docker_swarm_setup/docker-swarm.tf

View File

@ -0,0 +1,3 @@
provider "openstack" {
cloud = "d4s-dev"
}

View File

@ -0,0 +1 @@
../../docker_swarm_setup/swarm-variables.tf

View File

@ -1,20 +0,0 @@
# Configure the OpenStack Provider
provider "openstack" {
cloud = "d4s-dev"
}
variable "dns_zone" {
type = string
default = "cloud-dev.d4science.org."
}
variable "main_private_network" {
type = string
default = "d4s-dev-cloud-main"
}
variable "mtu_size" {
type = number
default = 8942
}

View File

@ -0,0 +1 @@
../variables/00-variables.tf

View File

@ -0,0 +1 @@
../../common_setups/10-main-network.tf

View File

@ -0,0 +1,5 @@
provider "openstack" {
# cloud = "d4s-dev"
cloud = "ISTI-Cloud"
}

View File

@ -0,0 +1,252 @@
{
"version": 4,
"terraform_version": "1.6.3",
"serial": 12,
"lineage": "8e064d5b-7e27-7da1-5aa2-330932157309",
"outputs": {
"dns_zone_id": {
"value": "cbae638a-9d99-44aa-946c-0f5ffb7fc488",
"type": "string"
},
"external_gateway_ip": {
"value": "146.48.31.109",
"type": "string"
},
"main_private_network_id": {
"value": "e0af5eba-f24a-4d0d-8184-bc654b980c4a",
"type": "string"
},
"main_subnet_network_id": {
"value": "2aa977f2-80b4-447c-a6b0-dfa06bf68751",
"type": "string"
}
},
"resources": [
{
"mode": "managed",
"type": "openstack_dns_recordset_v2",
"name": "acme_challenge_recordset",
"provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"description": "ACME challenge delegation",
"disable_status_check": false,
"id": "cbae638a-9d99-44aa-946c-0f5ffb7fc488/5e69d2f7-1926-4a74-b0c4-ad675975c144",
"name": "_acme-challenge.cloud-dev.d4science.org.",
"project_id": "e8f8ca72f30648a8b389b4e745ac83a9",
"records": [
"_acme-challenge.d4science.net."
],
"region": "isti_area_pi_1",
"timeouts": null,
"ttl": 8600,
"type": "CNAME",
"value_specs": null,
"zone_id": "cbae638a-9d99-44aa-946c-0f5ffb7fc488"
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwLCJ1cGRhdGUiOjYwMDAwMDAwMDAwMH19",
"dependencies": [
"openstack_dns_zone_v2.primary_project_dns_zone"
]
}
]
},
{
"mode": "managed",
"type": "openstack_dns_zone_v2",
"name": "primary_project_dns_zone",
"provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"attributes": {},
"description": "DNS primary zone for the d4s-dev-cloud project",
"disable_status_check": false,
"email": "postmaster@isti.cnr.it",
"id": "cbae638a-9d99-44aa-946c-0f5ffb7fc488",
"masters": [],
"name": "cloud-dev.d4science.org.",
"project_id": "e8f8ca72f30648a8b389b4e745ac83a9",
"region": "isti_area_pi_1",
"timeouts": null,
"ttl": 8600,
"type": "PRIMARY",
"value_specs": null
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwLCJ1cGRhdGUiOjYwMDAwMDAwMDAwMH19"
}
]
},
{
"mode": "managed",
"type": "openstack_networking_network_v2",
"name": "main-private-network",
"provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"admin_state_up": true,
"all_tags": [],
"availability_zone_hints": [],
"description": "D4Science DEV private network (use this as the main network)",
"dns_domain": "cloud-dev.d4science.org.",
"external": false,
"id": "e0af5eba-f24a-4d0d-8184-bc654b980c4a",
"mtu": 8942,
"name": "d4s-dev-cloud-main",
"port_security_enabled": true,
"qos_policy_id": "",
"region": "isti_area_pi_1",
"segments": [
{
"network_type": "geneve",
"physical_network": "",
"segmentation_id": 13667
}
],
"shared": false,
"tags": [],
"tenant_id": "e8f8ca72f30648a8b389b4e745ac83a9",
"timeouts": null,
"transparent_vlan": false,
"value_specs": null
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwfX0="
}
]
},
{
"mode": "managed",
"type": "openstack_networking_router_interface_v2",
"name": "private-network-routing",
"provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"force_destroy": null,
"id": "c7b93e0c-2046-436e-abc4-f19949e95847",
"port_id": "c7b93e0c-2046-436e-abc4-f19949e95847",
"region": "isti_area_pi_1",
"router_id": "2ae28c5f-036b-45db-bc9f-5bab8fa3e914",
"subnet_id": "2aa977f2-80b4-447c-a6b0-dfa06bf68751",
"timeouts": null
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwfSwic2NoZW1hX3ZlcnNpb24iOiIwIn0=",
"dependencies": [
"openstack_networking_network_v2.main-private-network",
"openstack_networking_router_v2.external-router",
"openstack_networking_subnet_v2.main-private-subnet"
]
}
]
},
{
"mode": "managed",
"type": "openstack_networking_router_v2",
"name": "external-router",
"provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"admin_state_up": true,
"all_tags": [],
"availability_zone_hints": [],
"description": "D4Science DEV main router",
"distributed": false,
"enable_snat": true,
"external_fixed_ip": [
{
"ip_address": "146.48.31.109",
"subnet_id": "57f87509-4016-46fb-b8c3-25fca7f72ccb"
}
],
"external_gateway": "1d2ff137-6ff7-4017-be2b-0d6c4af2353b",
"external_network_id": "1d2ff137-6ff7-4017-be2b-0d6c4af2353b",
"external_subnet_ids": null,
"id": "2ae28c5f-036b-45db-bc9f-5bab8fa3e914",
"name": "d4s-dev-cloud-external-router",
"region": "isti_area_pi_1",
"tags": [],
"tenant_id": "e8f8ca72f30648a8b389b4e745ac83a9",
"timeouts": null,
"value_specs": null,
"vendor_options": [
{
"set_router_gateway_after_create": true
}
]
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwfX0="
}
]
},
{
"mode": "managed",
"type": "openstack_networking_subnet_v2",
"name": "main-private-subnet",
"provider": "provider[\"registry.terraform.io/terraform-provider-openstack/openstack\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"all_tags": [],
"allocation_pool": [
{
"end": "10.1.31.254",
"start": "10.1.28.30"
}
],
"allocation_pools": [
{
"end": "10.1.31.254",
"start": "10.1.28.30"
}
],
"cidr": "10.1.28.0/22",
"description": "D4Science DEV main private subnet",
"dns_nameservers": [
"146.48.29.97",
"146.48.29.98",
"146.48.29.99"
],
"enable_dhcp": true,
"gateway_ip": "10.1.28.1",
"host_routes": [],
"id": "2aa977f2-80b4-447c-a6b0-dfa06bf68751",
"ip_version": 4,
"ipv6_address_mode": "",
"ipv6_ra_mode": "",
"name": "d4s-dev-cloud-sub",
"network_id": "e0af5eba-f24a-4d0d-8184-bc654b980c4a",
"no_gateway": false,
"prefix_length": null,
"region": "isti_area_pi_1",
"service_types": [],
"subnetpool_id": "",
"tags": [],
"tenant_id": "e8f8ca72f30648a8b389b4e745ac83a9",
"timeouts": null,
"value_specs": null
},
"sensitive_attributes": [],
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6NjAwMDAwMDAwMDAwfX0=",
"dependencies": [
"openstack_networking_network_v2.main-private-network"
]
}
]
}
],
"check_results": null
}

View File

@ -0,0 +1,95 @@
variable "os_project_data" {
type = map(string)
default = {
id = "e8f8ca72f30648a8b389b4e745ac83a9"
}
}
variable "dns_zone" {
type = map(string)
default = {
zone_name = "cloud-dev.d4science.org."
email = "postmaster@isti.cnr.it"
description = "DNS primary zone for the d4s-dev-cloud project"
ttl = 8600
}
}
variable "dns_zone_id" {
# Set with the correct value after the setup is complete
default = ""
}
variable "main_private_network" {
type = map(string)
default = {
name = "d4s-dev-cloud-main"
description = "D4Science DEV private network (use this as the main network)"
}
}
variable "main_private_network_id" {
# Set with the correct value after the setup is complete
default = ""
}
variable "main_private_subnet" {
type = map(string)
default = {
name = "d4s-dev-cloud-sub"
description = "D4Science DEV main private subnet"
cidr = "10.1.28.0/22"
gateway_ip = "10.1.28.1"
allocation_start = "10.1.28.30"
allocation_end = "10.1.31.254"
}
}
variable "main_private_subnet_id" {
# Set with the correct value after the setup is complete
default = ""
}
variable "external_router" {
type = map(string)
default = {
name = "d4s-dev-cloud-external-router"
description = "D4Science DEV main router"
id = "2ae28c5f-036b-45db-bc9f-5bab8fa3e914"
}
}
variable "basic_services_ip" {
type = map(string)
default = {
ca = "10.1.29.247"
ca_cidr = "10.1.29.247/32"
ssh_jump = "10.1.29.164"
ssh_jump_cidr = "10.1.29.164/32"
prometheus = "10.1.30.129"
prometheus_cidr = "10.1.30.129/32"
haproxy_l7_1 = "10.1.28.50"
haproxy_l7_1_cidr = "10.1.28.50/32"
haproxy_l7_2 = "10.1.30.241"
haproxy_l7_2_cidr = "10.1.30.241/32"
octavia_main = "10.1.28.227"
octavia_main_cidr = "10.1.28.227/32"
}
}
variable "main_haproxy_l7_ip" {
type = list(string)
default = ["10.1.40.11", "10.1.40.12"]
}
variable "octavia_information" {
type = map(string)
default = {
main_lb_name = "lb-dev-l4"
main_lb_description = "Main L4 load balancer for the D4Science DEV"
octavia_flavor = "octavia_amphora-mvcpu-ha"
octavia_flavor_id = "394988b5-6603-4a1e-a939-8e177c6681c7"
main_lb_hostname = "main-lb"
}
}

View File

@ -34,3 +34,27 @@ octavia_information = {
octavia_vrrp_ip_1 = "10.1.42.119/32"
octavia_vrrp_ip_2 = "10.1.42.188/32"
}
docker_swarm_data = {
mgr_name = "swarm-mgr"
mgr1_ip = "10.1.40.31"
mgr1_cidr = "10.1.40.31/32"
mgr2_ip = "10.1.40.32"
mgr2_cidr = "10.1.40.32/32"
mgr3_ip = "10.1.40.33"
mgr3_cidr = "10.1.40.33/32"
mgr_count = 3
mgr_flavor = "m1.large"
mgr_data_disk_size = 100
worker_name = "swarm-worker"
worker_count = 8
worker_flavor = "m1.xxl"
worker_data_disk_size = 200
nfs_server_name = "swarm-nfs-server"
nfs_server_flavor = "m1.medium"
nfs_server_data_disk_name = "Swarm NFS server data Disk"
nfs_server_data_disk_size = 200
nfs_server_data_disk_device = "/dev/vdb"
}
swarm_managers_ip = ["10.1.40.31", "10.1.40.32", "10.1.40.33"]

View File

@ -12,13 +12,13 @@ variable "docker_swarm_data" {
mgr_flavor = "m1.large"
mgr_data_disk_size = 100
worker_name = "swarm-worker"
worker_count = 8
worker_flavor = "m1.xxl"
worker_data_disk_size = 200
worker_count = 5
worker_flavor = "m1.xlarge"
worker_data_disk_size = 100
nfs_server_name = "swarm-nfs-server"
nfs_server_flavor = "m1.medium"
nfs_server_data_disk_name = "Swarm NFS server data Disk"
nfs_server_data_disk_size = 200
nfs_server_data_disk_size = 100
nfs_server_data_disk_device = "/dev/vdb"
}
}