Skip to content

Commit

Permalink
fix: Update bootsrapping to handle usage driver
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzalezzfelipe committed Aug 28, 2024
1 parent 3d1bae1 commit ea216f6
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 7 deletions.
13 changes: 8 additions & 5 deletions bootstrap/daemon/config.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ resource "kubernetes_config_map_v1" "fabric_daemon_config" {
"daemon.toml" = "${templatefile(
"${path.module}/daemon.toml.tftpl",
{
broker_urls = var.broker_urls
consumer_name = var.consumer_name
kafka_username = var.kafka_username
kafka_password = var.kafka_password
topic = var.kafka_topic
broker_urls = var.broker_urls
consumer_name = var.consumer_name
kafka_username = var.kafka_username
kafka_password = var.kafka_password
topic = var.kafka_topic
cluster_id = var.cluster_id
prometheus_url = var.prometheus_url
prometheus_delay_sec = var.prometheus_delay_sec
}
)}"
}
Expand Down
4 changes: 4 additions & 0 deletions bootstrap/daemon/daemon.toml.tftpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
topic = "${topic}"

cluster_id = "${cluster_id}"
prometheus_url = ${prometheus_url}
delay_sec = 60

[kafka]
"bootstrap.servers" = "${broker_urls}"
"group.id"= "${consumer_name}"
Expand Down
16 changes: 16 additions & 0 deletions bootstrap/daemon/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ variable "image" {
type = string
}

variable "cluster_id" {
type = string
}

variable "broker_urls" {
type = string
description = "Comma separated values of the queue broker urls."
Expand Down Expand Up @@ -38,6 +42,18 @@ variable "replicas" {
default = 1
}

variable "prometheus_url" {
type = string
description = "URL where to query prometheus to report usage metrics."
default = "http://prometheus-operated.demeter-system.svc.cluster.local:9090/api/v1"
}

variable "prometheus_delay_sec" {
type = number
description = "Delay between usage report loops."
default = 60
}

variable "tolerations" {
type = list(object({
effect = string
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/rpc/config.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ resource "kubernetes_config_map_v1" "fabric_rpc_config" {
"rpc.toml" = "${templatefile(
"${path.module}/rpc.toml.tftpl",
{
port = local.port,
port = local.port,
// If we change the consumer, we must rebuild the cache.
db_path = "/var/cache/${var.consumer_name}.db",
broker_urls = var.broker_urls
Expand Down
3 changes: 2 additions & 1 deletion bootstrap/rpc/crds.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ resource "kubernetes_config_map_v1" "fabric_rpc_crds" {
}

data = {
"utxorpcport.json" = "${file("${path.module}/utxorpcport.json")}"
"utxorpcport.json" = "${file("${path.module}/crds/utxorpcport.json")}"
"frontends.json" = "${file("${path.module}/crds/frontends.json")}"
}
}
137 changes: 137 additions & 0 deletions bootstrap/rpc/crds/frontends.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
{
"apiVersion": "apiextensions.k8s.io/v1",
"kind": "CustomResourceDefinition",
"metadata": {
"name": "frontends.demeter.run"
},
"spec": {
"group": "demeter.run",
"names": {
"kind": "Frontend",
"plural": "frontends",
"shortNames": [
"fnd"
],
"singular": "frontend"
},
"scope": "Namespaced",
"versions": [
{
"name": "v1alpha1",
"schema": {
"openAPIV3Schema": {
"type": "object",
"properties": {
"spec": {
"type": "object",
"properties": {
"givenName": {
"type": "string"
},
"image": {
"type": "string"
},
"replicas": {
"type": "number"
},
"enabled": {
"type": "boolean"
},
"args": {
"type": "string"
},
"tenancy": {
"type": "string",
"pattern": "^(\\b(cluster|project|proxy)\\b)$"
},
"envVars": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"value": {
"type": "string"
}
}
}
},
"annotations": {
"type": "object",
"x-kubernetes-preserve-unknown-fields": true
},
"computeClass": {
"type": "string"
}
}
},
"status": {
"type": "object",
"properties": {
"runningStatus": {
"type": "string"
},
"availableReplicas": {
"type": "number"
},
"observedGeneration": {
"type": "number"
},
"availableEnvVars": {
"type": "array",
"items": {
"type": "string"
}
},
"startTime": {
"type": "number"
},
"storageDCUPerMin": {
"type": "number"
},
"computeDCUPerMin": {
"type": "number"
}
}
}
}
}
},
"additionalPrinterColumns": [
{
"name": "Enabled",
"type": "boolean",
"jsonPath": ".spec.enabled"
},
{
"name": "Replicas",
"type": "number",
"jsonPath": ".spec.replicas"
},
{
"name": "Compute Class",
"type": "string",
"jsonPath": ".spec.computeClass"
},
{
"name": "Compute DCU/min",
"type": "number",
"jsonPath": ".status.computeDCUPerMin"
},
{
"name": "Storage DCU/min",
"type": "number",
"jsonPath": ".status.storageDCUPerMin"
}
],
"served": true,
"storage": true,
"subresources": {
"status": {}
}
}
]
}
}
File renamed without changes.

0 comments on commit ea216f6

Please sign in to comment.