Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ resources:
kind: DHCPRelay
path: github.com/ironcore-dev/network-operator/api/core/v1alpha1
version: v1alpha1
webhooks:
validation: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
Expand Down
2 changes: 1 addition & 1 deletion Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ k8s_resource(new_name='lldp', objects=['leaf1-lldp:lldp'], trigger_mode=TRIGGER_
# k8s_resource(new_name='lldpconfig', objects=['leaf1-lldpconfig:lldpconfig'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False, labels=['samples'])

k8s_yaml('./config/samples/v1alpha1_dhcprelay.yaml')
k8s_resource(new_name='dhcprelay', objects=['dhcprelay:dhcprelay'], resource_deps=['eth1-1'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False, labels=['samples'])
k8s_resource(new_name='dhcprelays', objects=['dhcp-vrf:vrf', 'vlan100:vlan', 'vlan200:vlan', 'svi100:interface', 'svi200:interface', 'dhcprelay100:dhcprelay', 'dhcprelay200:dhcprelay'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False, labels=['samples'])

k8s_yaml('./config/samples/v1alpha1_ethernetsegment.yaml')
k8s_resource(new_name='ethernetsegment-sample', objects=['ethernetsegment-sample:ethernetsegment'], resource_deps=['po10'], trigger_mode=TRIGGER_MODE_MANUAL, auto_init=False, labels=['samples'])
Expand Down
27 changes: 17 additions & 10 deletions api/core/v1alpha1/dhcprelay_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
)

// DHCPRelaySpec defines the desired state of DHCPRelay.
// Only a single DHCPRelay resource should be created per Device, the controller will reject additional resources of this type with the same DeviceRef.
// DHCPRelaySpec defines the desired state of the DHCPRelay configuration for a single interface.
// The migration path for existing DHCPRelay objects that use the deprecated InterfaceRefs field requires deleting those objects
// and creating new ones using the new fields. Objects using the deprecated field InterfaceRefs likely replace the entire DHCPRelay tree and thus
// would remove configuration for all interfaces, even for those that are not referenced.
// +kubebuilder:validation:XValidation:rule="has(self.interfaceRef) != has(self.interfaceRefs)",message="specify either interfaceRef or interfaceRefs, but not both"
type DHCPRelaySpec struct {
// DeviceRef is a reference to the Device this object belongs to. The Device object must exist in the same namespace.
// Immutable.
Expand All @@ -25,7 +28,14 @@ type DHCPRelaySpec struct {
// +optional
ProviderConfigRef *TypedLocalObjectReference `json:"providerConfigRef,omitempty"`

// VrfRef is an optional reference to the VRF to use when relaying DHCP messages in all referenced interfaces.
// InterfaceRef is a reference to an interface resource on which to enable DHCP relay.
// Immutable.
// To be made non-pointer object and required once we remove the deprecated fields.
// +optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="InterfaceRef is immutable"
InterfaceRef *LocalObjectReference `json:"interfaceRef,omitempty"`

// VrfRef is an optional reference to the VRF to use when relaying DHCP messages in the referenced interface(s).
// +optional
VrfRef *LocalObjectReference `json:"vrfRef,omitempty"`

Expand All @@ -37,8 +47,8 @@ type DHCPRelaySpec struct {
// +kubebuilder:validation:MinItems=1
Servers []string `json:"servers"`

// InterfaceRefs is a list of interfaces
// +required
// Deprecated: Use field Interfaces instead.
// +optional
// +listType=atomic
// +kubebuilder:validation:MinItems=1
InterfaceRefs []LocalObjectReference `json:"interfaceRefs,omitempty"`
Expand All @@ -62,18 +72,15 @@ type DHCPRelayStatus struct {
// +listMapKey=type
// +optional
Conditions []metav1.Condition `json:"conditions,omitempty"`

// ConfiguredInterfaces contains the names of Interface resources that have DHCP relay configured as known by the device.
// +optional
// +listType=atomic
ConfiguredInterfaces []string `json:"configuredInterfaces,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=dhcprelays
// +kubebuilder:resource:singular=dhcprelay
// +kubebuilder:printcolumn:name="Device",type=string,JSONPath=`.spec.deviceRef.name`
// +kubebuilder:printcolumn:name="VRF",type=string,JSONPath=`.spec.vrfRef.name`
// +kubebuilder:printcolumn:name="Servers",type=string,JSONPath=`.spec.servers`
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"

Expand Down
10 changes: 5 additions & 5 deletions api/core/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,11 @@ func main() { //nolint:gocyclo
os.Exit(1)
}

if err := webhookv1alpha1.SetupDHCPRelayWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "Failed to create webhook", "webhook", "DHCPRelay")
os.Exit(1)
}

if err := webhooknxv1alpha1.SetupNetworkVirtualizationEdgeConfigWebhookWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create webhook", "webhook", "NetworkVirtualizationEdgeConfig")
os.Exit(1)
Expand Down
47 changes: 35 additions & 12 deletions config/crd/bases/networking.metal.ironcore.dev_dhcprelays.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading