Skip to content

Commit a71f526

Browse files
committed
feat: define CRDs for VRF type
In this commit we define VRF type. A VRF is composed by a single route distinguisher (RD), and a set of route targets (RTs). Each route target is composed by the address families it affects, an action for it (e.g., import or export), and wether the RT is to be applied to the EVPN context.
1 parent 221d0a1 commit a71f526

File tree

10 files changed

+544
-0
lines changed

10 files changed

+544
-0
lines changed

api/v1alpha1/vrf_types.go

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
// SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and IronCore contributors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package v1alpha1
5+
6+
import (
7+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
8+
)
9+
10+
// VRFSpec defines the basic structure of a Virtual Routing and Forwarding (VRF) instance/context. A single VRF instance
11+
// has a single Route Distinguisher (RD) and a set of Route Targets (RT). RTs control the import and export of routes
12+
// among different VRFs.
13+
type VRFSpec struct {
14+
// Name defines the name of the VRF.
15+
//
16+
// +required
17+
Name *string `json:"foo,omitempty"`
18+
19+
// RD defines the Route Distinguisher (RD) for the VRF as per RFC 4364
20+
//
21+
// +kubebuilder:validation:Pattern=`^([0-9]+:[0-9]+|([0-9]{1,3}\.){3}[0-9]{1,3}:[0-9]+)$`
22+
RD *string `json:"routeDistinguisher,omitempty"`
23+
24+
// RTs defines the list of Route Targets (RTs) associated with the VRF.
25+
26+
RTs []RouteTarget `json:"routeTargets,omitempty"`
27+
}
28+
29+
// VRFStatus defines the observed state of VRF.
30+
type VRFStatus struct {
31+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
32+
// Important: Run "make" to regenerate code after modifying this file
33+
// The conditions are a list of status objects that describe the state of the Interface.
34+
//+listType=map
35+
//+listMapKey=type
36+
//+patchStrategy=merge
37+
//+patchMergeKey=type
38+
//+optional
39+
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
40+
}
41+
42+
// +kubebuilder:object:root=true
43+
// +kubebuilder:subresource:status
44+
45+
// VRF is the Schema for the vrves API
46+
type VRF struct {
47+
metav1.TypeMeta `json:",inline"`
48+
49+
// metadata is a standard object metadata
50+
// +optional
51+
metav1.ObjectMeta `json:"metadata,omitempty,omitzero"`
52+
53+
// spec defines the desired state of VRF
54+
// +required
55+
Spec VRFSpec `json:"spec"`
56+
57+
// status defines the observed state of VRF
58+
// +optional
59+
Status VRFStatus `json:"status,omitempty,omitzero"`
60+
}
61+
62+
// +kubebuilder:object:root=true
63+
64+
// VRFList contains a list of VRF
65+
type VRFList struct {
66+
metav1.TypeMeta `json:",inline"`
67+
metav1.ListMeta `json:"metadata,omitempty"`
68+
Items []VRF `json:"items"`
69+
}
70+
71+
// RouteTarget defines the structure for a single route target in a VRF.
72+
type RouteTarget struct {
73+
74+
// Value specifies the Route Target (RT) value as per RFC 4364.
75+
//
76+
// +kubebuilder:validation:Pattern=`^([0-9]+:[0-9]+|([0-9]{1,3}\.){3}[0-9]{1,3}:[0-9]+)$`
77+
Value string `json:"value,omitempty"`
78+
79+
// AddressFamily specifies the address families for the Route Target.
80+
//
81+
// +kubebuilder:validation:Enum=ipv4;ipv6
82+
// +kubebuilder:validation:XValidation:rule="self.addressFamily == null || self.addressFamily.size() == self.addressFamily.distinct().size()",message="addressFamily must not contain duplicates"
83+
AddressFamilies []AddressFamily `json:"addressFamily,omitempty"`
84+
85+
// Action specifies the action to be taken for the Route Target.
86+
//
87+
// +kubebuilder:validation:Enum=none;import;export;both
88+
Action RTAction `json:"action,omitempty"`
89+
90+
// EVPN specifies whether we should also add -or not- the EVPN route-target
91+
//
92+
// +kubebuilder:validation:Enum=add;ignore
93+
EVPN EVPNAction `json:"evpn,omitempty"`
94+
}
95+
96+
type AddressFamily string
97+
98+
const (
99+
AddressFamilyIPv4 AddressFamily = "ipv4"
100+
AddressFamilyIPv6 AddressFamily = "ipv6"
101+
)
102+
103+
type RTAction string
104+
105+
const (
106+
RTNone RTAction = "none"
107+
RTImport RTAction = "import"
108+
RTExport RTAction = "export"
109+
RTBoth RTAction = "both"
110+
)
111+
112+
type EVPNAction string
113+
114+
const (
115+
EVPNAdd EVPNAction = "add"
116+
EVPNIgnore EVPNAction = "ignore"
117+
)
118+
119+
func init() {
120+
SchemeBuilder.Register(&VRF{}, &VRFList{})
121+
}

api/v1alpha1/zz_generated.deepcopy.go

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

0 commit comments

Comments
 (0)