Skip to content

Commit 6af081c

Browse files
feat(vpc): expose allowSubnets per subnet
Every VPC subnet is rendered private, so kube-ovn drops any packet whose source lies outside the subnet's own CIDR. A tenant that runs a VPN or router VM on a subnet and points a static route at it gets the forward path from the existing routes value, but traffic arriving from the remote network is then dropped by the private ACL. Subnet is cluster-scoped, so the only workaround so far has been an operator patching spec.allowSubnets by hand: something the tenant cannot do, that no application value records, and that is lost whenever the subnet is recreated. Declaring it per subnet keeps the widening in the tenant's own VPC and scoped to the one subnet that needs it. Assisted-by: LLM Signed-off-by: Mattia Eleuteri <[email protected]>
1 parent 6748014 commit 6af081c

8 files changed

Lines changed: 117 additions & 2 deletions

File tree

‎api/apps/v1alpha1/vpc/types.go‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎api/apps/v1alpha1/vpc/zz_generated.deepcopy.go‎

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/apps/vpc/Makefile‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ generate:
66

77
update:
88
echo
9+
10+
test:
11+
helm unittest .

‎packages/apps/vpc/templates/vpc.yaml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ spec:
8181
protocol: IPv4
8282
enableLb: false
8383
private: true
84+
{{- with .allowSubnets }}
85+
allowSubnets:
86+
{{- range . }}
87+
- {{ . | quote }}
88+
{{- end }}
89+
{{- end }}
8490
{{- end }}
8591
---
8692
apiVersion: v1
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
suite: kube-ovn Subnet rendering
2+
3+
templates:
4+
- templates/vpc.yaml
5+
6+
release:
7+
name: virtualprivatecloud-myvpc
8+
namespace: tenant-test
9+
10+
tests:
11+
- it: renders no allowSubnets on a subnet that declares none
12+
set:
13+
subnets:
14+
- name: plain
15+
cidr: "172.16.0.0/24"
16+
asserts:
17+
- notExists:
18+
path: spec.allowSubnets
19+
documentSelector:
20+
path: spec.cidrBlock
21+
value: "172.16.0.0/24"
22+
- equal:
23+
path: spec.private
24+
value: true
25+
documentSelector:
26+
path: spec.cidrBlock
27+
value: "172.16.0.0/24"
28+
29+
- it: admits the declared CIDRs into the subnet while keeping it private
30+
set:
31+
subnets:
32+
- name: gateway
33+
cidr: "172.16.1.0/24"
34+
allowSubnets:
35+
- "192.168.1.0/24"
36+
- "10.20.0.0/16"
37+
asserts:
38+
- equal:
39+
path: spec.allowSubnets
40+
value:
41+
- "192.168.1.0/24"
42+
- "10.20.0.0/16"
43+
documentSelector:
44+
path: spec.cidrBlock
45+
value: "172.16.1.0/24"
46+
- equal:
47+
path: spec.private
48+
value: true
49+
documentSelector:
50+
path: spec.cidrBlock
51+
value: "172.16.1.0/24"
52+
53+
- it: scopes allowSubnets to the subnet that declares it
54+
set:
55+
subnets:
56+
- name: plain
57+
cidr: "172.16.0.0/24"
58+
- name: gateway
59+
cidr: "172.16.1.0/24"
60+
allowSubnets:
61+
- "192.168.1.0/24"
62+
asserts:
63+
- notExists:
64+
path: spec.allowSubnets
65+
documentSelector:
66+
path: spec.cidrBlock
67+
value: "172.16.0.0/24"
68+
- equal:
69+
path: spec.allowSubnets
70+
value:
71+
- "192.168.1.0/24"
72+
documentSelector:
73+
path: spec.cidrBlock
74+
value: "172.16.1.0/24"
75+
76+
- it: treats an empty allowSubnets list as unset
77+
set:
78+
subnets:
79+
- name: plain
80+
cidr: "172.16.0.0/24"
81+
allowSubnets: []
82+
asserts:
83+
- notExists:
84+
path: spec.allowSubnets
85+
documentSelector:
86+
path: spec.cidrBlock
87+
value: "172.16.0.0/24"

‎packages/apps/vpc/values.schema.json‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212
"name"
1313
],
1414
"properties": {
15+
"allowSubnets": {
16+
"description": "Additional source CIDRs admitted into this private subnet, such as remote networks routed in through a gateway VM",
17+
"type": "array",
18+
"items": {
19+
"type": "string"
20+
}
21+
},
1522
"cidr": {
1623
"description": "IP address range",
1724
"type": "string"

‎packages/apps/vpc/values.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
## @typedef {struct} Subnet - Subnet of a VPC
66
## @field {string} name - Subnet name
77
## @field {string} [cidr] - IP address range
8+
## @field {[]string} [allowSubnets] - Additional source CIDRs admitted into this private subnet, such as remote networks routed in through a gateway VM
89

910
## @param {[]Subnet} subnets - Subnets of a VPC
1011
subnets: []
@@ -14,6 +15,8 @@ subnets: []
1415
## cidr: "172.16.0.0/24"
1516
## - name: mysubnet1
1617
## cidr: "172.16.1.0/24"
18+
## allowSubnets:
19+
## - "192.168.1.0/24"
1720

1821
## @typedef {struct} Peer - VPC peering target
1922
## @field {string} vpcName - Logical name of the remote VPC (without "virtualprivatecloud-" prefix)

‎packages/system/virtualprivatecloud-rd/cozyrds/virtualprivatecloud.yaml‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)