Skip to content

Commit

Permalink
small tweak to node info
Browse files Browse the repository at this point in the history
  • Loading branch information
tobru committed Sep 6, 2024
1 parent 4087c75 commit bf5e5c0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
11 changes: 10 additions & 1 deletion podstatus/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand All @@ -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}")

Expand Down
1 change: 1 addition & 0 deletions podstatus/static/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

main h1 {
text-align: center;
color: rgb(0, 13, 26);
}

.container {
Expand Down
10 changes: 9 additions & 1 deletion podstatus/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ <h1>Status of Nodes</h1>
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 = '';
Expand All @@ -67,10 +71,14 @@ <h1>Status of Nodes</h1>
document.getElementById('node-status').appendChild(nodeElement);
}

nodeElement.innerHTML = `<strong>${nodeName}</strong>: ${nodeStatusValue}`;
nodeElement.innerHTML = `
<strong>${nodeName}</strong><br>
${kubeletVersion} - ${osImage} (${kernelVersion})
`;
nodeElement.style.backgroundColor = nodeStatusValue === 'KubeletReady' ? '#00bc8c' : '#e74c3c';
};
}, 1000); // Delay of 1 second before initializing SSE connection

});
</script>
<style>
Expand Down

0 comments on commit bf5e5c0

Please sign in to comment.