From 93364db7f5702de54877f37e07a8686ae8ce9c86 Mon Sep 17 00:00:00 2001 From: Damyan Yordanov Date: Mon, 23 Dec 2024 12:31:51 +0100 Subject: [PATCH] Switch `OOB` plugin to new k8s client initialization --- internal/kubernetes/client.go | 1 + plugins/oob/k8s.go | 15 ++++----------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/internal/kubernetes/client.go b/internal/kubernetes/client.go index b1ada74..1ea3944 100644 --- a/internal/kubernetes/client.go +++ b/internal/kubernetes/client.go @@ -5,6 +5,7 @@ package kubernetes import ( "fmt" + "k8s.io/client-go/kubernetes/scheme" ipamv1alpha1 "github.com/ironcore-dev/ipam/api/ipam/v1alpha1" diff --git a/plugins/oob/k8s.go b/plugins/oob/k8s.go index 6401c75..faca213 100644 --- a/plugins/oob/k8s.go +++ b/plugins/oob/k8s.go @@ -12,6 +12,8 @@ import ( "reflect" "strings" + "github.com/ironcore-dev/fedhcp/internal/kubernetes" + apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/watch" @@ -24,7 +26,6 @@ import ( corev1client "k8s.io/client-go/kubernetes/typed/core/v1" "k8s.io/client-go/tools/record" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/client/config" ) const ( @@ -41,16 +42,8 @@ type K8sClient struct { } func NewK8sClient(namespace string, oobLabel string) (*K8sClient, error) { - - if err := ipamv1alpha1.AddToScheme(scheme.Scheme); err != nil { - return nil, fmt.Errorf("unable to add registered types ipam to client scheme %w", err) - } - - cfg := config.GetConfigOrDie() - cl, err := client.New(cfg, client.Options{}) - if err != nil { - return nil, fmt.Errorf("failed to create controller runtime client %w", err) - } + cfg := kubernetes.GetConfig() + cl := kubernetes.GetClient() clientset, err := ipam.NewForConfig(cfg) if err != nil {