From e9e408b0e190dc845c73038ee650b787ca8820de Mon Sep 17 00:00:00 2001 From: Lukas Frank Date: Tue, 26 Nov 2024 12:04:51 +0100 Subject: [PATCH] WIP --- broker/machinebroker/server/server.go | 1 + .../compute/v1alpha1/reservation.go | 2 +- client-go/applyconfigurations/utils.go | 134 +++++++----------- .../compute/v1alpha1/reservation.go | 10 +- .../typed/compute/v1alpha1/reservation.go | 2 +- .../broker-rbac/role.yaml | 14 +- 6 files changed, 74 insertions(+), 89 deletions(-) diff --git a/broker/machinebroker/server/server.go b/broker/machinebroker/server/server.go index 2e00a2468..40da130cb 100644 --- a/broker/machinebroker/server/server.go +++ b/broker/machinebroker/server/server.go @@ -34,6 +34,7 @@ var _ iri.MachineRuntimeServer = (*Server)(nil) //+kubebuilder:rbac:groups=networking.ironcore.dev,resources=loadbalancerroutings,verbs=get;list;watch;create;update;patch;delete //+kubebuilder:rbac:groups=networking.ironcore.dev,resources=natgateways,verbs=get;list;watch;create;update;patch;delete //+kubebuilder:rbac:groups=networking.ironcore.dev,resources=natgateways/status,verbs=get;update;patch +//+kubebuilder:rbac:groups=compute.ironcore.dev,resources=reservations,verbs=get;list;watch;create;update;patch;delete type BrokerLabel struct { DefaultLabel string diff --git a/client-go/applyconfigurations/compute/v1alpha1/reservation.go b/client-go/applyconfigurations/compute/v1alpha1/reservation.go index 77b09ea80..bd9c43bfa 100644 --- a/client-go/applyconfigurations/compute/v1alpha1/reservation.go +++ b/client-go/applyconfigurations/compute/v1alpha1/reservation.go @@ -8,10 +8,10 @@ package v1alpha1 import ( computev1alpha1 "github.com/ironcore-dev/ironcore/api/compute/v1alpha1" internal "github.com/ironcore-dev/ironcore/client-go/applyconfigurations/internal" - v1 "github.com/ironcore-dev/ironcore/client-go/applyconfigurations/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" managedfields "k8s.io/apimachinery/pkg/util/managedfields" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" ) // ReservationApplyConfiguration represents an declarative configuration of the Reservation type for use diff --git a/client-go/applyconfigurations/utils.go b/client-go/applyconfigurations/utils.go index 40cb4712b..14456b624 100644 --- a/client-go/applyconfigurations/utils.go +++ b/client-go/applyconfigurations/utils.go @@ -6,20 +6,16 @@ package applyconfigurations import ( - v1alpha1 "github.com/ironcore-dev/ironcore/api/common/v1alpha1" - computev1alpha1 "github.com/ironcore-dev/ironcore/api/compute/v1alpha1" + v1alpha1 "github.com/ironcore-dev/ironcore/api/compute/v1alpha1" corev1alpha1 "github.com/ironcore-dev/ironcore/api/core/v1alpha1" ipamv1alpha1 "github.com/ironcore-dev/ironcore/api/ipam/v1alpha1" networkingv1alpha1 "github.com/ironcore-dev/ironcore/api/networking/v1alpha1" storagev1alpha1 "github.com/ironcore-dev/ironcore/api/storage/v1alpha1" - commonv1alpha1 "github.com/ironcore-dev/ironcore/client-go/applyconfigurations/common/v1alpha1" - applyconfigurationscomputev1alpha1 "github.com/ironcore-dev/ironcore/client-go/applyconfigurations/compute/v1alpha1" + computev1alpha1 "github.com/ironcore-dev/ironcore/client-go/applyconfigurations/compute/v1alpha1" applyconfigurationscorev1alpha1 "github.com/ironcore-dev/ironcore/client-go/applyconfigurations/core/v1alpha1" applyconfigurationsipamv1alpha1 "github.com/ironcore-dev/ironcore/client-go/applyconfigurations/ipam/v1alpha1" - metav1 "github.com/ironcore-dev/ironcore/client-go/applyconfigurations/meta/v1" applyconfigurationsnetworkingv1alpha1 "github.com/ironcore-dev/ironcore/client-go/applyconfigurations/networking/v1alpha1" applyconfigurationsstoragev1alpha1 "github.com/ironcore-dev/ironcore/client-go/applyconfigurations/storage/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" schema "k8s.io/apimachinery/pkg/runtime/schema" ) @@ -27,67 +23,57 @@ import ( // apply configuration type exists for the given GroupVersionKind. func ForKind(kind schema.GroupVersionKind) interface{} { switch kind { - // Group=common.ironcore.dev, Version=v1alpha1 - case v1alpha1.SchemeGroupVersion.WithKind("LocalUIDReference"): - return &commonv1alpha1.LocalUIDReferenceApplyConfiguration{} - case v1alpha1.SchemeGroupVersion.WithKind("SecretKeySelector"): - return &commonv1alpha1.SecretKeySelectorApplyConfiguration{} - case v1alpha1.SchemeGroupVersion.WithKind("Taint"): - return &commonv1alpha1.TaintApplyConfiguration{} - case v1alpha1.SchemeGroupVersion.WithKind("Toleration"): - return &commonv1alpha1.TolerationApplyConfiguration{} - - // Group=compute.ironcore.dev, Version=v1alpha1 - case computev1alpha1.SchemeGroupVersion.WithKind("DaemonEndpoint"): - return &applyconfigurationscomputev1alpha1.DaemonEndpointApplyConfiguration{} - case computev1alpha1.SchemeGroupVersion.WithKind("EFIVar"): - return &applyconfigurationscomputev1alpha1.EFIVarApplyConfiguration{} - case computev1alpha1.SchemeGroupVersion.WithKind("EmptyDiskVolumeSource"): - return &applyconfigurationscomputev1alpha1.EmptyDiskVolumeSourceApplyConfiguration{} - case computev1alpha1.SchemeGroupVersion.WithKind("EphemeralNetworkInterfaceSource"): - return &applyconfigurationscomputev1alpha1.EphemeralNetworkInterfaceSourceApplyConfiguration{} - case computev1alpha1.SchemeGroupVersion.WithKind("EphemeralVolumeSource"): - return &applyconfigurationscomputev1alpha1.EphemeralVolumeSourceApplyConfiguration{} - case computev1alpha1.SchemeGroupVersion.WithKind("Machine"): - return &applyconfigurationscomputev1alpha1.MachineApplyConfiguration{} - case computev1alpha1.SchemeGroupVersion.WithKind("MachineClass"): - return &applyconfigurationscomputev1alpha1.MachineClassApplyConfiguration{} - case computev1alpha1.SchemeGroupVersion.WithKind("MachinePool"): - return &applyconfigurationscomputev1alpha1.MachinePoolApplyConfiguration{} - case computev1alpha1.SchemeGroupVersion.WithKind("MachinePoolAddress"): - return &applyconfigurationscomputev1alpha1.MachinePoolAddressApplyConfiguration{} - case computev1alpha1.SchemeGroupVersion.WithKind("MachinePoolCondition"): - return &applyconfigurationscomputev1alpha1.MachinePoolConditionApplyConfiguration{} - case computev1alpha1.SchemeGroupVersion.WithKind("MachinePoolDaemonEndpoints"): - return &applyconfigurationscomputev1alpha1.MachinePoolDaemonEndpointsApplyConfiguration{} - case computev1alpha1.SchemeGroupVersion.WithKind("MachinePoolSpec"): - return &applyconfigurationscomputev1alpha1.MachinePoolSpecApplyConfiguration{} - case computev1alpha1.SchemeGroupVersion.WithKind("MachinePoolStatus"): - return &applyconfigurationscomputev1alpha1.MachinePoolStatusApplyConfiguration{} - case computev1alpha1.SchemeGroupVersion.WithKind("MachineSpec"): - return &applyconfigurationscomputev1alpha1.MachineSpecApplyConfiguration{} - case computev1alpha1.SchemeGroupVersion.WithKind("MachineStatus"): - return &applyconfigurationscomputev1alpha1.MachineStatusApplyConfiguration{} - case computev1alpha1.SchemeGroupVersion.WithKind("NetworkInterface"): - return &applyconfigurationscomputev1alpha1.NetworkInterfaceApplyConfiguration{} - case computev1alpha1.SchemeGroupVersion.WithKind("NetworkInterfaceSource"): - return &applyconfigurationscomputev1alpha1.NetworkInterfaceSourceApplyConfiguration{} - case computev1alpha1.SchemeGroupVersion.WithKind("NetworkInterfaceStatus"): - return &applyconfigurationscomputev1alpha1.NetworkInterfaceStatusApplyConfiguration{} - case computev1alpha1.SchemeGroupVersion.WithKind("Reservation"): - return &applyconfigurationscomputev1alpha1.ReservationApplyConfiguration{} - case computev1alpha1.SchemeGroupVersion.WithKind("ReservationPoolStatus"): - return &applyconfigurationscomputev1alpha1.ReservationPoolStatusApplyConfiguration{} - case computev1alpha1.SchemeGroupVersion.WithKind("ReservationSpec"): - return &applyconfigurationscomputev1alpha1.ReservationSpecApplyConfiguration{} - case computev1alpha1.SchemeGroupVersion.WithKind("ReservationStatus"): - return &applyconfigurationscomputev1alpha1.ReservationStatusApplyConfiguration{} - case computev1alpha1.SchemeGroupVersion.WithKind("Volume"): - return &applyconfigurationscomputev1alpha1.VolumeApplyConfiguration{} - case computev1alpha1.SchemeGroupVersion.WithKind("VolumeSource"): - return &applyconfigurationscomputev1alpha1.VolumeSourceApplyConfiguration{} - case computev1alpha1.SchemeGroupVersion.WithKind("VolumeStatus"): - return &applyconfigurationscomputev1alpha1.VolumeStatusApplyConfiguration{} + // Group=compute.ironcore.dev, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithKind("DaemonEndpoint"): + return &computev1alpha1.DaemonEndpointApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("EFIVar"): + return &computev1alpha1.EFIVarApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("EmptyDiskVolumeSource"): + return &computev1alpha1.EmptyDiskVolumeSourceApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("EphemeralNetworkInterfaceSource"): + return &computev1alpha1.EphemeralNetworkInterfaceSourceApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("EphemeralVolumeSource"): + return &computev1alpha1.EphemeralVolumeSourceApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("Machine"): + return &computev1alpha1.MachineApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("MachineClass"): + return &computev1alpha1.MachineClassApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("MachinePool"): + return &computev1alpha1.MachinePoolApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("MachinePoolAddress"): + return &computev1alpha1.MachinePoolAddressApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("MachinePoolCondition"): + return &computev1alpha1.MachinePoolConditionApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("MachinePoolDaemonEndpoints"): + return &computev1alpha1.MachinePoolDaemonEndpointsApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("MachinePoolSpec"): + return &computev1alpha1.MachinePoolSpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("MachinePoolStatus"): + return &computev1alpha1.MachinePoolStatusApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("MachineSpec"): + return &computev1alpha1.MachineSpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("MachineStatus"): + return &computev1alpha1.MachineStatusApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("NetworkInterface"): + return &computev1alpha1.NetworkInterfaceApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("NetworkInterfaceSource"): + return &computev1alpha1.NetworkInterfaceSourceApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("NetworkInterfaceStatus"): + return &computev1alpha1.NetworkInterfaceStatusApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("Reservation"): + return &computev1alpha1.ReservationApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("ReservationPoolStatus"): + return &computev1alpha1.ReservationPoolStatusApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("ReservationSpec"): + return &computev1alpha1.ReservationSpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("ReservationStatus"): + return &computev1alpha1.ReservationStatusApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("Volume"): + return &computev1alpha1.VolumeApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("VolumeSource"): + return &computev1alpha1.VolumeSourceApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("VolumeStatus"): + return &computev1alpha1.VolumeStatusApplyConfiguration{} // Group=core.ironcore.dev, Version=v1alpha1 case corev1alpha1.SchemeGroupVersion.WithKind("ObjectSelector"): @@ -119,20 +105,6 @@ func ForKind(kind schema.GroupVersionKind) interface{} { case ipamv1alpha1.SchemeGroupVersion.WithKind("PrefixTemplateSpec"): return &applyconfigurationsipamv1alpha1.PrefixTemplateSpecApplyConfiguration{} - // Group=meta.k8s.io, Version=v1 - case v1.SchemeGroupVersion.WithKind("LabelSelector"): - return &metav1.LabelSelectorApplyConfiguration{} - case v1.SchemeGroupVersion.WithKind("LabelSelectorRequirement"): - return &metav1.LabelSelectorRequirementApplyConfiguration{} - case v1.SchemeGroupVersion.WithKind("ManagedFieldsEntry"): - return &metav1.ManagedFieldsEntryApplyConfiguration{} - case v1.SchemeGroupVersion.WithKind("ObjectMeta"): - return &metav1.ObjectMetaApplyConfiguration{} - case v1.SchemeGroupVersion.WithKind("OwnerReference"): - return &metav1.OwnerReferenceApplyConfiguration{} - case v1.SchemeGroupVersion.WithKind("TypeMeta"): - return &metav1.TypeMetaApplyConfiguration{} - // Group=networking.ironcore.dev, Version=v1alpha1 case networkingv1alpha1.SchemeGroupVersion.WithKind("EphemeralPrefixSource"): return &applyconfigurationsnetworkingv1alpha1.EphemeralPrefixSourceApplyConfiguration{} diff --git a/client-go/informers/externalversions/compute/v1alpha1/reservation.go b/client-go/informers/externalversions/compute/v1alpha1/reservation.go index 4b0d99444..b9b5d1c81 100644 --- a/client-go/informers/externalversions/compute/v1alpha1/reservation.go +++ b/client-go/informers/externalversions/compute/v1alpha1/reservation.go @@ -10,8 +10,8 @@ import ( time "time" computev1alpha1 "github.com/ironcore-dev/ironcore/api/compute/v1alpha1" - internalinterfaces "github.com/ironcore-dev/ironcore/client-go/informers/internalinterfaces" - ironcore "github.com/ironcore-dev/ironcore/client-go/ironcore" + internalinterfaces "github.com/ironcore-dev/ironcore/client-go/informers/externalversions/internalinterfaces" + versioned "github.com/ironcore-dev/ironcore/client-go/ironcore/versioned" v1alpha1 "github.com/ironcore-dev/ironcore/client-go/listers/compute/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" @@ -35,14 +35,14 @@ type reservationInformer struct { // NewReservationInformer constructs a new informer for Reservation type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewReservationInformer(client ironcore.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { +func NewReservationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { return NewFilteredReservationInformer(client, namespace, resyncPeriod, indexers, nil) } // NewFilteredReservationInformer constructs a new informer for Reservation type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. -func NewFilteredReservationInformer(client ironcore.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { +func NewFilteredReservationInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { return cache.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options v1.ListOptions) (runtime.Object, error) { @@ -64,7 +64,7 @@ func NewFilteredReservationInformer(client ironcore.Interface, namespace string, ) } -func (f *reservationInformer) defaultInformer(client ironcore.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { +func (f *reservationInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { return NewFilteredReservationInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) } diff --git a/client-go/ironcore/versioned/typed/compute/v1alpha1/reservation.go b/client-go/ironcore/versioned/typed/compute/v1alpha1/reservation.go index c69131dda..9dd0da5e9 100644 --- a/client-go/ironcore/versioned/typed/compute/v1alpha1/reservation.go +++ b/client-go/ironcore/versioned/typed/compute/v1alpha1/reservation.go @@ -13,7 +13,7 @@ import ( v1alpha1 "github.com/ironcore-dev/ironcore/api/compute/v1alpha1" computev1alpha1 "github.com/ironcore-dev/ironcore/client-go/applyconfigurations/compute/v1alpha1" - scheme "github.com/ironcore-dev/ironcore/client-go/ironcore/scheme" + scheme "github.com/ironcore-dev/ironcore/client-go/ironcore/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" diff --git a/config/machinepoollet-broker/broker-rbac/role.yaml b/config/machinepoollet-broker/broker-rbac/role.yaml index 63fc023d0..8a0d0aabd 100644 --- a/config/machinepoollet-broker/broker-rbac/role.yaml +++ b/config/machinepoollet-broker/broker-rbac/role.yaml @@ -1,6 +1,6 @@ --- apiVersion: rbac.authorization.k8s.io/v1 -kind: Role +kind: ClusterRole metadata: name: broker-role rules: @@ -43,6 +43,18 @@ rules: verbs: - create - get +- apiGroups: + - compute.ironcore.dev + resources: + - reservations + verbs: + - create + - delete + - get + - list + - patch + - update + - watch - apiGroups: - networking.ironcore.dev resources: