Skip to content

Commit 20f2a26

Browse files
verbotenjpaulobressangonzalezzfelipe
authored
Feat/add dynamic tolerations (#73)
* feat: add support for GCP to bootstrap Signed-off-by: Ales Verbic <[email protected]> * Implemented crdgen json output (#69) * chore: implemented crdgen json output * chore: implemented crdgen json output * fix: adjusted host regex (#70) * fix: fixed proxy api key (#71) * chore: Update Ogmios base image (#72) * feat(bootstrap): add dynamic support for tolerations Signed-off-by: Ales Verbic <[email protected]> --------- Signed-off-by: Ales Verbic <[email protected]> Co-authored-by: Paulo Bressan <[email protected]> Co-authored-by: Felipe Gonzalez <[email protected]>
1 parent e1f4a78 commit 20f2a26

File tree

8 files changed

+126
-33
lines changed

8 files changed

+126
-33
lines changed

bootstrap/feature/main.tf

+4-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ variable "api_key_salt" {
3131
variable "dcu_per_frame" {
3232
type = map(string)
3333
default = {
34-
"mainnet" = "10"
35-
"preprod" = "5"
36-
"preview" = "5"
34+
"mainnet" = "10"
35+
"preprod" = "5"
36+
"preview" = "5"
37+
"vector-testnet" = "5"
3738
}
3839
}
3940

bootstrap/instance/main.tf

+28-4
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,31 @@ variable "resources" {
5555
}
5656
}
5757

58-
59-
variable "compute_arch" {
60-
type = string
61-
}
58+
variable "tolerations" {
59+
description = "List of tolerations for the instance"
60+
type = list(object({
61+
effect = string
62+
key = string
63+
operator = string
64+
value = optional(string)
65+
}))
66+
default = [
67+
{
68+
effect = "NoSchedule"
69+
key = "demeter.run/compute-profile"
70+
operator = "Exists"
71+
},
72+
{
73+
effect = "NoSchedule"
74+
key = "demeter.run/compute-arch"
75+
operator = "Equal"
76+
value = "x86"
77+
},
78+
{
79+
effect = "NoSchedule"
80+
key = "demeter.run/availability-sla"
81+
operator = "Equal"
82+
value = "consistent"
83+
}
84+
]
85+
}

bootstrap/instance/ogmios.tf

+9-19
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ resource "kubernetes_deployment_v1" "ogmios" {
6262
name = "main"
6363
image = local.image
6464
image_pull_policy = "IfNotPresent"
65-
args = local.container_args
65+
args = local.container_args
6666

6767
resources {
6868
limits = {
@@ -137,24 +137,14 @@ resource "kubernetes_deployment_v1" "ogmios" {
137137
}
138138
}
139139

140-
toleration {
141-
effect = "NoSchedule"
142-
key = "demeter.run/compute-profile"
143-
operator = "Exists"
144-
}
145-
146-
toleration {
147-
effect = "NoSchedule"
148-
key = "demeter.run/compute-arch"
149-
operator = "Equal"
150-
value = var.compute_arch
151-
}
152-
153-
toleration {
154-
effect = "NoSchedule"
155-
key = "demeter.run/availability-sla"
156-
operator = "Equal"
157-
value = "consistent"
140+
dynamic "toleration" {
141+
for_each = var.tolerations
142+
content {
143+
effect = toleration.value.effect
144+
key = toleration.value.key
145+
operator = toleration.value.operator
146+
value = toleration.value.value
147+
}
158148
}
159149
}
160150
}

bootstrap/main.tf

+7-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ module "ogmios_v1_proxy" {
3232
proxy_image_tag = var.proxy_blue_image_tag
3333
extension_name = var.extension_name
3434
networks = var.networks
35+
cloud_provider = var.cloud_provider
36+
dns_zone = var.dns_zone
37+
cluster_issuer = var.cluster_issuer
3538
name = "proxy"
3639
}
3740

@@ -44,6 +47,9 @@ module "ogmios_v1_proxy_green" {
4447
extension_name = var.extension_name
4548
networks = ["mainnet", "preprod", "preview", "vector-testnet"]
4649
environment = "green"
50+
cloud_provider = var.cloud_provider
51+
dns_zone = var.dns_zone
52+
cluster_issuer = var.cluster_issuer
4753
name = "proxy-green"
4854
}
4955

@@ -69,7 +75,7 @@ module "ogmios_instances" {
6975
ogmios_image = each.value.ogmios_image
7076
node_private_dns = each.value.node_private_dns
7177
ogmios_version = each.value.ogmios_version
72-
compute_arch = each.value.compute_arch
78+
tolerations = each.value.tolerations
7379
replicas = each.value.replicas
7480
}
7581

bootstrap/proxy/cert.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ resource "kubernetes_manifest" "certificate_cluster_wildcard_tls" {
2525

2626
"issuerRef" = {
2727
"kind" = "ClusterIssuer"
28-
"name" = "letsencrypt"
28+
"name" = var.cluster_issuer
2929
}
3030
"secretName" = local.cert_secret_name
3131
}

bootstrap/proxy/main.tf

+15
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,18 @@ variable "dns_zone" {
8080
type = string
8181
default = "demeter.run"
8282
}
83+
84+
variable "cluster_issuer" {
85+
type = string
86+
default = "letsencrypt"
87+
}
88+
89+
variable "cloud_provider" {
90+
type = string
91+
default = "aws"
92+
}
93+
94+
variable "healthcheck_port" {
95+
type = number
96+
default = null
97+
}

bootstrap/proxy/service.tf

+43-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
resource "kubernetes_service_v1" "proxy_service" {
1+
resource "kubernetes_service_v1" "proxy_service_aws" {
2+
for_each = toset([for n in toset(["loadbalancer"]) : n if var.cloud_provider == "aws"])
23
metadata {
34
name = local.name
45
namespace = var.namespace
@@ -8,6 +9,7 @@ resource "kubernetes_service_v1" "proxy_service" {
89
"service.beta.kubernetes.io/aws-load-balancer-type" : "external"
910
"service.beta.kubernetes.io/aws-load-balancer-healthcheck-protocol" : "HTTPS"
1011
"service.beta.kubernetes.io/aws-load-balancer-healthcheck-path" : "/healthz"
12+
"service.beta.kubernetes.io/aws-load-balancer-healthcheck-port" : var.healthcheck_port != null ? var.healthcheck_port : "traffic-port"
1113
}
1214
}
1315

@@ -22,6 +24,46 @@ resource "kubernetes_service_v1" "proxy_service" {
2224
protocol = "TCP"
2325
}
2426

27+
28+
port {
29+
name = "health"
30+
port = 80
31+
target_port = local.prometheus_port
32+
protocol = "TCP"
33+
}
34+
35+
type = "LoadBalancer"
36+
}
37+
}
38+
39+
resource "kubernetes_service_v1" "proxy_service_gcp" {
40+
for_each = toset([for n in toset(["loadbalancer"]) : n if var.cloud_provider == "gcp"])
41+
metadata {
42+
name = local.name
43+
namespace = var.namespace
44+
annotations = {
45+
"cloud.google.com/l4-rbs" : "enabled"
46+
}
47+
}
48+
49+
spec {
50+
external_traffic_policy = "Local"
51+
selector = local.proxy_labels
52+
53+
port {
54+
name = "proxy"
55+
port = 443
56+
target_port = local.proxy_port
57+
protocol = "TCP"
58+
}
59+
60+
port {
61+
name = "health"
62+
port = 80
63+
target_port = local.prometheus_port
64+
protocol = "TCP"
65+
}
66+
2567
type = "LoadBalancer"
2668
}
2769
}

bootstrap/variables.tf

+19-4
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,20 @@ variable "dns_zone" {
77
default = "demeter.run"
88
}
99

10+
variable "cluster_issuer" {
11+
type = string
12+
default = "letsencrypt"
13+
}
14+
1015
variable "extension_name" {
1116
type = string
1217
default = "ogmios-m1"
1318
}
1419

20+
variable "cloud_provider" {
21+
type = string
22+
default = "aws"
23+
}
1524

1625
variable "networks" {
1726
type = list(string)
@@ -37,9 +46,10 @@ variable "api_key_salt" {
3746
variable "dcu_per_frame" {
3847
type = map(string)
3948
default = {
40-
"mainnet" = "10"
41-
"preprod" = "5"
42-
"preview" = "5"
49+
"mainnet" = "10"
50+
"preprod" = "5"
51+
"preview" = "5"
52+
"vector-testnet" = "5"
4353
}
4454
}
4555

@@ -128,7 +138,6 @@ variable "proxy_resources" {
128138
}
129139
}
130140

131-
132141
variable "instances" {
133142
type = map(object({
134143
salt = string
@@ -148,5 +157,11 @@ variable "instances" {
148157
memory = string
149158
})
150159
}))
160+
tolerations = optional(list(object({
161+
effect = string
162+
key = string
163+
operator = string
164+
value = optional(string)
165+
})))
151166
}))
152167
}

0 commit comments

Comments
 (0)