From 441de0b80e5ebba4f64ddcf4511a167998469cfc Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Mon, 16 Sep 2024 09:32:42 +0200 Subject: [PATCH] add node name to podstatus --- podstatus/app.py | 3 ++- podstatus/templates/index.html | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/podstatus/app.py b/podstatus/app.py index 2c59a01..25f6a9a 100644 --- a/podstatus/app.py +++ b/podstatus/app.py @@ -119,8 +119,9 @@ def watch_pods(): pod_index = pod.metadata.labels.get( "statefulset.kubernetes.io/pod-name", "unknown" ) + pod_node = pod.spec.node_name if pod.spec.node_name else "unknown" - yield f'data: {{"name": "{pod_name}", "status": "{pod_status}", "index": "{pod_index}"}}\n\n' + yield f'data: {{"name": "{pod_name}", "status": "{pod_status}", "index": "{pod_index}", "node": "{pod_node}"}}\n\n' except Exception as e: logging.error(f"Error watching pods: {e}") diff --git a/podstatus/templates/index.html b/podstatus/templates/index.html index 54a9d1f..856d908 100644 --- a/podstatus/templates/index.html +++ b/podstatus/templates/index.html @@ -24,6 +24,7 @@

Status of Nodes

const podName = podStatus.name; const podStatusValue = podStatus.status; const podIndex = podStatus.index; + const podNode = podStatus.node; if (firstEvent) { document.getElementById('pod-status').innerHTML = ''; @@ -38,7 +39,7 @@

Status of Nodes

document.getElementById('pod-status').appendChild(podElement); } - podElement.innerHTML = `${podName}: ${podStatusValue}`; + podElement.innerHTML = `${podName}: ${podStatusValue} on ${podNode}`; podElement.style.backgroundColor = podStatusValue === 'Running' ? '#00bc8c' : podStatusValue === 'Pending' ? '#f39c12' : '#e74c3c'; };