Skip to content

Commit

Permalink
added lb code
Browse files Browse the repository at this point in the history
  • Loading branch information
Janibasha committed Nov 8, 2024
1 parent 6b0526e commit fe0c8fd
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource "volterra_k8s_cluster" "mk8s" {
name = format("%s-xcop", var.project_prefix)
name = format("%s-mk8s", var.project_prefix)
namespace = "system"
use_default_cluster_role_bindings = true
use_default_cluster_roles = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#output "xc_lb_name" {
# value = nonsensitive(volterra_http_loadbalancer.lb_https.name)
#}
output "xc_lb_name" {
value = nonsensitive(volterra_http_loadbalancer.lb_https.name)
}

output "endpoint" {
value = var.app_domain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,5 @@ terraform {
source = "volterraedge/volterra"
version = ">= 0.11.34"
}
azurerm = {
source = "hashicorp/azurerm"
version = ">=3.18.0"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Wait for appstack CE site creation
resource "null_resource" "wait_for_aws_ce_site"{
count = var.user_site ? 1 : 0
depends_on = [volterra_tf_params_action.apply_aws_vpc]
}

# Create XC LB config
resource "volterra_origin_pool" "op" {
depends_on = [null_resource.wait_for_aws_ce_site]
name = format("%s-xcop", var.project_prefix)
namespace = var.xc_namespace
description = format("Origin pool pointing to origin server for %s", var.project_prefix)

dynamic "origin_servers" {
for_each = var.k8s_pool ? [1] : []
content {
k8s_service {
service_name = var.serviceName
vk8s_networks = true
outside_network = true
site_locator {
site {
name = var.site_name
namespace = "system"
tenant = var.xc_tenant
}
}
}
}
}

no_tls = true
port = var.serviceport
endpoint_selection = "LOCAL_PREFERRED"
loadbalancer_algorithm = "LB_OVERRIDE"
}

resource "volterra_http_loadbalancer" "lb_https" {
depends_on = [volterra_origin_pool.op]
name = format("%s-xclb", var.project_prefix)
namespace = var.xc_namespace
description = format("HTTP loadbalancer object for %s origin server", var.project_prefix)
domains = [var.app_domain]
advertise_on_public_default_vip = true

dynamic "https_auto_cert" {
for_each = var.http_only ? [] : [1]
content {
add_hsts = false
http_redirect = true
no_mtls = true
enable_path_normalize = true
tls_config {
default_security = true
}
}
}

default_route_pools {
pool {
name = volterra_origin_pool.op.name
namespace = var.xc_namespace
}
weight = 1
}

disable_waf = false
round_robin = true
service_policies_from_namespace = true
user_id_client_ip = true
source_ip_stickiness = true

dynamic "more_option" {
for_each = var.k8s_pool ? [1] : []
content {
idle_timeout = 600000
}
}
}

0 comments on commit fe0c8fd

Please sign in to comment.