Skip to content

Commit ddba674

Browse files
committed
feat: enable VTEPs
* generic API and controller * cisco-specific provider ref * min tests * operSt * webhooks
1 parent e2e7831 commit ddba674

50 files changed

Lines changed: 2711 additions & 118 deletions

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: 10 additions & 4 deletions
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'])
@@ -39,11 +39,11 @@ def device_yaml():
3939
return encode_yaml_stream(decoded)
4040

4141
k8s_yaml(device_yaml())
42-
k8s_resource(new_name='leaf1', objects=['leaf1:device', 'secret-basic-auth:secret'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)
42+
k8s_resource(new_name='leaf1', objects=['leaf1:device', 'secret-basic-auth:secret'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=True)
4343

4444
k8s_yaml('./config/samples/v1alpha1_interface.yaml')
45-
k8s_resource(new_name='lo0', objects=['lo0:interface'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)
46-
k8s_resource(new_name='lo1', objects=['lo1:interface'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)
45+
k8s_resource(new_name='lo0', objects=['lo0:interface'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=True)
46+
k8s_resource(new_name='lo1', objects=['lo1:interface'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=True)
4747
k8s_resource(new_name='eth1-1', objects=['eth1-1:interface'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)
4848
k8s_resource(new_name='eth1-2', objects=['eth1-2:interface'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)
4949
k8s_resource(new_name='eth1-10', objects=['eth1-10:interface'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False)
@@ -83,6 +83,12 @@ 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=True)
89+
k8s_resource(new_name='vtep1-cfg', objects=['vtep1-cfg:vtepconfig'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=True)
90+
91+
8692
print('🚀 network-operator development environment')
8793
print('👉 Edit the code inside the api/, cmd/, or internal/ directories')
8894
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: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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 (e.g. "100", "200-300").
34+
// +kubebuilder:validation:Pattern=`^(\d{1,4}(-\d{1,4})?)$`
35+
type VLANListItem string
36+
37+
// +kubebuilder:object:root=true
38+
// +kubebuilder:resource:path=vtepconfigs
39+
// +kubebuilder:resource:singular=vtepconfig
40+
41+
// VTEPConfig is the Schema for the VTEP API
42+
type VTEPConfig struct {
43+
metav1.TypeMeta `json:",inline"`
44+
metav1.ObjectMeta `json:"metadata,omitempty,omitzero"`
45+
46+
// spec defines the desired state of VTEP
47+
// +required
48+
Spec VTEPConfigSpec `json:"spec"`
49+
}
50+
51+
// +kubebuilder:object:root=true
52+
53+
// VTEPList contains a list of VTEP
54+
type VTEPConfigList struct {
55+
metav1.TypeMeta `json:",inline"`
56+
metav1.ListMeta `json:"metadata,omitempty"`
57+
Items []VTEPConfig `json:"items"`
58+
}
59+
60+
// init registers the VTEPConfig type with the core v1alpha1 scheme and sets
61+
// itself as a dependency for the VTEP core type.
62+
func init() {
63+
corev1alpha1.RegisterVTEPDependency(GroupVersion.WithKind("VTEPConfig"))
64+
SchemeBuilder.Register(&VTEPConfig{}, &VTEPConfigList{})
65+
}

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

Lines changed: 95 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: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,49 @@ 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+
for i := 0; i < hostBits; i++ {
120+
byteIdx := 15 - i/8
121+
bit := byte(1 << (uint(i % 8)))
122+
a16[byteIdx] |= bit
123+
}
124+
return netip.AddrFrom16(a16)
125+
}

‎api/core/v1alpha1/ref_types.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ 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+
// former ignore me: 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])?)$`
42+
// +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])?)$`
4243
APIVersion string `json:"apiVersion"`
4344
}
4445

0 commit comments

Comments
 (0)