Skip to content

Commit

Permalink
Allow to deploy terraform on ovn environment
Browse files Browse the repository at this point in the history
Related-Prod: PRODX-40904
Change-Id: I948970f5dc7e82a6de537b12fa103c1e81ae125d
  • Loading branch information
jumpojoy committed Mar 19, 2024
1 parent 3027416 commit d611a91
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 5 deletions.
5 changes: 5 additions & 0 deletions terraform/000-main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
provider "openstack" {
use_octavia = "true"
cloud = "admin"
}

# Define OpenStack provider
terraform {
required_providers {
Expand Down
16 changes: 16 additions & 0 deletions terraform/001-input.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ variable "db_volume_size" {
description = "Volume size of disk for database"
default = 1
}
variable "database_lb_algorithm" {
type = string
description = "LB algorithm for database"
default = "SOURCE_IP"
}


# Application
variable "app_instance_names" {
Expand Down Expand Up @@ -110,6 +116,16 @@ variable "app_database" {
user = "refapp"
}
}
variable "app_lb_algorithm" {
type = string
default = "ROUND_ROBIN"
description = "The lb algorithm for app"
}
variable "app_lb_protocol" {
type = string
default = "HTTP"
description = "The lb protoco for app"
}
variable "database_docker_image" {
type = string
description = "The link to docker image with Mairadb"
Expand Down
10 changes: 5 additions & 5 deletions terraform/070-loadbalancer.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ resource "openstack_lb_loadbalancer_v2" "app" {
# Create listener
resource "openstack_lb_listener_v2" "app" {
name = "${var.identifier}-listener-app"
protocol = "HTTP"
protocol = var.app_lb_protocol
protocol_port = var.app_port
loadbalancer_id = openstack_lb_loadbalancer_v2.app.id
}

# Set method for load balance charge between instance
resource "openstack_lb_pool_v2" "app" {
name = "${var.identifier}-pool-app"
protocol = "HTTP"
lb_method = "ROUND_ROBIN"
protocol = var.app_lb_protocol
lb_method = var.app_lb_algorithm
listener_id = openstack_lb_listener_v2.app.id
}

Expand All @@ -36,7 +36,7 @@ resource "openstack_lb_member_v2" "app" {
resource "openstack_lb_monitor_v2" "app" {
name = "${var.identifier}-monitor-app"
pool_id = openstack_lb_pool_v2.app.id
type = "HTTP"
type = var.app_lb_protocol
delay = 5
timeout = 5
max_retries = 5
Expand Down Expand Up @@ -70,7 +70,7 @@ resource "openstack_lb_listener_v2" "db" {
resource "openstack_lb_pool_v2" "db" {
name = "${var.identifier}-pool-db"
protocol = "TCP"
lb_method = "SOURCE_IP"
lb_method = var.database_lb_algorithm
listener_id = openstack_lb_listener_v2.db.id

persistence {
Expand Down
3 changes: 3 additions & 0 deletions terraform/tfvars/ovn.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
app_lb_algorithm = "SOURCE_IP_PORT"
app_lb_protocol = "TCP"
database_lb_algorithm = "SOURCE_IP_PORT"
3 changes: 3 additions & 0 deletions terraform/tfvars/ovs.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
app_lb_algorithm = "ROUND_ROBIN"
app_lb_protocol = "HTTP"
database_lb_algorithm = "SOURCE_IP"

0 comments on commit d611a91

Please sign in to comment.