Skip to content

Commit

Permalink
add node name to podstatus
Browse files Browse the repository at this point in the history
  • Loading branch information
tobru committed Sep 16, 2024
1 parent cdb6981 commit 441de0b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion podstatus/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

Expand Down
3 changes: 2 additions & 1 deletion podstatus/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ <h1>Status of Nodes</h1>
const podName = podStatus.name;
const podStatusValue = podStatus.status;
const podIndex = podStatus.index;
const podNode = podStatus.node;

if (firstEvent) {
document.getElementById('pod-status').innerHTML = '';
Expand All @@ -38,7 +39,7 @@ <h1>Status of Nodes</h1>
document.getElementById('pod-status').appendChild(podElement);
}

podElement.innerHTML = `<strong>${podName}</strong>: ${podStatusValue}`;
podElement.innerHTML = `<strong>${podName}</strong>: ${podStatusValue} on ${podNode}`;
podElement.style.backgroundColor = podStatusValue === 'Running' ? '#00bc8c' :
podStatusValue === 'Pending' ? '#f39c12' : '#e74c3c';
};
Expand Down

0 comments on commit 441de0b

Please sign in to comment.