Skip to content

Commit

Permalink
Switch OOB plugin to new k8s client initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
damyan committed Dec 23, 2024
1 parent b4bcfed commit 93364db
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
1 change: 1 addition & 0 deletions internal/kubernetes/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package kubernetes

import (
"fmt"

"k8s.io/client-go/kubernetes/scheme"

ipamv1alpha1 "github.com/ironcore-dev/ipam/api/ipam/v1alpha1"
Expand Down
15 changes: 4 additions & 11 deletions plugins/oob/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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 (
Expand All @@ -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 {
Expand Down

0 comments on commit 93364db

Please sign in to comment.