Skip to content

Commit b2b5301

Browse files
authored
add nxos support to match (ext-)communities on routingpolicy
Signed-off-by: Ivo Gosemann <ivo.gosemann@sap.com>
1 parent 09fa2d6 commit b2b5301

27 files changed

Lines changed: 1415 additions & 25 deletions

‎api/core/v1alpha1/groupversion_info.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,10 @@ const (
289289
const (
290290
// PrefixSetNotFoundReason indicates that a referenced PrefixSet was not found.
291291
PrefixSetNotFoundReason = "PrefixSetNotFound"
292+
// CommunitySetNotFoundReason indicates that a referenced CommunitySet was not found.
293+
CommunitySetNotFoundReason = "CommunitySetNotFound"
294+
// InvalidCommunitySetTypeReason indicates that a referenced CommunitySet is of the wrong type (standard vs extended).
295+
InvalidCommunitySetTypeReason = "InvalidCommunitySetType"
292296
// SecretNotFoundReason indicates that a referenced Secret was not found.
293297
SecretNotFoundReason = "SecretNotFound"
294298
// RemoteEndpointUnreachableReason indicates that the remote object storage endpoint is not reachable.

‎api/core/v1alpha1/routingpolicy_types.go‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ type PolicyConditions struct {
6363
// MatchPrefixSet matches routes against a PrefixSet resource.
6464
// +optional
6565
MatchPrefixSet *PrefixSetMatchCondition `json:"matchPrefixSet,omitempty"`
66+
67+
// MatchCommunitySet matches routes against a CommunitySet resource.
68+
// +optional
69+
MatchCommunitySet *CommunitySetMatchCondition `json:"matchCommunitySet,omitempty"`
70+
71+
// MatchExtendedCommunitySet matches routes against a CommunitySet resource of type Extended.
72+
// +optional
73+
MatchExtendedCommunitySet *CommunitySetMatchCondition `json:"matchExtendedCommunitySet,omitempty"`
6674
}
6775

6876
// PrefixSetMatchCondition defines the condition for matching against a PrefixSet.
@@ -73,6 +81,30 @@ type PrefixSetMatchCondition struct {
7381
PrefixSetRef LocalObjectReference `json:"prefixSetRef"`
7482
}
7583

84+
// CommunitySetMatchCondition defines the condition for matching against a CommunitySet.
85+
type CommunitySetMatchCondition struct {
86+
// CommunitySetRef references a CommunitySet in the same namespace.
87+
// The CommunitySet must exist and belong to the same device.
88+
// +required
89+
CommunitySetRef LocalObjectReference `json:"communitySetRef"`
90+
91+
// MatchSetOption defines if the route must match 'Any' or 'All' of the community members in the set.
92+
// +optional
93+
// +kubebuilder:default=Any
94+
MatchSetOption MatchSetOption `json:"matchSetOption,omitempty"`
95+
}
96+
97+
// MatchSetOption defines how a route's attributes are compared against a referenced set.
98+
// +kubebuilder:validation:Enum=Any;All
99+
type MatchSetOption string
100+
101+
const (
102+
// MatchSetOptionAny matches a route carrying at least one member of the referenced set.
103+
MatchSetOptionAny MatchSetOption = "Any"
104+
// MatchSetOptionAll matches only a route carrying every member of the referenced set.
105+
MatchSetOptionAll MatchSetOption = "All"
106+
)
107+
76108
// PolicyActions defines the actions to take when a policy statement matches.
77109
// +kubebuilder:validation:XValidation:rule="self.routeDisposition == 'AcceptRoute' || !has(self.bgpActions)",message="bgpActions cannot be specified when routeDisposition is RejectRoute"
78110
type PolicyActions struct {

‎api/core/v1alpha1/zz_generated.deepcopy.go‎

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

‎charts/network-operator/templates/crd/routingpolicies.networking.metal.ironcore.dev.yaml‎

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

‎charts/network-operator/templates/prometheus/controller-manager-metrics-monitor.yaml‎

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

‎config/crd/bases/networking.metal.ironcore.dev_routingpolicies.yaml‎

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

‎config/default/kustomization.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ resources:
2424
# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. 'WEBHOOK' components are required.
2525
- ../certmanager
2626
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
27-
#- ../prometheus
27+
- ../prometheus
2828
# [METRICS] Expose the controller manager metrics service.
2929
- metrics_service.yaml
3030
# [PROVISIONING] Expose the controller manager provisioning service.

‎config/samples/v1alpha1_routingpolicy.yaml‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,22 @@ spec:
7272
bgpActions:
7373
setASPath:
7474
asNumber: 65000
75+
- sequence: 80
76+
conditions:
77+
matchCommunitySet:
78+
communitySetRef:
79+
name: communityset-regular
80+
matchSetOptions: All
81+
actions:
82+
routeDisposition: AcceptRoute
83+
- sequence: 90
84+
conditions:
85+
matchExtendedCommunitySet:
86+
communitySetRef:
87+
name: communityset-extended
88+
matchSetOptions: All
89+
actions:
90+
routeDisposition: AcceptRoute
7591
- sequence: 100
7692
actions:
7793
routeDisposition: AcceptRoute
@@ -129,3 +145,39 @@ spec:
129145
maskLengthRange:
130146
min: 25
131147
max: 32
148+
---
149+
apiVersion: networking.metal.ironcore.dev/v1alpha1
150+
kind: CommunitySet
151+
metadata:
152+
labels:
153+
app.kubernetes.io/name: network-operator
154+
app.kubernetes.io/managed-by: kustomize
155+
name: communityset-regular
156+
spec:
157+
deviceRef:
158+
name: leaf1
159+
name: example-communityset
160+
type: Standard
161+
members:
162+
- sequence: 5
163+
regex: "50000:[0-9][0-9]"
164+
- sequence: 10
165+
regex: "65001:[0-9]+"
166+
---
167+
apiVersion: networking.metal.ironcore.dev/v1alpha1
168+
kind: CommunitySet
169+
metadata:
170+
labels:
171+
app.kubernetes.io/name: network-operator
172+
app.kubernetes.io/managed-by: kustomize
173+
name: communityset-extended
174+
spec:
175+
deviceRef:
176+
name: leaf1
177+
name: example-extcommunityset
178+
type: Extended
179+
members:
180+
- sequence: 5
181+
regex: "65200:[0-9][0-9]"
182+
- sequence: 15
183+
regex: "65300:[0-9]+"

0 commit comments

Comments
 (0)