Skip to content

Commit 2103346

Browse files
Add vrf association to Interface resource
This change introduces a new field on the `Interface` resource to allow to configure an interface as part of a specified `VRF` (Network Instance) instead of configuring them in the DEFAULT_INSTANCE vrf where they are configured by default. This configuration is only allowed in L3 interfaces.
1 parent c68f3a4 commit 2103346

20 files changed

+519
-47
lines changed

Tiltfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ k8s_resource(new_name='eth1-2', objects=['eth1-2:interface'], trigger_mode=TRIGG
4949
k8s_resource(new_name='eth1-10', objects=['eth1-10:interface'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)
5050
k8s_resource(new_name='po10', objects=['po-10:interface'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)
5151
k8s_resource(new_name='svi-10', objects=['svi-10:interface'], resource_deps=['vlan-10'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)
52+
k8s_resource(new_name='eth1-30', objects=['eth1-30:interface'], resource_deps=['vrf-vpc-keepalive'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)
5253

5354
k8s_yaml('./config/samples/v1alpha1_banner.yaml')
5455
k8s_resource(new_name='banner', objects=['banner:banner'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)
@@ -83,6 +84,7 @@ k8s_resource(new_name='isis-underlay', objects=['underlay:isis'], resource_deps=
8384
k8s_yaml('./config/samples/v1alpha1_vrf.yaml')
8485
k8s_resource(new_name='vrf-admin', objects=['vrf-cc-admin:vrf'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)
8586
k8s_resource(new_name='vrf-001', objects=['vrf-cc-prod-001:vrf'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)
87+
k8s_resource(new_name='vrf-vpc-keepalive', objects=['vpc-keepalive:vrf'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)
8688

8789
k8s_yaml('./config/samples/v1alpha1_pim.yaml')
8890
k8s_resource(new_name='pim', objects=['pim:pim'], resource_deps=['lo0', 'lo1', 'eth1-1', 'eth1-2'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)

api/core/v1alpha1/groupversion_info.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ const AggregateLabel = "networking.metal.ironcore.dev/aggregate-name"
5050
// the name of the RoutedVLAN interface that provides Layer 3 routing for the VLAN.
5151
const RoutedVLANLabel = "networking.metal.ironcore.dev/routed-vlan-name"
5252

53+
// VRFLabel is a label applied to interfaces to indicate
54+
// the name of the VRF they belong to.
55+
const VRFLabel = "networking.metal.ironcore.dev/vrf-name"
56+
5357
// Condition types that are used across different objects.
5458
const (
5559
// ReadyCondition is the top-level status condition that reports if an object is ready.
@@ -122,4 +126,7 @@ const (
122126

123127
// VLANAlreadyInUseReason indicates that a VLAN is already in use by another routed VLAN interface.
124128
VLANAlreadyInUseReason = "VLANAlreadyInUse"
129+
130+
// VRFNotFoundReason indicates that a referenced VRF was not found.
131+
VRFNotFoundReason = "VRFNotFound"
125132
)

api/core/v1alpha1/interface_types.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import (
1818
// +kubebuilder:validation:XValidation:rule="self.type == 'RoutedVLAN' || !has(self.vlanRef)", message="vlanRef must only be specified on interfaces of type RoutedVLAN"
1919
// +kubebuilder:validation:XValidation:rule="self.type != 'RoutedVLAN' || !has(self.switchport)", message="switchport must not be specified for interfaces of type RoutedVLAN"
2020
// +kubebuilder:validation:XValidation:rule="self.type != 'RoutedVLAN' || !has(self.aggregation)", message="aggregation must not be specified for interfaces of type RoutedVLAN"
21+
// +kubebuilder:validation:XValidation:rule="self.type != 'Aggregate' || !has(self.vrfRef)", message="vrfRef must not be specified for interfaces of type Aggregate"
22+
// +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"
2123
type InterfaceSpec struct {
2224
// DeviceName is the name of the Device this object belongs to. The Device object must exist in the same namespace.
2325
// Immutable.
@@ -76,6 +78,13 @@ type InterfaceSpec struct {
7678
// The referenced VLAN must exist in the same namespace.
7779
// +optional
7880
VlanRef *LocalObjectReference `json:"vlanRef,omitempty"`
81+
82+
// VrfRef is a reference to the VRF resource that this interface belongs to.
83+
// If not specified, the interface will be part of the default VRF.
84+
// This is only applicable for Layer 3 interfaces.
85+
// The referenced VRF must exist in the same namespace.
86+
// +optional
87+
VrfRef *LocalObjectReference `json:"vrfRef,omitempty"`
7988
}
8089

8190
// AdminState represents the administrative state of the interface.

api/core/v1alpha1/vrf_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ type VRFSpec struct {
2121
ProviderConfigRef *TypedLocalObjectReference `json:"providerConfigRef,omitempty"`
2222

2323
// Name is the name of the VRF.
24+
// Immutable.
2425
// +required
2526
// +kubebuilder:validation:MinLength=1
2627
// +kubebuilder:validation:MaxLength=32
28+
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Name is immutable"
2729
Name string `json:"name"`
2830

2931
// Description provides a human-readable description of the VRF.

api/core/v1alpha1/zz_generated.deepcopy.go

Lines changed: 5 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/networking.metal.ironcore.dev_interfaces.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,24 @@ spec:
345345
- name
346346
type: object
347347
x-kubernetes-map-type: atomic
348+
vrfRef:
349+
description: |-
350+
VrfRef is a reference to the VRF resource that this interface belongs to.
351+
If not specified, the interface will be part of the default VRF.
352+
This is only applicable for Layer 3 interfaces.
353+
The referenced VRF must exist in the same namespace.
354+
properties:
355+
name:
356+
description: |-
357+
Name of the referent.
358+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
359+
maxLength: 63
360+
minLength: 1
361+
type: string
362+
required:
363+
- name
364+
type: object
365+
x-kubernetes-map-type: atomic
348366
required:
349367
- adminState
350368
- deviceRef
@@ -373,6 +391,11 @@ spec:
373391
rule: self.type != 'RoutedVLAN' || !has(self.switchport)
374392
- message: aggregation must not be specified for interfaces of type RoutedVLAN
375393
rule: self.type != 'RoutedVLAN' || !has(self.aggregation)
394+
- message: vrfRef must not be specified for interfaces of type Aggregate
395+
rule: self.type != 'Aggregate' || !has(self.vrfRef)
396+
- message: vrfRef must not be specified for Physical interfaces with switchport
397+
configuration
398+
rule: self.type != 'Physical' || !has(self.switchport) || !has(self.vrfRef)
376399
status:
377400
description: |-
378401
Status of the resource. This is set and updated automatically.

charts/network-operator/templates/crd/networking.metal.ironcore.dev_vrfs.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,15 @@ spec:
8686
- message: DeviceRef is immutable
8787
rule: self == oldSelf
8888
name:
89-
description: Name is the name of the VRF.
89+
description: |-
90+
Name is the name of the VRF.
91+
Immutable.
9092
maxLength: 32
9193
minLength: 1
9294
type: string
95+
x-kubernetes-validations:
96+
- message: Name is immutable
97+
rule: self == oldSelf
9398
providerConfigRef:
9499
description: |-
95100
ProviderConfigRef is a reference to a resource holding the provider-specific configuration of this interface.

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,24 @@ spec:
339339
- name
340340
type: object
341341
x-kubernetes-map-type: atomic
342+
vrfRef:
343+
description: |-
344+
VrfRef is a reference to the VRF resource that this interface belongs to.
345+
If not specified, the interface will be part of the default VRF.
346+
This is only applicable for Layer 3 interfaces.
347+
The referenced VRF must exist in the same namespace.
348+
properties:
349+
name:
350+
description: |-
351+
Name of the referent.
352+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
353+
maxLength: 63
354+
minLength: 1
355+
type: string
356+
required:
357+
- name
358+
type: object
359+
x-kubernetes-map-type: atomic
342360
required:
343361
- adminState
344362
- deviceRef
@@ -367,6 +385,11 @@ spec:
367385
rule: self.type != 'RoutedVLAN' || !has(self.switchport)
368386
- message: aggregation must not be specified for interfaces of type RoutedVLAN
369387
rule: self.type != 'RoutedVLAN' || !has(self.aggregation)
388+
- message: vrfRef must not be specified for interfaces of type Aggregate
389+
rule: self.type != 'Aggregate' || !has(self.vrfRef)
390+
- message: vrfRef must not be specified for Physical interfaces with switchport
391+
configuration
392+
rule: self.type != 'Physical' || !has(self.switchport) || !has(self.vrfRef)
370393
status:
371394
description: |-
372395
Status of the resource. This is set and updated automatically.

config/crd/bases/networking.metal.ironcore.dev_vrfs.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,15 @@ spec:
8080
- message: DeviceRef is immutable
8181
rule: self == oldSelf
8282
name:
83-
description: Name is the name of the VRF.
83+
description: |-
84+
Name is the name of the VRF.
85+
Immutable.
8486
maxLength: 32
8587
minLength: 1
8688
type: string
89+
x-kubernetes-validations:
90+
- message: Name is immutable
91+
rule: self == oldSelf
8792
providerConfigRef:
8893
description: |-
8994
ProviderConfigRef is a reference to a resource holding the provider-specific configuration of this interface.

config/samples/v1alpha1_interface.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,24 @@ spec:
155155
ipv4:
156156
addresses:
157157
- 192.168.10.254/24
158+
---
159+
apiVersion: networking.metal.ironcore.dev/v1alpha1
160+
kind: Interface
161+
metadata:
162+
labels:
163+
app.kubernetes.io/name: network-operator
164+
app.kubernetes.io/managed-by: kustomize
165+
networking.metal.ironcore.dev/device-name: leaf1
166+
name: eth1-30
167+
spec:
168+
deviceRef:
169+
name: leaf1
170+
name: eth1/30
171+
description: vPC Keepalive
172+
adminState: Up
173+
type: Physical
174+
ipv4:
175+
addresses:
176+
- 10.1.1.1/30
177+
vrfRef:
178+
name: vpc-keepalive

0 commit comments

Comments
 (0)