Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added pod monitor for metrics #209

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions bootstrap/rpc/config.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ resource "kubernetes_config_map_v1" "fabric_rpc_config" {
"rpc.toml" = "${templatefile(
"${path.module}/rpc.toml.tftpl",
{
port = local.port,
port = local.port,
prometheus_port = local.prometheus_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 All @@ -27,7 +29,6 @@ resource "kubernetes_config_map_v1" "fabric_rpc_config" {
email_ses_secret_access_key = var.email_ses_secret_access_key
email_ses_region = var.email_ses_region
email_ses_verified_email = var.email_ses_verified_email
prometheus_addr = var.prometheus_addr
}
)}"
}
Expand Down
7 changes: 1 addition & 6 deletions bootstrap/rpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ locals {
configmap_name = "fabric-rpc-config"
crds_configmap_name = "fabric-rpc-crds"
port = 5050
prometheus_port = 9946
}

variable "namespace" {
Expand Down Expand Up @@ -92,12 +93,6 @@ variable "dns_zone" {
default = "demeter.run"
}

variable "prometheus_addr" {
type = string
default = "0.0.0.0:9946"
}


variable "replicas" {
type = number
default = 1
Expand Down
27 changes: 27 additions & 0 deletions bootstrap/rpc/monitor.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
resource "kubernetes_manifest" "rpc_monitor" {
manifest = {
apiVersion = "monitoring.coreos.com/v1"
kind = "PodMonitor"
metadata = {
labels = {
"app.kubernetes.io/component" = "o11y"
"app.kubernetes.io/part-of" = "demeter"
}
name = "fabric-rpc"
namespace = var.namespace
}
spec = {
selector = {
matchLabels = {
role = "fabric-rpc"
}
}
podMetricsEndpoints = [
{
port = "metrics",
path = "/metrics"
}
]
}
}
}
2 changes: 1 addition & 1 deletion bootstrap/rpc/rpc.toml.tftpl
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ ses_verified_email = "${email_ses_verified_email}"
"sasl.password" = "${kafka_password}"

[prometheus]
addr = "${prometheus_addr}"
addr = "0.0.0.0:${prometheus_port}"

5 changes: 5 additions & 0 deletions bootstrap/rpc/sts.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ resource "kubernetes_stateful_set_v1" "rpc" {
container_port = local.port
}

port {
name = "metrics"
container_port = local.prometheus_port
}

volume_mount {
name = "cache"
mount_path = "/var/cache"
Expand Down
Loading