|
| 1 | +suite: tenant egress to ancestor observability ingest |
| 2 | +# The <tenant>-egress CiliumClusterwideNetworkPolicy (networkpolicy.yaml) |
| 3 | +# opens child-tenant egress to a fixed set of ancestor-namespace services: |
| 4 | +# vminsert (VictoriaMetrics ingest), vlinsert (VictoriaLogs ingest), etcd, |
| 5 | +# and ingress controllers. A child tenant running monitoring-agents relies |
| 6 | +# on these allowances to ship metrics and container logs up to a parent |
| 7 | +# tenant's observability stack with no hand-edited CCNP. |
| 8 | +# |
| 9 | +# vlinsert is a security boundary: it is an allow rule on a clusterwide |
| 10 | +# policy, so a silent template regression would quietly cut a child |
| 11 | +# tenant's log delivery (observed as fluent-bit "no upstream connections |
| 12 | +# available", with the drop invisible downstream because the packet never |
| 13 | +# leaves the source node). Pin it here alongside vminsert so neither block |
| 14 | +# can disappear or drift its selector unnoticed. |
| 15 | +# |
| 16 | +# The ancestor namespace is derived from the release namespace by a pure |
| 17 | +# splitList/join walk (no cluster lookup), so helm-unittest renders it |
| 18 | +# offline. Depth-2 child tenant-htdev in namespace tenant-ktj resolves its |
| 19 | +# single ancestor to tenant-ktj. |
| 20 | +templates: |
| 21 | + - templates/networkpolicy.yaml |
| 22 | +set: |
| 23 | + _cluster: |
| 24 | + root-host: example.com |
| 25 | +tests: |
| 26 | + - it: child tenant egress allows vlinsert and vminsert in the parent namespace |
| 27 | + release: |
| 28 | + name: tenant-htdev |
| 29 | + namespace: tenant-ktj |
| 30 | + asserts: |
| 31 | + - documentSelector: |
| 32 | + path: metadata.name |
| 33 | + value: tenant-ktj-htdev-egress |
| 34 | + contains: |
| 35 | + path: spec.egress |
| 36 | + content: |
| 37 | + toEndpoints: |
| 38 | + - matchLabels: |
| 39 | + "k8s:app.kubernetes.io/name": "vlinsert" |
| 40 | + "k8s:io.kubernetes.pod.namespace": tenant-ktj |
| 41 | + - documentSelector: |
| 42 | + path: metadata.name |
| 43 | + value: tenant-ktj-htdev-egress |
| 44 | + contains: |
| 45 | + path: spec.egress |
| 46 | + content: |
| 47 | + toEndpoints: |
| 48 | + - matchLabels: |
| 49 | + "k8s:app.kubernetes.io/name": "vminsert" |
| 50 | + "k8s:io.kubernetes.pod.namespace": tenant-ktj |
| 51 | + |
| 52 | + - it: root tenant egress emits no ancestor ingest blocks |
| 53 | + # The `ne (include "tenant.name" .) "tenant-root"` guard must suppress |
| 54 | + # every ancestor-egress block for the root tenant, which has no ancestor |
| 55 | + # to reach. Its egress list carries only the self-namespace allow, so a |
| 56 | + # broken guard (which would emit vlinsert scoped to tenant-root) is |
| 57 | + # caught both by the explicit notContains and by the exact length pin. |
| 58 | + release: |
| 59 | + name: tenant-root |
| 60 | + namespace: tenant-root |
| 61 | + asserts: |
| 62 | + - documentSelector: |
| 63 | + path: metadata.name |
| 64 | + value: tenant-root-egress |
| 65 | + notContains: |
| 66 | + path: spec.egress |
| 67 | + content: |
| 68 | + toEndpoints: |
| 69 | + - matchLabels: |
| 70 | + "k8s:app.kubernetes.io/name": "vlinsert" |
| 71 | + "k8s:io.kubernetes.pod.namespace": tenant-root |
| 72 | + - documentSelector: |
| 73 | + path: metadata.name |
| 74 | + value: tenant-root-egress |
| 75 | + lengthEqual: |
| 76 | + path: spec.egress |
| 77 | + count: 1 |
0 commit comments