|
| 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 | + v1alpha1 "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 | + // AdvertiseVirtualMAC controls if the VTEP should advertise a virtual MAC address |
| 17 | + // +optional |
| 18 | + // +kubebuilder:default=false |
| 19 | + AdvertiseVirtualMAC *bool `json:"advertiseVirtualMAC,omitempty"` |
| 20 | + |
| 21 | + // HoldDownTime defines the duration for which the switch suppresses the advertisement of the NVE loopback address. |
| 22 | + // +optional |
| 23 | + // +kubebuilder:validation:Minimum=1 |
| 24 | + // +kubebuilder:validation:Maximum=1500 |
| 25 | + // +kubebuilder:default=180 |
| 26 | + HoldDownTime uint16 `json:"holdDownTime,omitempty"` |
| 27 | + |
| 28 | + // InfraVLANs specifies VLANs used by all SVI interfaces for uplink and vPC peer-links in VXLAN as infra-VLANs. |
| 29 | + // The total number of VLANs configured must not exceed 512. |
| 30 | + // Elements in the list must not overlap with each other. |
| 31 | + // +optional |
| 32 | + // +kubebuilder:validation:MaxItems=10 |
| 33 | + InfraVLANs []VLANListItem `json:"infraVLANs,omitempty"` |
| 34 | +} |
| 35 | + |
| 36 | +// 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 |
| 37 | +// and rangeMax must be set. |
| 38 | +// +kubebuilder:validation:XValidation:rule="!has(self.rangeMax) || self.rangeMax > self.rangeMin",message="rangeMax must be greater than rangeMin" |
| 39 | +// +kubebuilder:validation:XValidation:rule="has(self.id) || (has(self.rangeMin) && has(self.rangeMax))",message="either ID or both rangeMin and rangeMax must be set" |
| 40 | +// +kubebuilder:validation:XValidation:rule="!has(self.id) || (!has(self.rangeMin) && !has(self.rangeMax))",message="rangeMin and rangeMax must be omitted when ID is set" |
| 41 | +type VLANListItem struct { |
| 42 | + // +optional |
| 43 | + // +kubebuilder:validation:Minimum=1 |
| 44 | + // +kubebuilder:validation:Maximum=3967 |
| 45 | + ID uint16 `json:"id,omitempty"` |
| 46 | + // +optional |
| 47 | + // +kubebuilder:validation:Minimum=1 |
| 48 | + // +kubebuilder:validation:Maximum=3967 |
| 49 | + RangeMin uint16 `json:"rangeMin,omitempty"` |
| 50 | + // +optional |
| 51 | + // +kubebuilder:validation:Minimum=1 |
| 52 | + // +kubebuilder:validation:Maximum=3967 |
| 53 | + RangeMax uint16 `json:"rangeMax,omitempty"` |
| 54 | +} |
| 55 | + |
| 56 | +// +kubebuilder:object:root=true |
| 57 | +// +kubebuilder:resource:path=vtepconfigs |
| 58 | +// +kubebuilder:resource:singular=vtepconfig |
| 59 | + |
| 60 | +// VTEPConfig is the Schema for the VTEP API |
| 61 | +type VTEPConfig struct { |
| 62 | + metav1.TypeMeta `json:",inline"` |
| 63 | + metav1.ObjectMeta `json:"metadata,omitempty,omitzero"` |
| 64 | + |
| 65 | + // spec defines the desired state of VTEP |
| 66 | + // +required |
| 67 | + Spec VTEPConfigSpec `json:"spec"` |
| 68 | +} |
| 69 | + |
| 70 | +// +kubebuilder:object:root=true |
| 71 | + |
| 72 | +// VTEPList contains a list of VTEP |
| 73 | +type VTEPConfigList struct { |
| 74 | + metav1.TypeMeta `json:",inline"` |
| 75 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 76 | + Items []VTEPConfig `json:"items"` |
| 77 | +} |
| 78 | + |
| 79 | +// init registers the VTEPConfig type with the core v1alpha1 scheme and sets |
| 80 | +// itself as a dependency for the VTEP core type. |
| 81 | +func init() { |
| 82 | + v1alpha1.RegisterVTEPDependency(GroupVersion.WithKind("VTEPConfig")) |
| 83 | + SchemeBuilder.Register(&VTEPConfig{}, &VTEPConfigList{}) |
| 84 | +} |
0 commit comments