From bf5e5c00384c67ffad1f4c6d7881c8f51ea42a1a Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Fri, 6 Sep 2024 16:50:56 +0200 Subject: [PATCH] small tweak to node info --- podstatus/app.py | 11 ++++++++++- podstatus/static/css/styles.css | 1 + podstatus/templates/index.html | 10 +++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/podstatus/app.py b/podstatus/app.py index 2bfb214..2c59a01 100644 --- a/podstatus/app.py +++ b/podstatus/app.py @@ -136,6 +136,7 @@ def watch_nodes(): node_name = node.metadata.name node_status = "Unknown" + # Extract node conditions for condition in node.status.conditions: if condition.type == "Ready": node_status = ( @@ -145,7 +146,15 @@ def watch_nodes(): ) break - yield f'data: {{"name": "{node_name}", "status": "{node_status}"}}\n\n' + # Extract additional node information + node_info = node.status.node_info + kubelet_version = node_info.kubelet_version + architecture = node_info.architecture + kernel_version = node_info.kernel_version + os_image = node_info.os_image + + # Send all the node data as part of the SSE event + yield f'data: {{"name": "{node_name}", "status": "{node_status}", "kubeletVersion": "{kubelet_version}", "architecture": "{architecture}", "kernelVersion": "{kernel_version}", "osImage": "{os_image}"}}\n\n' except Exception as e: logging.error(f"Error watching nodes: {e}") diff --git a/podstatus/static/css/styles.css b/podstatus/static/css/styles.css index 59417fb..dd721b4 100644 --- a/podstatus/static/css/styles.css +++ b/podstatus/static/css/styles.css @@ -14,6 +14,7 @@ main h1 { text-align: center; + color: rgb(0, 13, 26); } .container { diff --git a/podstatus/templates/index.html b/podstatus/templates/index.html index 06957e6..54a9d1f 100644 --- a/podstatus/templates/index.html +++ b/podstatus/templates/index.html @@ -53,6 +53,10 @@

Status of Nodes

const data = JSON.parse(event.data.replaceAll("'", '"')); const nodeName = data.name; const nodeStatusValue = data.status; + const kubeletVersion = data.kubeletVersion; + const architecture = data.architecture; + const kernelVersion = data.kernelVersion; + const osImage = data.osImage; if (firstEventNodes) { document.getElementById('node-status').innerHTML = ''; @@ -67,10 +71,14 @@

Status of Nodes

document.getElementById('node-status').appendChild(nodeElement); } - nodeElement.innerHTML = `${nodeName}: ${nodeStatusValue}`; + nodeElement.innerHTML = ` + ${nodeName}
+ ${kubeletVersion} - ${osImage} (${kernelVersion}) + `; nodeElement.style.backgroundColor = nodeStatusValue === 'KubeletReady' ? '#00bc8c' : '#e74c3c'; }; }, 1000); // Delay of 1 second before initializing SSE connection + });