Skip to content

Commit 501bde5

Browse files
feat: introduce subinterface interface type
Add a new "subinterface" interface type to support Layer 3 subinterfaces. Layer 3 subinterfaces allow a single physical router interface to handle traffic from multiple VLANs by creating separate logical interfaces per VLAN. Validation rules: - Encapsulation is allowed for subinterfaces only - Supported encapsulation types: 802.1Q and 802.1ad - Validate VLAN ID range - 802.1ad requires two VLAN IDs (outer and inner VLAN) - Subinterfaces cannot be configured as aggregate, switchport, or vlanRef
1 parent 8ae519b commit 501bde5

5 files changed

Lines changed: 250 additions & 3 deletions

File tree

‎api/core/v1alpha1/interface_types.go‎

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ import (
2525
// +kubebuilder:validation:XValidation:rule="self.type != 'Aggregate' || !has(self.switchport) || !has(self.vrfRef)", message="vrfRef must not be specified for Aggregate interfaces with switchport configuration"
2626
// +kubebuilder:validation:XValidation:rule="self.type != 'Physical' || !has(self.switchport) || !has(self.vrfRef)", message="vrfRef must not be specified for Physical interfaces with switchport configuration"
2727
// +kubebuilder:validation:XValidation:rule="self.type != 'Aggregate' || !has(self.switchport) || !has(self.bfd)", message="bfd must not be specified for Aggregate interfaces with switchport configuration"
28+
// +kubebuilder:validation:XValidation:rule="self.type == 'Subinterface' || !(has(self.encapsulation) || has(self.parentInterfaceRef))", message="encapsulation and parentInterfaceRef must only be specified for subinterfaces"
29+
// +kubebuilder:validation:XValidation:rule="self.type != 'Subinterface' || !(has(self.aggregation) || has(self.switchport) || has(self.vlanRef))", message="subinterface must not have aggregation, switchport or vlanRef configuration"
30+
// +kubebuilder:validation:XValidation:rule="self.type != 'Subinterface' || (has(self.encapsulation) && has(self.parentInterfaceRef))", message="encapsulation and parentInterfaceRef must both be specified for subinterfaces"
2831
// +kubebuilder:validation:XValidation:rule="!has(self.bfd) || !has(self.switchport)", message="bfd must not be specified for interfaces with switchport configuration"
2932
// +kubebuilder:validation:XValidation:rule="self.type == 'Physical' || !has(self.ethernet)", message="ethernet configuration must only be specified on interfaces of type Physical"
3033
type InterfaceSpec struct {
@@ -104,6 +107,15 @@ type InterfaceSpec struct {
104107
// When omitted, ethernet parameters use their default values (e.g., FEC mode defaults to auto).
105108
// +optional
106109
Ethernet *Ethernet `json:"ethernet,omitempty"`
110+
111+
// Encapsulation defines the subinterfaces config for an L3 interface.
112+
// +optional
113+
Encapsulation *Encapsulation `json:"encapsulation,omitempty"`
114+
115+
// ParentInterfaceRef is a reference to the parent interface for this subinterface.
116+
// Required if the interface type is Subinterface. Must not be set for other interface types.
117+
// +optional
118+
ParentInterfaceRef *LocalObjectReference `json:"parentInterfaceRef,omitempty"`
107119
}
108120

109121
// AdminState represents the administrative state of a resource.
@@ -120,7 +132,7 @@ const (
120132
)
121133

122134
// InterfaceType represents the type of the interface.
123-
// +kubebuilder:validation:Enum=Physical;Loopback;Aggregate;RoutedVLAN
135+
// +kubebuilder:validation:Enum=Physical;Loopback;Aggregate;RoutedVLAN;Subinterface
124136
type InterfaceType string
125137

126138
const (
@@ -132,6 +144,8 @@ const (
132144
InterfaceTypeAggregate InterfaceType = "Aggregate"
133145
// InterfaceTypeRoutedVLAN indicates that the interface is a routed VLAN interface (SVI/IRB).
134146
InterfaceTypeRoutedVLAN InterfaceType = "RoutedVLAN"
147+
// InterfaceTypeSubinterface indicates that the interface is a subinterface of an interface.
148+
InterfaceTypeSubinterface InterfaceType = "Subinterface"
135149
)
136150

137151
// Switchport defines the switchport configuration for an interface.
@@ -165,6 +179,42 @@ type Switchport struct {
165179
AllowedVlans []int32 `json:"allowedVlans,omitempty"`
166180
}
167181

182+
// +kubebuilder:validation:Enum="802.1q";"802.1ad"
183+
type EncapType string
184+
185+
const (
186+
// EncapsulationTypeDot1Q indicates IEEE 802.1Q encapsulation.
187+
EncapsulationTypeDot1Q EncapType = "802.1q"
188+
// EncapsulationTypeQinQ indicates IEEE 802.1ad encapsulation.
189+
EncapsulationTypeQinQ EncapType = "802.1ad"
190+
)
191+
192+
// Encapsulation defines config for an L3 subinterface.
193+
// +kubebuilder:validation:XValidation:rule="self.type != '802.1q' || has(self.tag)", message="tag must be specified for interfaces of type 802.1q"
194+
// +kubebuilder:validation:XValidation:rule="self.type != '802.1ad' || (has(self.innerTag) && has(self.outerTag))", message="innerTag and outerTag must be specified for interfaces of type 802.1ad"
195+
type Encapsulation struct {
196+
// +required
197+
Type EncapType `json:"type"`
198+
// +optional
199+
// +kubebuilder:validation:Minimum=1
200+
// +kubebuilder:validation:Maximum=4094
201+
Tag int32 `json:"tag"`
202+
203+
// InnerTag specifies the inner VLAN ID for QinQ encapsulation.
204+
// Only applicable when Type is set to "QinQ".
205+
// +optional
206+
// +kubebuilder:validation:Minimum=1
207+
// +kubebuilder:validation:Maximum=4094
208+
InnerTag int32 `json:"innerTag,omitempty"`
209+
210+
// OuterTag specifies the outer VLAN ID for QinQ encapsulation.
211+
// Only applicable when Type is set to "QinQ".
212+
// +optional
213+
// +kubebuilder:validation:Minimum=1
214+
// +kubebuilder:validation:Maximum=4094
215+
OuterTag int32 `json:"outerTag,omitempty"`
216+
}
217+
168218
// SwitchportMode represents the switchport mode of an interface.
169219
// +kubebuilder:validation:Enum=Access;Trunk
170220
type SwitchportMode string

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

Lines changed: 25 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/interfaces.networking.metal.ironcore.dev.yaml‎

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,45 @@ spec:
217217
x-kubernetes-validations:
218218
- message: DeviceRef is immutable
219219
rule: self == oldSelf
220+
encapsulation:
221+
description: Encapsulation defines the subinterfaces config for an
222+
L3 interface.
223+
properties:
224+
innerTag:
225+
description: |-
226+
InnerTag specifies the inner VLAN ID for QinQ encapsulation.
227+
Only applicable when Type is set to "QinQ".
228+
format: int32
229+
maximum: 4094
230+
minimum: 1
231+
type: integer
232+
outerTag:
233+
description: |-
234+
OuterTag specifies the outer VLAN ID for QinQ encapsulation.
235+
Only applicable when Type is set to "QinQ".
236+
format: int32
237+
maximum: 4094
238+
minimum: 1
239+
type: integer
240+
tag:
241+
format: int32
242+
maximum: 4094
243+
minimum: 1
244+
type: integer
245+
type:
246+
enum:
247+
- 802.1q
248+
- 802.1ad
249+
type: string
250+
required:
251+
- type
252+
type: object
253+
x-kubernetes-validations:
254+
- message: tag must be specified for interfaces of type 802.1q
255+
rule: self.type != '802.1q' || has(self.tag)
256+
- message: innerTag and outerTag must be specified for interfaces
257+
of type 802.1ad
258+
rule: self.type != '802.1ad' || (has(self.innerTag) && has(self.outerTag))
220259
ethernet:
221260
description: |-
222261
Ethernet defines the ethernet-specific configuration for physical interfaces.
@@ -301,6 +340,22 @@ spec:
301340
x-kubernetes-validations:
302341
- message: Name is immutable
303342
rule: self == oldSelf
343+
parentInterfaceRef:
344+
description: |-
345+
ParentInterfaceRef is a reference to the parent interface for this subinterface.
346+
Required if the interface type is Subinterface. Must not be set for other interface types.
347+
properties:
348+
name:
349+
description: |-
350+
Name of the referent.
351+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
352+
maxLength: 63
353+
minLength: 1
354+
type: string
355+
required:
356+
- name
357+
type: object
358+
x-kubernetes-map-type: atomic
304359
providerConfigRef:
305360
description: |-
306361
ProviderConfigRef is a reference to a resource holding the provider-specific configuration of this interface.
@@ -388,6 +443,7 @@ spec:
388443
- Loopback
389444
- Aggregate
390445
- RoutedVLAN
446+
- Subinterface
391447
type: string
392448
x-kubernetes-validations:
393449
- message: Type is immutable
@@ -466,6 +522,16 @@ spec:
466522
- message: bfd must not be specified for Aggregate interfaces with switchport
467523
configuration
468524
rule: self.type != 'Aggregate' || !has(self.switchport) || !has(self.bfd)
525+
- message: encapsulation and parentInterfaceRef must only be specified
526+
for subinterfaces
527+
rule: self.type == 'Subinterface' || !(has(self.encapsulation) || has(self.parentInterfaceRef))
528+
- message: subinterface must not have aggregation, switchport or vlanRef
529+
configuration
530+
rule: self.type != 'Subinterface' || !(has(self.aggregation) || has(self.switchport)
531+
|| has(self.vlanRef))
532+
- message: encapsulation and parentInterfaceRef must both be specified
533+
for subinterfaces
534+
rule: self.type != 'Subinterface' || (has(self.encapsulation) && has(self.parentInterfaceRef))
469535
- message: bfd must not be specified for interfaces with switchport configuration
470536
rule: '!has(self.bfd) || !has(self.switchport)'
471537
- message: ethernet configuration must only be specified on interfaces

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

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,45 @@ spec:
214214
x-kubernetes-validations:
215215
- message: DeviceRef is immutable
216216
rule: self == oldSelf
217+
encapsulation:
218+
description: Encapsulation defines the subinterfaces config for an
219+
L3 interface.
220+
properties:
221+
innerTag:
222+
description: |-
223+
InnerTag specifies the inner VLAN ID for QinQ encapsulation.
224+
Only applicable when Type is set to "QinQ".
225+
format: int32
226+
maximum: 4094
227+
minimum: 1
228+
type: integer
229+
outerTag:
230+
description: |-
231+
OuterTag specifies the outer VLAN ID for QinQ encapsulation.
232+
Only applicable when Type is set to "QinQ".
233+
format: int32
234+
maximum: 4094
235+
minimum: 1
236+
type: integer
237+
tag:
238+
format: int32
239+
maximum: 4094
240+
minimum: 1
241+
type: integer
242+
type:
243+
enum:
244+
- 802.1q
245+
- 802.1ad
246+
type: string
247+
required:
248+
- type
249+
type: object
250+
x-kubernetes-validations:
251+
- message: tag must be specified for interfaces of type 802.1q
252+
rule: self.type != '802.1q' || has(self.tag)
253+
- message: innerTag and outerTag must be specified for interfaces
254+
of type 802.1ad
255+
rule: self.type != '802.1ad' || (has(self.innerTag) && has(self.outerTag))
217256
ethernet:
218257
description: |-
219258
Ethernet defines the ethernet-specific configuration for physical interfaces.
@@ -298,6 +337,22 @@ spec:
298337
x-kubernetes-validations:
299338
- message: Name is immutable
300339
rule: self == oldSelf
340+
parentInterfaceRef:
341+
description: |-
342+
ParentInterfaceRef is a reference to the parent interface for this subinterface.
343+
Required if the interface type is Subinterface. Must not be set for other interface types.
344+
properties:
345+
name:
346+
description: |-
347+
Name of the referent.
348+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
349+
maxLength: 63
350+
minLength: 1
351+
type: string
352+
required:
353+
- name
354+
type: object
355+
x-kubernetes-map-type: atomic
301356
providerConfigRef:
302357
description: |-
303358
ProviderConfigRef is a reference to a resource holding the provider-specific configuration of this interface.
@@ -385,6 +440,7 @@ spec:
385440
- Loopback
386441
- Aggregate
387442
- RoutedVLAN
443+
- Subinterface
388444
type: string
389445
x-kubernetes-validations:
390446
- message: Type is immutable
@@ -463,6 +519,16 @@ spec:
463519
- message: bfd must not be specified for Aggregate interfaces with switchport
464520
configuration
465521
rule: self.type != 'Aggregate' || !has(self.switchport) || !has(self.bfd)
522+
- message: encapsulation and parentInterfaceRef must only be specified
523+
for subinterfaces
524+
rule: self.type == 'Subinterface' || !(has(self.encapsulation) || has(self.parentInterfaceRef))
525+
- message: subinterface must not have aggregation, switchport or vlanRef
526+
configuration
527+
rule: self.type != 'Subinterface' || !(has(self.aggregation) || has(self.switchport)
528+
|| has(self.vlanRef))
529+
- message: encapsulation and parentInterfaceRef must both be specified
530+
for subinterfaces
531+
rule: self.type != 'Subinterface' || (has(self.encapsulation) && has(self.parentInterfaceRef))
466532
- message: bfd must not be specified for interfaces with switchport configuration
467533
rule: '!has(self.bfd) || !has(self.switchport)'
468534
- message: ethernet configuration must only be specified on interfaces

‎docs/api-reference/index.md‎

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,43 @@ _Appears in:_
11061106
| `action` _[RouteTargetAction](#routetargetaction)_ | Action defines whether the route target is imported, exported, or both. | | Enum: [Import Export Both] <br />Required: \{\} <br /> |
11071107

11081108

1109+
#### EncapType
1110+
1111+
_Underlying type:_ _string_
1112+
1113+
1114+
1115+
_Validation:_
1116+
- Enum: [802.1q 802.1ad]
1117+
1118+
_Appears in:_
1119+
- [Encapsulation](#encapsulation)
1120+
1121+
| Field | Description |
1122+
| --- | --- |
1123+
| `802.1q` | EncapsulationTypeDot1Q indicates IEEE 802.1Q encapsulation.<br /> |
1124+
| `802.1ad` | EncapsulationTypeQinQ indicates IEEE 802.1ad encapsulation.<br /> |
1125+
1126+
1127+
#### Encapsulation
1128+
1129+
1130+
1131+
Encapsulation defines config for an L3 subinterface.
1132+
1133+
1134+
1135+
_Appears in:_
1136+
- [InterfaceSpec](#interfacespec)
1137+
1138+
| Field | Description | Default | Validation |
1139+
| --- | --- | --- | --- |
1140+
| `type` _[EncapType](#encaptype)_ | | | Enum: [802.1q 802.1ad] <br />Required: \{\} <br /> |
1141+
| `tag` _integer_ | | | Maximum: 4094 <br />Minimum: 1 <br />Optional: \{\} <br /> |
1142+
| `innerTag` _integer_ | InnerTag specifies the inner VLAN ID for QinQ encapsulation.<br />Only applicable when Type is set to "QinQ". | | Maximum: 4094 <br />Minimum: 1 <br />Optional: \{\} <br /> |
1143+
| `outerTag` _integer_ | OuterTag specifies the outer VLAN ID for QinQ encapsulation.<br />Only applicable when Type is set to "QinQ". | | Maximum: 4094 <br />Minimum: 1 <br />Optional: \{\} <br /> |
1144+
1145+
11091146
#### Endpoint
11101147

11111148

@@ -1403,7 +1440,7 @@ _Appears in:_
14031440
| `name` _string_ | Name is the name of the interface. | | MaxLength: 255 <br />MinLength: 1 <br />Required: \{\} <br /> |
14041441
| `adminState` _[AdminState](#adminstate)_ | AdminState indicates whether the interface is administratively up or down. | Up | Enum: [Up Down] <br />Optional: \{\} <br /> |
14051442
| `description` _string_ | Description provides a human-readable description of the interface. | | MaxLength: 255 <br />Optional: \{\} <br /> |
1406-
| `type` _[InterfaceType](#interfacetype)_ | Type indicates the type of the interface. | | Enum: [Physical Loopback Aggregate RoutedVLAN] <br />Required: \{\} <br /> |
1443+
| `type` _[InterfaceType](#interfacetype)_ | Type indicates the type of the interface. | | Enum: [Physical Loopback Aggregate RoutedVLAN Subinterface] <br />Required: \{\} <br /> |
14071444
| `mtu` _integer_ | MTU (Maximum Transmission Unit) specifies the size of the largest packet that can be sent over the interface. | | Maximum: 9216 <br />Minimum: 576 <br />Optional: \{\} <br /> |
14081445
| `switchport` _[Switchport](#switchport)_ | Switchport defines the switchport configuration for the interface.<br />This is only applicable for Ethernet and Aggregate interfaces. | | Optional: \{\} <br /> |
14091446
| `ipv4` _[InterfaceIPv4](#interfaceipv4)_ | IPv4 defines the IPv4 configuration for the interface. | | Optional: \{\} <br /> |
@@ -1412,6 +1449,8 @@ _Appears in:_
14121449
| `vrfRef` _[LocalObjectReference](#localobjectreference)_ | VrfRef is a reference to the VRF resource that this interface belongs to.<br />If not specified, the interface will be part of the default VRF.<br />This is only applicable for Layer 3 interfaces.<br />The referenced VRF must exist in the same namespace. | | Optional: \{\} <br /> |
14131450
| `bfd` _[BFD](#bfd)_ | BFD defines the Bidirectional Forwarding Detection configuration for the interface.<br />BFD is only applicable for Layer 3 interfaces. | | Optional: \{\} <br /> |
14141451
| `ethernet` _[Ethernet](#ethernet)_ | Ethernet defines the ethernet-specific configuration for physical interfaces.<br />This configuration is only applicable to Physical interfaces.<br />When omitted, ethernet parameters use their default values (e.g., FEC mode defaults to auto). | | Optional: \{\} <br /> |
1452+
| `encapsulation` _[Encapsulation](#encapsulation)_ | Encapsulation defines the subinterfaces config for an L3 interface. | | Optional: \{\} <br /> |
1453+
| `parentInterfaceRef` _[LocalObjectReference](#localobjectreference)_ | ParentInterfaceRef is a reference to the parent interface for this subinterface.<br />Required if the interface type is Subinterface. Must not be set for other interface types. | | Optional: \{\} <br /> |
14151454

14161455

14171456
#### InterfaceStatus
@@ -1438,7 +1477,7 @@ _Underlying type:_ _string_
14381477
InterfaceType represents the type of the interface.
14391478

14401479
_Validation:_
1441-
- Enum: [Physical Loopback Aggregate RoutedVLAN]
1480+
- Enum: [Physical Loopback Aggregate RoutedVLAN Subinterface]
14421481

14431482
_Appears in:_
14441483
- [InterfaceSpec](#interfacespec)
@@ -1449,6 +1488,7 @@ _Appears in:_
14491488
| `Loopback` | InterfaceTypeLoopback indicates that the interface is a loopback interface.<br /> |
14501489
| `Aggregate` | InterfaceTypeAggregate indicates that the interface is an aggregate (bundle) interface.<br /> |
14511490
| `RoutedVLAN` | InterfaceTypeRoutedVLAN indicates that the interface is a routed VLAN interface (SVI/IRB).<br /> |
1491+
| `Subinterface` | InterfaceTypeSubinterface indicates that the interface is a subinterface of an interface.<br /> |
14521492

14531493

14541494
#### LACPMode

0 commit comments

Comments
 (0)