Skip to content

Commit

Permalink
only apply prom exporter if metrics are enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
m3dwards committed Feb 14, 2024
1 parent c4a4187 commit 1850e31
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/backends/kubernetes/kubernetes_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
BITCOIN_CONTAINER_NAME = "bitcoin"
LN_CONTAINER_NAME = "ln"
MAIN_NAMESPACE = "warnet"
PROMETHEUS_METRICS_PORT = 9332


logger = logging.getLogger("KubernetesBackend")
Expand Down Expand Up @@ -576,7 +577,11 @@ def create_bitcoind_service(self, tank) -> client.V1Service:
client.V1ServicePort(
port=tank.zmqtxport, target_port=tank.zmqtxport, name="zmqtx"
),
client.V1ServicePort(port=9332, target_port=9332, name="prometheus-metrics"),
client.V1ServicePort(
port=PROMETHEUS_METRICS_PORT,
target_port=PROMETHEUS_METRICS_PORT,
name="prometheus-metrics",
),
],
),
)
Expand Down Expand Up @@ -622,8 +627,11 @@ def deploy_pods(self, warnet):
bitcoind_pod = self.create_pod_object(
tank, bitcoind_container, self.get_pod_name(tank.index, ServiceType.BITCOIN)
)
prometheus_container = self.create_prometheus_container(tank)
bitcoind_pod.spec.containers.append(prometheus_container)

if tank.exporter:
prometheus_container = self.create_prometheus_container(tank)
bitcoind_pod.spec.containers.append(prometheus_container)

bitcoind_service = self.create_bitcoind_service(tank)
self.client.create_namespaced_pod(namespace=self.namespace, body=bitcoind_pod)
# delete the service if it already exists, ignore 404
Expand Down

0 comments on commit 1850e31

Please sign in to comment.