Skip to content

Commit a141665

Browse files
committed
fix(tenant): allow tenant egress to the KubeVirt export proxy
The vm-exportproxy Ingress is served by the ingress controller in tenant-root, and tenant egress is default-deny. Nothing allowed traffic to virt-exportproxy in cozy-kubevirt, so the Ingress stayed unreachable even with the right backend Service. The new policy renders wherever allow-to-cdi-upload-proxy does, but narrows the destination to the export proxy pods and their container port. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent 1e81164 commit a141665

2 files changed

Lines changed: 102 additions & 0 deletions

File tree

‎packages/apps/tenant/templates/networkpolicy.yaml‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,23 @@ spec:
241241
- toEndpoints:
242242
- matchLabels:
243243
"k8s:io.kubernetes.pod.namespace": cozy-kubevirt-cdi
244+
---
245+
apiVersion: cilium.io/v2
246+
kind: CiliumNetworkPolicy
247+
metadata:
248+
name: allow-to-vm-exportproxy
249+
namespace: {{ include "tenant.name" . }}
250+
spec:
251+
endpointSelector: {}
252+
egress:
253+
- toEndpoints:
254+
- matchLabels:
255+
"k8s:io.kubernetes.pod.namespace": cozy-kubevirt
256+
kubevirt.io: virt-exportproxy
257+
toPorts:
258+
- ports:
259+
- port: "8443"
260+
protocol: TCP
244261
{{- if .Values.monitoring }}
245262
---
246263
apiVersion: cilium.io/v2
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
suite: tenant egress to the KubeVirt export proxy
2+
# The vm-exportproxy Ingress in cozy-kubevirt is served by the ingress
3+
# controller running in tenant-root. Tenant egress is default-deny plus
4+
# explicit allow-to-* policies, so without this one the controller cannot
5+
# reach virt-exportproxy. It follows allow-to-cdi-upload-proxy, the policy for
6+
# the sibling CDI upload proxy, in where and when it renders.
7+
templates:
8+
- templates/networkpolicy.yaml
9+
tests:
10+
- it: renders next to allow-to-cdi-upload-proxy in the root tenant
11+
release:
12+
name: tenant-root
13+
namespace: tenant-root
14+
asserts:
15+
- documentSelector:
16+
path: metadata.name
17+
value: allow-to-cdi-upload-proxy
18+
equal:
19+
path: metadata.namespace
20+
value: tenant-root
21+
- documentSelector:
22+
path: metadata.name
23+
value: allow-to-vm-exportproxy
24+
isKind:
25+
of: CiliumNetworkPolicy
26+
- documentSelector:
27+
path: metadata.name
28+
value: allow-to-vm-exportproxy
29+
equal:
30+
path: metadata.namespace
31+
value: tenant-root
32+
33+
- it: renders next to allow-to-cdi-upload-proxy in a nested tenant with every module off
34+
release:
35+
name: tenant-bar
36+
namespace: tenant-foo
37+
set:
38+
monitoring: false
39+
ingress: false
40+
etcd: false
41+
asserts:
42+
- documentSelector:
43+
path: metadata.name
44+
value: allow-to-cdi-upload-proxy
45+
equal:
46+
path: metadata.namespace
47+
value: tenant-foo-bar
48+
- documentSelector:
49+
path: metadata.name
50+
value: allow-to-vm-exportproxy
51+
equal:
52+
path: metadata.namespace
53+
value: tenant-foo-bar
54+
55+
- it: applies to every pod of the tenant, as allow-to-cdi-upload-proxy does
56+
release:
57+
name: tenant-root
58+
namespace: tenant-root
59+
asserts:
60+
- documentSelector:
61+
path: metadata.name
62+
value: allow-to-vm-exportproxy
63+
equal:
64+
path: spec.endpointSelector
65+
value: {}
66+
67+
- it: allows only the export proxy pods on their container port
68+
release:
69+
name: tenant-root
70+
namespace: tenant-root
71+
asserts:
72+
- documentSelector:
73+
path: metadata.name
74+
value: allow-to-vm-exportproxy
75+
equal:
76+
path: spec.egress
77+
value:
78+
- toEndpoints:
79+
- matchLabels:
80+
"k8s:io.kubernetes.pod.namespace": cozy-kubevirt
81+
kubevirt.io: virt-exportproxy
82+
toPorts:
83+
- ports:
84+
- port: "8443"
85+
protocol: TCP

0 commit comments

Comments
 (0)