Skip to content

Commit

Permalink
chore: add node relay bootstrap (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
avatxus authored Jun 6, 2024
1 parent 43f61a7 commit f85c543
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 10 deletions.
4 changes: 3 additions & 1 deletion bootstrap/instance/node.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ locals {
"3000"
]
arguments = var.is_custom == true ? local.custom_arguments : local.default_arguments

n2n_port_name = contains(["mainnet", "preview", "preprod"], var.network) && var.release == "stable" ? "n2n-${var.network}" : "n2n"
}


Expand Down Expand Up @@ -177,7 +179,7 @@ resource "kubernetes_stateful_set_v1" "node" {
}

port {
name = "n2n"
name = local.n2n_port_name
container_port = 3000
}

Expand Down
6 changes: 6 additions & 0 deletions bootstrap/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,9 @@ module "services" {
release = each.value.release
active_salt = each.value.active_salt
}

module "node_relay" {
depends_on = [kubernetes_namespace.namespace]
source = "./relay"
namespace = var.namespace
}
18 changes: 9 additions & 9 deletions bootstrap/proxy/config.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ locals {
"max_connections" = 1
"rates" = [
{
"interval" = "1s",
"limit" = 1024 * 1024
"interval" = "1m",
"limit" = 1024 * 1024 * 60
}
]
},
Expand All @@ -21,8 +21,8 @@ locals {
"max_connections" = 5
"rates" = [
{
"interval" = "1s",
"limit" = 1024 * 1024
"interval" = "1m",
"limit" = 1024 * 1024 * 60 * 2
}
]
},
Expand All @@ -31,18 +31,18 @@ locals {
"max_connections" = 25
"rates" = [
{
"interval" = "1s",
"limit" = 1024 * 1024
"interval" = "1m",
"limit" = 1024 * 1024 * 60 * 2
}
]
},
{
"name" = "3",
"max_connections" = 75
"rates" = [
{
"interval" = "1s",
"limit" = 1024 * 1024
{
"interval" = "1m",
"limit" = 1024 * 1024 * 60 * 2
}
]
}
Expand Down
50 changes: 50 additions & 0 deletions bootstrap/relay/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
variable "namespace" {
description = "the namespace where the resources will be created"
}

resource "kubernetes_service_v1" "node-relay-n2n" {
metadata {
name = "node-relay-n2n"
namespace = var.namespace
annotations = {
"service.beta.kubernetes.io/aws-load-balancer-nlb-target-type" : "instance"
"service.beta.kubernetes.io/aws-load-balancer-scheme" : "internet-facing"
"service.beta.kubernetes.io/aws-load-balancer-type" : "external"
}
}

spec {
type = "LoadBalancer"
load_balancer_class = "service.k8s.aws/nlb"

selector = {
"role" = "node"
"release" = "stable"
}

port {
name = "mainnet"
protocol = "TCP"
port = 3000
target_port = "n2n-mainnet"
}

port {
name = "preprod"
protocol = "TCP"
port = 3001
target_port = "n2n-preprod"
}

port {
name = "preview"
protocol = "TCP"
port = 3002
target_port = "n2n-preview"
}




}
}

0 comments on commit f85c543

Please sign in to comment.