From be3c76801ea6784e663d762872be2f2edf75c21a Mon Sep 17 00:00:00 2001 From: Gabriel Simmer Date: Fri, 10 Nov 2023 14:45:02 +0000 Subject: [PATCH] Deploy vrchat-prometheus-adapter to cluster --- homelab/kubernetes.nix | 3 +- homelab/vrchat-prometheus-exporter.nix | 56 ++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 homelab/vrchat-prometheus-exporter.nix diff --git a/homelab/kubernetes.nix b/homelab/kubernetes.nix index f521853..3cb05c7 100644 --- a/homelab/kubernetes.nix +++ b/homelab/kubernetes.nix @@ -1,5 +1,6 @@ { lib, config, kubenix, ... }: { imports = [ kubenix.modules.k8s (import ./custom.nix) - (import ./tclip.nix) ]; + (import ./tclip.nix) + (import ./vrchat-prometheus-exporter.nix) ]; } diff --git a/homelab/vrchat-prometheus-exporter.nix b/homelab/vrchat-prometheus-exporter.nix new file mode 100644 index 0000000..1587f7b --- /dev/null +++ b/homelab/vrchat-prometheus-exporter.nix @@ -0,0 +1,56 @@ +let + appName = "vrchat-prometheus-exporter"; + appImage = "git.gmem.ca/arch/vrchat-prometheus-adapter:arm"; +in +{ + kubernetes.resources."monitoring.coreos.com"."v1".ServiceMonitor.vrchat-prometheus-adapter = { + spec = { + selector.matchLabels.app = appName; + endpoints = [ { port = "metrics"; interval = "60s"; } ]; + }; + }; + kubernetes.resources.services.vrchat-prometheus-adapter = { + metadata.annotations = { + "prometheus.io/port" = "6534"; + "prometheus.io/scrape" = "true"; + "prometheus.io/path" = "/metrics"; + }; + spec = { + selector.app = appName; + ports.metrics = { + port = 6534; + targetPort = 6534; + }; + }; + }; + kubernetes.resources.deployments.vrchat-prometheus-adapter.spec = { + selector.matchLabels.app = appName; + template = { + metadata.labels.app = appName; + spec = { + volumes = { + config.configMap.name = "vrchat-prometheus-adapter"; + }; + containers = { + vrchat-prometheus-adapter = { + image = appImage; + imagePullPolicy = "Always"; + volumeMounts = [ { name = "config"; mountPath = "/config.toml"; subPath = "config.toml"; } ]; + envFrom = [ { secretRef.name = "vrchat-prometheus-adapter"; } ]; + ports.metrics.containerPort = 6534; + resources = { + requests = { + cpu = "50m"; + memory = "32Mi"; + }; + limits = { + cpu = "500m"; + memory = "256Mi"; + }; + }; + }; + }; + }; + }; + }; +}