Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 53 additions & 1 deletion api/core/v1alpha1/interface_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ import (
// +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"
// +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"
// +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"
// +kubebuilder:validation:XValidation:rule="self.type == 'Subinterface' || !(has(self.encapsulation) || has(self.parentInterfaceRef))", message="encapsulation and parentInterfaceRef must only be specified for subinterfaces"
// +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"
// +kubebuilder:validation:XValidation:rule="self.type != 'Subinterface' || (has(self.encapsulation) && has(self.parentInterfaceRef))", message="encapsulation and parentInterfaceRef must both be specified for subinterfaces"
// +kubebuilder:validation:XValidation:rule="!has(self.bfd) || !has(self.switchport)", message="bfd must not be specified for interfaces with switchport configuration"
// +kubebuilder:validation:XValidation:rule="self.type == 'Physical' || !has(self.ethernet)", message="ethernet configuration must only be specified on interfaces of type Physical"
type InterfaceSpec struct {
Expand Down Expand Up @@ -104,6 +107,15 @@ type InterfaceSpec struct {
// When omitted, ethernet parameters use their default values (e.g., FEC mode defaults to auto).
// +optional
Ethernet *Ethernet `json:"ethernet,omitempty"`

// Encapsulation defines the subinterfaces config for an L3 interface.
// +optional
Encapsulation *Encapsulation `json:"encapsulation,omitempty"`

// ParentInterfaceRef is a reference to the parent interface for this subinterface.
// Required if the interface type is Subinterface. Must not be set for other interface types.
// +optional
ParentInterfaceRef *LocalObjectReference `json:"parentInterfaceRef,omitempty"`
}

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

// InterfaceType represents the type of the interface.
// +kubebuilder:validation:Enum=Physical;Loopback;Aggregate;RoutedVLAN
// +kubebuilder:validation:Enum=Physical;Loopback;Aggregate;RoutedVLAN;Subinterface
type InterfaceType string

const (
Expand All @@ -132,6 +144,8 @@ const (
InterfaceTypeAggregate InterfaceType = "Aggregate"
// InterfaceTypeRoutedVLAN indicates that the interface is a routed VLAN interface (SVI/IRB).
InterfaceTypeRoutedVLAN InterfaceType = "RoutedVLAN"
// InterfaceTypeSubinterface indicates that the interface is a subinterface of an interface.
InterfaceTypeSubinterface InterfaceType = "Subinterface"
)

// Switchport defines the switchport configuration for an interface.
Expand Down Expand Up @@ -165,6 +179,44 @@ type Switchport struct {
AllowedVlans []int32 `json:"allowedVlans,omitempty"`
}

// +kubebuilder:validation:Enum="802.1q";"802.1ad"
type EncapType string

const (
// EncapsulationTypeDot1Q indicates IEEE 802.1Q encapsulation.
EncapsulationTypeDot1Q EncapType = "802.1q"
// EncapsulationTypeQinQ indicates IEEE 802.1ad encapsulation.
EncapsulationTypeQinQ EncapType = "802.1ad"
)

// Encapsulation defines config for an L3 subinterface.
// +kubebuilder:validation:XValidation:rule="self.type != '802.1q' || has(self.tag)", message="tag must be specified for interfaces of type 802.1q"
// +kubebuilder:validation:XValidation:rule="self.type != '802.1q' || !(has(self.innerTag) || has(self.outerTag))", message="innerTag or outerTag must not be specified for interfaces of type 802.1q"
// +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"
Comment thread
felix-kaestner marked this conversation as resolved.
// +kubebuilder:validation:XValidation:rule="self.type != '802.1ad' || !has(self.tag)", message="tag must not be specified for interfaces of type 802.1ad"
type Encapsulation struct {
// +required
Type EncapType `json:"type"`
// +optional
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=4094
Tag int32 `json:"tag"`

// InnerTag specifies the inner VLAN ID for QinQ encapsulation.
// Only applicable when Type is set to "QinQ".
// +optional
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=4094
InnerTag int32 `json:"innerTag,omitempty"`

// OuterTag specifies the outer VLAN ID for QinQ encapsulation.
// Only applicable when Type is set to "QinQ".
// +optional
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=4094
OuterTag int32 `json:"outerTag,omitempty"`
}

// SwitchportMode represents the switchport mode of an interface.
// +kubebuilder:validation:Enum=Access;Trunk
type SwitchportMode string
Expand Down
25 changes: 25 additions & 0 deletions api/core/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,50 @@ spec:
x-kubernetes-validations:
- message: DeviceRef is immutable
rule: self == oldSelf
encapsulation:
description: Encapsulation defines the subinterfaces config for an
L3 interface.
properties:
innerTag:
description: |-
InnerTag specifies the inner VLAN ID for QinQ encapsulation.
Only applicable when Type is set to "QinQ".
format: int32
maximum: 4094
minimum: 1
type: integer
outerTag:
description: |-
OuterTag specifies the outer VLAN ID for QinQ encapsulation.
Only applicable when Type is set to "QinQ".
format: int32
maximum: 4094
minimum: 1
type: integer
tag:
format: int32
maximum: 4094
minimum: 1
type: integer
type:
enum:
- 802.1q
- 802.1ad
type: string
required:
- type
type: object
x-kubernetes-validations:
- message: tag must be specified for interfaces of type 802.1q
rule: self.type != '802.1q' || has(self.tag)
- message: innerTag or outerTag must not be specified for interfaces
of type 802.1q
rule: self.type != '802.1q' || !(has(self.innerTag) || has(self.outerTag))
- message: innerTag and outerTag must be specified for interfaces
of type 802.1ad
rule: self.type != '802.1ad' || (has(self.innerTag) && has(self.outerTag))
- message: tag must not be specified for interfaces of type 802.1ad
rule: self.type != '802.1ad' || !has(self.tag)
ethernet:
description: |-
Ethernet defines the ethernet-specific configuration for physical interfaces.
Expand Down Expand Up @@ -301,6 +345,22 @@ spec:
x-kubernetes-validations:
- message: Name is immutable
rule: self == oldSelf
parentInterfaceRef:
description: |-
ParentInterfaceRef is a reference to the parent interface for this subinterface.
Required if the interface type is Subinterface. Must not be set for other interface types.
properties:
name:
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
maxLength: 63
minLength: 1
type: string
required:
- name
type: object
x-kubernetes-map-type: atomic
providerConfigRef:
description: |-
ProviderConfigRef is a reference to a resource holding the provider-specific configuration of this interface.
Expand Down Expand Up @@ -388,6 +448,7 @@ spec:
- Loopback
- Aggregate
- RoutedVLAN
- Subinterface
type: string
x-kubernetes-validations:
- message: Type is immutable
Expand Down Expand Up @@ -466,6 +527,16 @@ spec:
- message: bfd must not be specified for Aggregate interfaces with switchport
configuration
rule: self.type != 'Aggregate' || !has(self.switchport) || !has(self.bfd)
- message: encapsulation and parentInterfaceRef must only be specified
for subinterfaces
rule: self.type == 'Subinterface' || !(has(self.encapsulation) || has(self.parentInterfaceRef))
- message: subinterface must not have aggregation, switchport or vlanRef
configuration
rule: self.type != 'Subinterface' || !(has(self.aggregation) || has(self.switchport)
|| has(self.vlanRef))
- message: encapsulation and parentInterfaceRef must both be specified
for subinterfaces
rule: self.type != 'Subinterface' || (has(self.encapsulation) && has(self.parentInterfaceRef))
- message: bfd must not be specified for interfaces with switchport configuration
rule: '!has(self.bfd) || !has(self.switchport)'
- message: ethernet configuration must only be specified on interfaces
Expand Down
71 changes: 71 additions & 0 deletions config/crd/bases/networking.metal.ironcore.dev_interfaces.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,50 @@ spec:
x-kubernetes-validations:
- message: DeviceRef is immutable
rule: self == oldSelf
encapsulation:
description: Encapsulation defines the subinterfaces config for an
L3 interface.
properties:
innerTag:
description: |-
InnerTag specifies the inner VLAN ID for QinQ encapsulation.
Only applicable when Type is set to "QinQ".
format: int32
maximum: 4094
minimum: 1
type: integer
outerTag:
description: |-
OuterTag specifies the outer VLAN ID for QinQ encapsulation.
Only applicable when Type is set to "QinQ".
format: int32
maximum: 4094
minimum: 1
type: integer
tag:
format: int32
maximum: 4094
minimum: 1
type: integer
type:
enum:
- 802.1q
- 802.1ad
type: string
required:
- type
type: object
x-kubernetes-validations:
- message: tag must be specified for interfaces of type 802.1q
rule: self.type != '802.1q' || has(self.tag)
- message: innerTag or outerTag must not be specified for interfaces
of type 802.1q
rule: self.type != '802.1q' || !(has(self.innerTag) || has(self.outerTag))
- message: innerTag and outerTag must be specified for interfaces
of type 802.1ad
rule: self.type != '802.1ad' || (has(self.innerTag) && has(self.outerTag))
- message: tag must not be specified for interfaces of type 802.1ad
rule: self.type != '802.1ad' || !has(self.tag)
ethernet:
description: |-
Ethernet defines the ethernet-specific configuration for physical interfaces.
Expand Down Expand Up @@ -298,6 +342,22 @@ spec:
x-kubernetes-validations:
- message: Name is immutable
rule: self == oldSelf
parentInterfaceRef:
description: |-
ParentInterfaceRef is a reference to the parent interface for this subinterface.
Required if the interface type is Subinterface. Must not be set for other interface types.
properties:
name:
description: |-
Name of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
maxLength: 63
minLength: 1
type: string
required:
- name
type: object
x-kubernetes-map-type: atomic
providerConfigRef:
description: |-
ProviderConfigRef is a reference to a resource holding the provider-specific configuration of this interface.
Expand Down Expand Up @@ -385,6 +445,7 @@ spec:
- Loopback
- Aggregate
- RoutedVLAN
- Subinterface
type: string
x-kubernetes-validations:
- message: Type is immutable
Expand Down Expand Up @@ -463,6 +524,16 @@ spec:
- message: bfd must not be specified for Aggregate interfaces with switchport
configuration
rule: self.type != 'Aggregate' || !has(self.switchport) || !has(self.bfd)
- message: encapsulation and parentInterfaceRef must only be specified
for subinterfaces
rule: self.type == 'Subinterface' || !(has(self.encapsulation) || has(self.parentInterfaceRef))
- message: subinterface must not have aggregation, switchport or vlanRef
configuration
rule: self.type != 'Subinterface' || !(has(self.aggregation) || has(self.switchport)
|| has(self.vlanRef))
- message: encapsulation and parentInterfaceRef must both be specified
for subinterfaces
rule: self.type != 'Subinterface' || (has(self.encapsulation) && has(self.parentInterfaceRef))
- message: bfd must not be specified for interfaces with switchport configuration
rule: '!has(self.bfd) || !has(self.switchport)'
- message: ethernet configuration must only be specified on interfaces
Expand Down
Loading
Loading