Skip to content

Commit bf5de61

Browse files
committed
feat: Virtual Tunnel End-Points (VTEPs)
* Adds generic support for VXLAN Tunnel End Point (VTEP). The core type `VTEP` requires at least two loopback interfaces on the same device. The generic API type includes an optional field for Multicastgroup. The generic VTEP includes a `ProviderConfigRef` field to support extended capabilities for specific switches. * The `VTEP` controller includes Configuration and Operation status updates. * The type `VTEP` has an admission webhook to validate that the provided multicast prefix is indeed a multicast prefix. Notice that the current implementation of this check is partial, and it relies on further check at the target device. * This multicast prefix check requires extending the `IPPrefix` type with two methods that provide the first and the last IP in the prefix. * The `cisco.nx.v1alpha1.VTEPConfig` can be used in the `ProviderConfigRef` includes cisco specific settings, including system settings. Thus, updates to a single `VTEPConfig` that is reference by multiple `VTEP` will result in changing system settings in multiple devices (infra VLANs). * The `VTEP` controller checks during reconciliation that the provider `ProviderConfigRef` is actually supported. It implements it by checking the `Device` status fields and looking for the device model information. It then checks if the API version of the `ProviderConfigRef` supports this model. This is currently done by checking the `Kind`. If this a `VTEPConfig` from `cisco.nx` then it checks additional information encoded in that specific API. This approach avoids querying the device. * The `cisco.nx` type `VTEPConfig` has also a webhook to validate some of the conditions required by Cisco for the infra VLANs. Even though the device also checks for these settings, we add the webhook to avoid a gNMI call to the device when possible.
1 parent e2e7831 commit bf5de61

53 files changed

Lines changed: 3262 additions & 90 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/goreleaser.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# SPDX-License-Identifier: Apache-2.0
88

99
name: goreleaser
10-
"on":
10+
on:
1111
push:
1212
tags:
1313
- '*'

‎PROJECT‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,26 @@ resources:
118118
webhooks:
119119
validation: true
120120
webhookVersion: v1
121-
version: "3"
121+
- api:
122+
crdVersion: v1
123+
namespaced: true
124+
controller: true
125+
domain: networking.metal.ironcore.dev
126+
kind: VTEP
127+
path: github.com/ironcore-dev/network-operator/api/core/v1alpha1
128+
version: v1alpha1
129+
webhooks:
130+
validation: true
131+
webhookVersion: v1
132+
- api:
133+
crdVersion: v1
134+
namespaced: true
135+
domain: cisco.networking.metal.ironcore.dev
136+
group: nx
137+
kind: VTEPConfig
138+
controller: false
139+
path: github.com/ironcore-dev/network-operator/api/cisco/nx/v1alpha1
140+
version: v1alpha1
141+
webhooks:
142+
validation: true
143+
webhookVersion: v1

‎Tiltfile‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ docker_build('ghcr.io/ironcore-dev/gnmi-test-server:latest', './test/gnmi')
2525
provider = os.getenv('PROVIDER', 'openconfig')
2626

2727
manager = kustomize('config/develop')
28-
manager = str(manager).replace('--provider=openconfig', '--provider={}'.format(provider))
28+
manager = str(manager).replace('--provider=openconfig', '--provider={}'.format(provider), 1)
2929

3030
k8s_yaml(blob(manager))
3131
k8s_resource('network-operator-controller-manager', resource_deps=['controller-gen'])
@@ -83,6 +83,11 @@ k8s_yaml('./config/samples/v1alpha1_vrf.yaml')
8383
k8s_resource(new_name='vrf-admin', objects=['vrf-cc-admin:vrf'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)
8484
k8s_resource(new_name='vrf-001', objects=['vrf-cc-prod-001:vrf'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)
8585

86+
k8s_yaml('./config/samples/v1alpha1_vtep.yaml')
87+
k8s_yaml('./config/samples/cisco/nx/v1alpha1_vtepconfig.yaml')
88+
k8s_resource(new_name='vtep1', objects=['vtep1:vtep'], trigger_mode=TRIGGER_MODE_MANUAL, resource_deps=['vtep1-cfg', 'lo0', 'lo1'], auto_init=False)
89+
k8s_resource(new_name='vtep1-cfg', objects=['vtep1-cfg:vtepconfig'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)
90+
8691
print('🚀 network-operator development environment')
8792
print('👉 Edit the code inside the api/, cmd/, or internal/ directories')
8893
print('👉 Tilt will automatically rebuild and redeploy when changes are detected')

‎api/cisco/nx/v1alpha1/groupversion_info.go‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,12 @@ var (
2222
// AddToScheme adds the types in this group-version to the given scheme.
2323
AddToScheme = SchemeBuilder.AddToScheme
2424
)
25+
26+
// TODO: discuss with team if we want to use these constants in the provider to ensure
27+
// compatibility checks
28+
const CompatibleManufacturer = "Cisco"
29+
30+
var (
31+
CompatibleFirmwareVersions = []string{"10.4(3)"}
32+
CompatibleModels = []string{"N9K-C9300v"}
33+
)
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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+
corev1alpha1 "github.com/ironcore-dev/network-operator/api/core/v1alpha1"
10+
)
11+
12+
// +kubebuilder:rbac:groups=nx.cisco.networking.metal.ironcore.dev,resources=vtepconfigs,verbs=get;list;watch
13+
14+
// VTEPConfig defines the Cisco-specific configuration of a VTEP/NVE
15+
type VTEPConfigSpec struct {
16+
// AdvertiseVMAC is equivalent to: `advertise virtual-rmac`
17+
// +optional
18+
AdvertiseVMAC *bool `json:"advertiseVMAC,omitempty"`
19+
20+
// HoldDownTime is equivalent to: `source-interface hold-down-time
21+
// +optional
22+
// +kubebuilder:validation:Minimum=1
23+
// +kubebuilder:validation:Maximum=1500
24+
HoldDownTime uint16 `json:"holdDownTime,omitempty"`
25+
26+
// InfraVLANs is the list of infrastructure VLANs for ingress replication, equivalent to: `system nve infra-vlan`
27+
// See admission webhook for additional validation rules.
28+
// +optional
29+
// +kubebuilder:validation:MaxItems=10
30+
InfraVLANs []VLANListItem `json:"infraVLANs,omitempty"`
31+
}
32+
33+
// VLANListItem represents a single VLAN ID or a range start-end. If ID is set, rangeMin and rangeMax must be absent. If ID is absent, both rangeMin
34+
// and rangeMax must be set.
35+
// +kubebuilder:validation:XValidation:rule="!has(self.rangeMax) || self.rangeMax > self.rangeMin",message="rangeMax must be greater than rangeMin"
36+
// +kubebuilder:validation:XValidation:rule="has(self.id) || (has(self.rangeMin) && has(self.rangeMax))",message="either ID or both rangeMin and rangeMax must be set"
37+
// +kubebuilder:validation:XValidation:rule="!has(self.id) || (!has(self.rangeMin) && !has(self.rangeMax))",message="rangeMin and rangeMax must be omitted when ID is set"
38+
type VLANListItem struct {
39+
// +optional
40+
// +kubebuilder:validation:Minimum=1
41+
// +kubebuilder:validation:Maximum=3967
42+
ID uint `json:"id,omitempty"`
43+
// +optional
44+
// +kubebuilder:validation:Minimum=1
45+
// +kubebuilder:validation:Maximum=3967
46+
RangeMin uint `json:"rangeMin,omitempty"`
47+
// +optional
48+
// +kubebuilder:validation:Minimum=1
49+
// +kubebuilder:validation:Maximum=3967
50+
RangeMax uint `json:"rangeMax,omitempty"`
51+
}
52+
53+
// +kubebuilder:object:root=true
54+
// +kubebuilder:resource:path=vtepconfigs
55+
// +kubebuilder:resource:singular=vtepconfig
56+
57+
// VTEPConfig is the Schema for the VTEP API
58+
type VTEPConfig struct {
59+
metav1.TypeMeta `json:",inline"`
60+
metav1.ObjectMeta `json:"metadata,omitempty,omitzero"`
61+
62+
// spec defines the desired state of VTEP
63+
// +required
64+
Spec VTEPConfigSpec `json:"spec"`
65+
}
66+
67+
// +kubebuilder:object:root=true
68+
69+
// VTEPList contains a list of VTEP
70+
type VTEPConfigList struct {
71+
metav1.TypeMeta `json:",inline"`
72+
metav1.ListMeta `json:"metadata,omitempty"`
73+
Items []VTEPConfig `json:"items"`
74+
}
75+
76+
// init registers the VTEPConfig type with the core v1alpha1 scheme and sets
77+
// itself as a dependency for the VTEP core type.
78+
func init() {
79+
corev1alpha1.RegisterVTEPDependency(GroupVersion.WithKind("VTEPConfig"))
80+
SchemeBuilder.Register(&VTEPConfig{}, &VTEPConfigList{})
81+
}

‎api/cisco/nx/v1alpha1/zz_generated.deepcopy.go‎

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

‎api/core/v1alpha1/groupversion_info.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ const (
9797

9898
// WaitingForDependenciesReason indicates that the resource is waiting for its dependencies to be ready.
9999
WaitingForDependenciesReason = "WaitingForDependencies"
100+
101+
// ImcompatibleProviderConfigRef indicates that the referenced provider configuration is not compatible with the device.
102+
IncompatibleProviderConfigRef = "IncompatibleProviderConfigRef"
100103
)
101104

102105
// Reasons that are specific to [Interface] objects.

‎api/core/v1alpha1/prefix_types.go‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,50 @@ func (in *IPPrefix) DeepCopy() *IPPrefix {
7777
in.DeepCopyInto(out)
7878
return out
7979
}
80+
81+
func (in *IPPrefix) First() netip.Addr {
82+
if !in.IsValid() {
83+
return netip.Addr{}
84+
}
85+
return in.Masked().Addr()
86+
}
87+
88+
func (in *IPPrefix) Last() netip.Addr {
89+
if !in.IsValid() {
90+
return netip.Addr{}
91+
}
92+
net := in.Masked().Addr()
93+
if in.Bits() == 0 {
94+
if net.Is4() {
95+
return netip.AddrFrom4([4]byte{255, 255, 255, 255})
96+
}
97+
return netip.AddrFrom16([16]byte{
98+
0xff, 0xff, 0xff, 0xff,
99+
0xff, 0xff, 0xff, 0xff,
100+
0xff, 0xff, 0xff, 0xff,
101+
0xff, 0xff, 0xff, 0xff,
102+
})
103+
}
104+
if net.Is4() {
105+
a4 := net.As4()
106+
v := uint32(a4[0])<<24 | uint32(a4[1])<<16 | uint32(a4[2])<<8 | uint32(a4[3])
107+
hostBits := 32 - in.Bits()
108+
mask := uint32(1<<hostBits) - 1
109+
v |= mask
110+
return netip.AddrFrom4([4]byte{
111+
byte(v >> 24),
112+
byte(v >> 16),
113+
byte(v >> 8),
114+
byte(v),
115+
})
116+
}
117+
a16 := net.As16()
118+
hostBits := 128 - in.Bits()
119+
120+
for i := range hostBits {
121+
byteIdx := 15 - i/8
122+
bit := byte(1 << (i % 8))
123+
a16[byteIdx] |= bit
124+
}
125+
return netip.AddrFrom16(a16)
126+
}

‎api/core/v1alpha1/ref_types.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type TypedLocalObjectReference struct {
3838
// +required
3939
// +kubebuilder:validation:MinLength=1
4040
// +kubebuilder:validation:MaxLength=253
41-
//+kubebuilder:validation:Pattern=`^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*\/)?([a-z0-9]([-a-z0-9]*[a-z0-9])?)$`
41+
// +kubebuilder:validation:Pattern=`^([a-z0-9]([-a-z0-9]*[a-z0-9])?(?:\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*\/)?([a-z0-9]([-a-z0-9]*[a-z0-9])?)$`
4242
APIVersion string `json:"apiVersion"`
4343
}
4444

0 commit comments

Comments
 (0)