UI rework: inventory tree, compact cards, live Hubble traffic

Frontend rewritten around three panes. Inventory tree on the left
(namespaces by kind, or nodes by namespace) with search and keyboard
navigation replaces the namespace checkbox list. The map shows only the
selected namespace(s) or node: fixed-size cards inside namespace boxes,
laid out in two elk passes so a big namespace packs into rows instead of
one tall column; zoom is capped so the view no longer jumps. Details
panel has Overview / Links / YAML / Logs tabs. Light and dark themes.
Libraries are vendored, no CDN.

Backend: /api/flows reads recent flows from hubble-relay (TLS verified
with the hubble CA, no client cert needed) and aggregates them per
source/destination/port. Pods are resolved to workloads with the same
rules as the graph, since Hubble leaves Workloads empty on some flows.
Pods under non-native controllers (kruise DaemonSet, CNPG clusters,
bare Jobs, static pods) are now graph nodes too. Probes move to
/healthz: /api/graph was timing out the 1s probe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Vitaliy Chefanov
2026-09-23 19:50:53 +03:00
co-authored by Claude Opus 5.5
parent 2ac0ddb6ba
commit cf84e9976f
11 changed files with 8711 additions and 395 deletions
+202
View File
@@ -0,0 +1,202 @@
:root {
color-scheme: light dark;
--bg: light-dark(#f4f5f7, #0f1115);
--panel: light-dark(#ffffff, #161920);
--panel-2: light-dark(#f0f2f5, #1c2029);
--line: light-dark(#d9dde3, #2a2f3a);
--text: light-dark(#1d2129, #e3e6eb);
--muted: light-dark(#5d6573, #98a1b0);
--accent: light-dark(#2f6fe0, #6aa0ff);
--accent-soft: light-dark(#e3edfd, #1d2a44);
--ok: light-dark(#1f9d55, #3fcf7f);
--warn: light-dark(#c98200, #f0b429);
--error: light-dark(#d33a3a, #ff6b6b);
--idle: light-dark(#8a93a3, #6b7383);
--focus: light-dark(#2f6fe0, #8fb8ff);
accent-color: var(--accent);
scrollbar-color: light-dark(#b9c0cb, #3a4150) transparent;
scrollbar-width: thin;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
background: var(--bg);
color: var(--text);
font: 0.8125rem/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
display: flex;
flex-direction: column;
}
.muted { color: var(--muted); }
.small { font-size: 0.75rem; }
:where(button, input, select, [role="treeitem"], [role="tab"]):focus-visible {
outline: 2px solid var(--focus);
outline-offset: 1px;
}
.btn {
background: var(--panel-2);
color: var(--text);
border: 1px solid var(--line);
border-radius: 6px;
padding: 0.25rem 0.6rem;
font: inherit;
cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn.icon { width: 2rem; height: 2rem; padding: 0; font-size: 1rem; line-height: 1; }
select, input[type="search"] {
background: var(--panel-2);
color: var(--text);
border: 1px solid var(--line);
border-radius: 6px;
padding: 0.3rem 0.5rem;
font: inherit;
}
/* top bar */
.topbar {
display: flex;
align-items: center;
gap: 1rem;
padding: 0.5rem 0.9rem;
background: var(--panel);
border-bottom: 1px solid var(--line);
flex: none;
}
.brand { font-weight: 650; letter-spacing: 0.01em; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; flex: 1; min-width: 0; }
.crumbs button {
background: none; border: none; color: var(--accent); font: inherit; cursor: pointer; padding: 0.1rem 0.2rem; border-radius: 4px;
}
.crumbs .sep { color: var(--muted); }
.crumbs .chip {
display: inline-flex; align-items: center; gap: 0.25rem;
background: var(--accent-soft); color: var(--text); border-radius: 999px; padding: 0.05rem 0.25rem 0.05rem 0.6rem;
}
.crumbs .chip button { color: var(--muted); padding: 0 0.35rem; }
.topbar-actions { display: flex; align-items: center; gap: 0.6rem; flex: none; }
.toggle { display: inline-flex; align-items: center; gap: 0.3rem; cursor: pointer; }
/* main layout */
.layout { flex: 1; display: flex; min-height: 0; }
.sidebar {
width: 19rem; flex: none;
display: flex; flex-direction: column; gap: 0.6rem;
padding: 0.75rem;
background: var(--panel);
border-right: 1px solid var(--line);
min-height: 0;
}
.seg { display: flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; padding: 2px; }
.seg [role="tab"] {
flex: 1; border: none; background: none; color: var(--muted); font: inherit; padding: 0.3rem; border-radius: 5px; cursor: pointer;
}
.seg [role="tab"][aria-selected="true"] { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px #0002; }
.hint { margin: 0; color: var(--muted); font-size: 0.72rem; }
/* inventory tree */
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree { flex: 1; overflow-y: auto; min-height: 0; padding-right: 2px; }
.tree ul { padding-left: 0.9rem; }
.tree [role="treeitem"] > .row {
display: flex; align-items: center; gap: 0.35rem;
padding: 0.18rem 0.35rem; border-radius: 5px; cursor: pointer;
white-space: nowrap;
}
.tree [role="treeitem"] > .row:hover { background: var(--panel-2); }
.tree [role="treeitem"][aria-selected="true"] > .row { background: var(--accent-soft); }
.tree [role="treeitem"].in-scope > .row .label { font-weight: 600; }
.tree [role="treeitem"]:focus-visible { outline: none; }
.tree [role="treeitem"]:focus-visible > .row { outline: 2px solid var(--focus); outline-offset: -2px; }
.tree [role="treeitem"][aria-expanded="false"] > ul { display: none; }
.tree .twisty { width: 0.9rem; flex: none; color: var(--muted); text-align: center; font-size: 0.65rem; }
.tree [aria-expanded="true"] > .row .twisty::before { content: "▾"; }
.tree [aria-expanded="false"] > .row .twisty::before { content: "▸"; }
.tree .icon { width: 14px; height: 14px; flex: none; }
.tree .label { overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.tree .count { color: var(--muted); font-size: 0.7rem; font-variant-numeric: tabular-nums; }
.tree mark { background: none; color: var(--accent); font-weight: 650; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.error { background: var(--error); }
.dot.idle { background: var(--idle); }
/* canvas */
.stage { flex: 1; position: relative; min-width: 0; }
#cy { position: absolute; inset: 0; }
.stage-status {
position: absolute; top: 0.6rem; left: 50%; transform: translateX(-50%);
background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
padding: 0.2rem 0.8rem; font-size: 0.75rem; color: var(--muted);
}
.stage-status:empty { display: none; }
.stage-status.error { color: var(--error); }
.zoom { position: absolute; right: 0.75rem; bottom: 0.75rem; display: flex; flex-direction: column; gap: 0.3rem; }
.legend {
position: absolute; left: 0.75rem; bottom: 0.75rem;
display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; max-width: 70%;
background: color-mix(in srgb, var(--panel) 88%, transparent);
border: 1px solid var(--line); border-radius: 8px; padding: 0.4rem 0.7rem;
font-size: 0.72rem; color: var(--muted);
}
.legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.legend .line { width: 22px; height: 0; border-top: 2px solid var(--muted); }
.legend .line.traffic { border-top: 3px dashed var(--accent); }
.legend .line.drop { border-top: 3px dashed var(--error); }
.legend .line.config { border-top: 1.5px solid var(--muted); }
/* details panel */
.details {
width: 27rem; flex: none;
display: flex; flex-direction: column;
background: var(--panel);
border-left: 1px solid var(--line);
min-height: 0;
}
.details[hidden] { display: none; }
.details-head { display: flex; align-items: flex-start; gap: 0.5rem; padding: 0.8rem 0.9rem 0.5rem; }
.details-title { flex: 1; min-width: 0; }
.details-title h2 { margin: 0.2rem 0 0; font-size: 1rem; overflow-wrap: anywhere; }
.kind-chip {
display: inline-block; font-size: 0.68rem; font-weight: 600; letter-spacing: 0.02em;
padding: 0.05rem 0.45rem; border-radius: 4px; color: #fff;
}
.tabs { display: flex; gap: 0.2rem; padding: 0 0.9rem; border-bottom: 1px solid var(--line); }
.tabs [role="tab"] {
border: none; background: none; color: var(--muted); font: inherit;
padding: 0.45rem 0.6rem; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs [role="tab"][aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tabs [role="tab"][hidden] { display: none; }
.tab-panel { flex: 1; overflow-y: auto; padding: 0.8rem 0.9rem; min-height: 0; }
.tab-panel[hidden] { display: none; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.3rem 0.8rem; margin: 0 0 1rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.status { display: inline-flex; align-items: center; gap: 0.35rem; }
.section-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 1rem 0 0.4rem; }
.link-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.2rem; }
.link-list button {
width: 100%; display: flex; align-items: center; gap: 0.5rem; text-align: left;
background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px;
padding: 0.35rem 0.5rem; color: var(--text); font: inherit; cursor: pointer;
}
.link-list button:hover { border-color: var(--accent); }
.link-list .meta { margin-left: auto; color: var(--muted); font-size: 0.72rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.link-list .drop { color: var(--error); }
.code {
margin: 0; white-space: pre; overflow: auto;
font: 0.72rem/1.5 ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 0.6rem;
}
#d-logs { white-space: pre-wrap; overflow-wrap: anywhere; }
.logs-bar { display: flex; gap: 0.4rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.logs-bar select { max-width: 100%; }
@media (prefers-reduced-motion: reduce) {
* { transition: none !important; animation: none !important; }
}