Repository navigation
feat(tenant): allow egress to vlinsert in parent tenants - #3439
IvanHunters wants to merge 2 commits into
Conversation
Tenant egress CCNP already permits child tenants to reach vminsert (VictoriaMetrics ingest) in any ancestor namespace, but vlinsert (VictoriaLogs ingest) was missing. Without it, fluent-bit / vector deployed via monitoring-agents in a child tenant cannot forward logs to a parent tenant's VictoriaLogs. Mirror the existing vminsert block. Signed-off-by: IvanHunters <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe tenant network policy template changes non- ChangesTenant egress policy
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Checkov (3.3.8)packages/apps/tenant/tests/networkpolicy_egress_test.yamlTraceback (most recent call last): Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Aleksei Sviridkin (lexfrei)
left a comment
There was a problem hiding this comment.
NOT LGTM — the change is correct and I verified it renders and targets the right endpoint, but it modifies a template in a chart that gates on tests and ships no test for the new rule.
Business context: the tenant egress CiliumClusterwideNetworkPolicy already lets a child tenant reach vminsert, etcd, and ingress controllers in ancestor namespaces; this PR adds the missing vlinsert (VictoriaLogs insert) allowance so a child tenant running monitoring-agents can forward container logs to a parent tenant's VictoriaLogs without hand-editing the policy.
Verified correct
The new toEndpoints block is a verbatim structural mirror of the existing vminsert block, changing only the matched selector value. I confirmed the surrounding facts rather than taking them on faith:
- Selector is right:
vlinsertpods are labeledapp.kubernetes.io/name: vlinsert(cross-checked againstpackages/extra/monitoring/templates/workloadmonitors.yamlandpackages/system/monitoring/templates/vm/vmcluster-scrape.yaml), matching the block'sk8s:app.kubernetes.io/name: vlinsert. This is the same convention asvminsert, and correctly distinct frometcd, which is matched byapp.kubernetes.io/instance. - It renders:
helm templateoftemplates/networkpolicy.yamlfor a depth-2 child (tenant-htdevin namespacetenant-ktj) emits thevlinsertblock parallel tovminsert, scoped to the parent namespacetenant-ktj; thene (include "tenant.name" .) "tenant-root"guard correctly suppresses it for the root tenant. - It is purely additive:
CiliumClusterwideNetworkPolicyegress is allow-only, so appending atoEndpointsblock only widens egress and cannot tighten the baseline; existing rules are untouched (the only other change is a trailing-whitespace cleanup on the preceding{{- end }}). - Scope is correct: egress is limited to pods matching both
app.kubernetes.io/name: vlinsertand an ancestor namespace, so it is not a general child→parent hole. The ancestor-walk limitation the PR calls out is genuinely pre-existing and mirrored identically fromvminsert, so it introduces no new bug and is correctly left out of scope.
Blockers
B1 — no test for the new egress rule (blocking)
packages/apps/tenant/ is a tested chart: it has a tests/ directory with five helm unittest suites and a make test target (helm unittest .). Under this repo's convention, a change to a template in a chart that already has a test harness needs a test, and this change ships none. This is a network egress rule — a security boundary — which is exactly the kind of behavior that should be pinned so it cannot silently regress. Testing here is also cheap and has direct precedent: the sibling suite tests/namespace_ancestor_labels_test.yaml already renders the same helper-driven ancestor logic offline, and its header comment names this very <tenant>-egress policy as the consumer of those labels.
Please add a suite targeting templates/networkpolicy.yaml that covers the full contract, not just the happy path:
- For a child tenant (e.g. release
tenant-htdevin namespacetenant-ktj), assert the egress list contains atoEndpointsentry matchingk8s:app.kubernetes.io/name: vlinsertandk8s:io.kubernetes.pod.namespace: tenant-ktj. - For a
tenant-rootrelease, assert novlinsertblock is emitted, pinning the root-tenant guard.
Since this PR touches the template, it owns its coverage: fold a matching vminsert assertion into the same suite while you are here rather than leaving it as a separate follow-up.
Non-blocking follow-ups
- (non-blocking) The PR description points at #2810 and #2171 as separately tracking the ancestor-walk limitation, but both issues are closed — so the "tracked separately" framing currently references nothing open. If that limitation still stands (the walk recovers only the immediate parent, not grandparents), it is worth tracking against an open issue.
The <tenant>-egress CiliumClusterwideNetworkPolicy opens child-tenant egress to vminsert/vlinsert/etcd/ingress in ancestor namespaces. These are allow rules on a clusterwide policy and act as a security boundary, so a silent template regression would quietly cut a child tenant's metric or log delivery. Add a helm-unittest suite for templates/networkpolicy.yaml covering the full contract: a depth-2 child tenant's egress must contain both the vlinsert and vminsert toEndpoints blocks scoped to the parent namespace, and the root tenant must emit no ancestor ingest block (guard pinned by notContains plus an exact egress-length assertion). Signed-off-by: IvanHunters <[email protected]>
|
This PR has had no activity for 60 days and was marked |
Aleksei Sviridkin (lexfrei)
left a comment
There was a problem hiding this comment.
IvanHunters NOT LGTM, but only because of the PR description. Sorry this re-review took two months. The test I asked for is in and it works, so the code side is done. What's left is the body: it goes into the merge commit as written, and a few lines in it don't match the diff.
The new test catches every break I tried. I changed the template in a scratch copy and ran the suite after each change. Renaming vlinsert, switching its selector key to app.kubernetes.io/instance, dropping its namespace label, pointing it at the tenant's own namespace, or deleting the block all fail "child tenant egress allows vlinsert and vminsert in the parent namespace". Renaming vminsert fails the same test on its second assert. Removing the root guard from the new block fails "root tenant egress emits no ancestor ingest blocks", on both the notContains and the lengthEqual.
Current main doesn't change anything here. The branch merges without conflicts, and nothing merged since July touched the ancestor blocks around the new one. On the merged tree the tenant suite passes, 12 suites and 48 tests. I rendered the chart from main and from the merged tree for a direct child of root, a depth-2 tenant and a depth-3 tenant, and compared every object. The only difference is one new entry in <tenant>-egress: pods labelled app.kubernetes.io/name: vlinsert in the ancestor namespaces, on any port, same shape as vminsert. For tenant-a-b-c those are tenant-a and tenant-a-b. The root tenant renders identically. The CI on this head ran on 2026-07-23 against a July base, so it doesn't cover current main.
The body needs four fixes before merge:
- It says "Add a third
toEndpointsblock". The policy already had three ancestor blocks (vminsert,etcd, ingress), so this is the fourth. - The CodeRabbit summary at the bottom puts the change under "Bug Fixes" and says the rules now "correctly match tenant-scoped insert pods". Nothing was mismatched before, this is a new allowance. It also adds a vendor-named section to the commit. Please delete that block. Editing the description is enough, the bot writes it back on a push, not on an edit.
- The Summary says the rules cover "any ancestor namespace", and the Notes say the gap is tracked in #2810 and #2171. Both issues were closed on 2026-07-03. Below the first level, the walk reaches every ancestor except
tenant-root, because a first-level tenant's namespace name doesn't containroot. Sotenant-a-bcan't reach avlinsertintenant-root, even when root is the nearest tenant running monitoring. My last review called this "only the immediate parent", which was wrong for depth 3 and deeper. Please describe the gap this way and link an open issue, or say it's untracked. - The test plan doesn't mention the new unit suite, and the real-world item is still unchecked. Please say whether that run happened.
Not blocking: the child test checks that both blocks exist, but not that nothing else was added. When I added - toEndpoints: [{}] for non-root tenants, which opens egress to every endpoint in the cluster, both tests still passed. A lengthEqual with count: 5 on the child's spec.egress, like the one in the root case, would catch that.
|
IvanHunters the code is done, the review from 2026-09-22 has no open points on it. Only the PR body does not match the diff yet. Can you update it? |
Summary
Tenant egress
CiliumClusterwideNetworkPolicyalready permits child tenants to reachvminsert(VictoriaMetrics ingest) andetcdand ingress controllers in any ancestor namespace.vlinsert(VictoriaLogs ingest) was missing — so a child tenant that runs its ownmonitoring-agentscannot forward container logs to a parent tenant's VictoriaLogs.Mirrors the existing
vminsertblock.Problem statement
In a chain
tenant-root → tenant-a → tenant-a-b, thetenant-a-btenant's fluent-bit (deployed viamonitoring-agents) tries to POST tovlinsert-generic.tenant-a.svc:9481(parent's VictoriaLogs). The currenttenant-a-b-egressCCNP only allows egress to ancestor namespaces forvminsert/etcd/ingress-labelled endpoints. Connections tovlinsertare dropped at L4 by Cilium.Observable as
no upstream connections availableerrors in fluent-bit, with no visible drops anywhere downstream — the dropped packets never leave the source node.Change
Add a third
toEndpointsblock matchingapp.kubernetes.io/name: vlinsertin any ancestor namespace, identical in structure to the existingvminsertblock.Test plan
helm template packages/apps/tenantfor a child tenant — verify the new block appears.kubernetesapp inside a tenant withaddons.monitoringAgents.enabled: true; verify fluent-bit logs reach the parent tenant's VictoriaLogs without manual CCNP additions.Notes
The same
splitList "-"pattern is used as in the surrounding blocks, which assumes the parent name encodes the full hierarchy via dashes — that ancestor-walk bug is tracked separately in #2810 / #2171 and is intentionally not touched here to keep this PR minimal.Release note
Summary by CodeRabbit