You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/vpc/security-group.en.md
+109-1Lines changed: 109 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,10 +41,118 @@ Pods bind security groups by adding the `ovn.kubernetes.io/security_groups` anno
41
41
42
42
For port security feature, please refer to the [Port Security documentation](../guide/port-security.en.md).
43
43
44
+
## Tiered Security Groups
45
+
46
+
Security groups support multi-tier ACL processing via the optional `tier` field. This allows you to stack multiple security groups to perform hierarchical ACL evaluation.
47
+
48
+
- **`tier`**: An integer value of `0` or `1` (default `0`). Rules in tier `0` are evaluated first. If a rule in tier `0` matches with `policy: pass`, ACL processing continues to tier `1`.
49
+
- **`policy: pass`**: A policy action (in addition to `allow` and `deny`) that forwards packet evaluation to the next tier instead of making a final decision. The `pass` policy cannot be used when the security group tier is set to the maximum value (`1`), since there is no subsequent tier to pass to.
50
+
51
+
This enables use cases such as a broad tier-0 security group that passes certain traffic to a more specific tier-1 security group for further filtering.
52
+
53
+
### Tiered SecurityGroup Example
54
+
55
+
Create two security groups, one for each tier:
56
+
57
+
```yaml
58
+
apiVersion: kubeovn.io/v1
59
+
kind: SecurityGroup
60
+
metadata:
61
+
name: sg-tier0
62
+
spec:
63
+
tier: 0
64
+
allowSameGroupTraffic: true
65
+
ingressRules:
66
+
- ipVersion: ipv4
67
+
policy: pass
68
+
priority: 1
69
+
protocol: tcp
70
+
remoteAddress: 10.16.0.0/16
71
+
remoteType: address
72
+
- ipVersion: ipv4
73
+
policy: deny
74
+
priority: 2
75
+
protocol: all
76
+
remoteAddress: 0.0.0.0/0
77
+
remoteType: address
78
+
---
79
+
apiVersion: kubeovn.io/v1
80
+
kind: SecurityGroup
81
+
metadata:
82
+
name: sg-tier1
83
+
spec:
84
+
tier: 1
85
+
allowSameGroupTraffic: true
86
+
ingressRules:
87
+
- ipVersion: ipv4
88
+
policy: allow
89
+
priority: 1
90
+
protocol: tcp
91
+
remoteAddress: 10.16.0.0/16
92
+
remoteType: address
93
+
portRangeMin: 80
94
+
portRangeMax: 443
95
+
```
96
+
97
+
In this example, `sg-tier0` passes all TCP traffic from `10.16.0.0/16` to tier 1 and denies everything else. `sg-tier1` then only allows TCP traffic on ports 80–443 from that same range.
98
+
99
+
To apply both security groups to a Pod, list them as a comma-separated value in the annotation:
Security group rules support optional `localAddress` and source port range fields for more granular matching:
122
+
123
+
- **`localAddress`**: A local IP address or CIDR to match against. This allows rules to apply only when the local (source for egress, destination for ingress) address matches.
124
+
- **`sourcePortRangeMin`** / **`sourcePortRangeMax`**: Define a source port range (1–65535) to match against. These are only applicable for TCP and UDP protocols.
125
+
126
+
### Local Address Filtering Example
127
+
128
+
```yaml
129
+
apiVersion: kubeovn.io/v1
130
+
kind: SecurityGroup
131
+
metadata:
132
+
name: sg-local-filter
133
+
spec:
134
+
allowSameGroupTraffic: true
135
+
ingressRules:
136
+
- ipVersion: ipv4
137
+
policy: allow
138
+
priority: 1
139
+
protocol: tcp
140
+
remoteAddress: 10.16.0.0/16
141
+
remoteType: address
142
+
portRangeMin: 8080
143
+
portRangeMax: 8080
144
+
localAddress: 10.16.0.100
145
+
sourcePortRangeMin: 1024
146
+
sourcePortRangeMax: 65535
147
+
```
148
+
149
+
This rule allows inbound TCP traffic to `10.16.0.100` on port 8080 from `10.16.0.0/16` with source ports in the range 1024–65535.
150
+
44
151
## Caution
45
152
46
153
- Security groups are implemented by setting ACL rules. As mentioned in the OVN documentation, if two ACL rules match with the same priority, it is uncertain which ACL will actually work. Therefore, when setting up security group rules, you need to be careful to differentiate the priority.
47
-
- When configuring a security group, the `priority` value ranges from 1 to 200, with smaller values indicating higher priority. When implementing a security group through ACLs, the security group's priority is mapped to the ACL priority. The specific mapping relationship is as follows: ACL priority = 2300 - Security group priority, therefore, it is essential to distinguish between the priorities of security groups and subnet ACLs.
154
+
- When configuring a security group, the `priority` value ranges from 1 to 16384, with smaller values indicating higher priority. When implementing a security group through ACLs, the security group's priority is mapped to the ACL priority. Therefore, it is essential to distinguish between the priorities of security groups and subnet ACLs.
155
+
- The `tier` field accepts values `0` or `1`. The `policy: pass` action is only valid in tier `0`; using it in tier `1` will result in a validation error.
48
156
- When adding a security group, it is important to know what restrictions are being added. As a CNI, Kube-OVN will perform a Pod-to-Gateway connectivity test after creating a Pod. If the gateway is not accessible, the Pod will remain in the ContainerCreating state and cannot switch to Running state.
0 commit comments