|
| 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 | +} |
0 commit comments