From 27ef6fb9fd33f607239ff1930ccc43de31bff717 Mon Sep 17 00:00:00 2001 From: rasel Date: Tue, 5 Mar 2024 18:45:21 +0600 Subject: [PATCH 1/3] remove kube-system namespace permissions Signed-off-by: rasel --- .../clusterbinding_reconcile.go | 6 +-- pkg/konnector/konnector_controller.go | 5 ++- pkg/konnector/konnector_reconcile.go | 38 +++++++++++-------- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/contrib/example-backend/controllers/clusterbinding/clusterbinding_reconcile.go b/contrib/example-backend/controllers/clusterbinding/clusterbinding_reconcile.go index d5aa547d..b87057c7 100644 --- a/contrib/example-backend/controllers/clusterbinding/clusterbinding_reconcile.go +++ b/contrib/example-backend/controllers/clusterbinding/clusterbinding_reconcile.go @@ -60,9 +60,9 @@ type reconciler struct { func (r *reconciler) reconcile(ctx context.Context, clusterBinding *v1alpha1.ClusterBinding) error { var errs []error - if err := r.ensureKubeSystemNSAccess(ctx, clusterBinding); err != nil { - errs = append(errs, err) - } + //if err := r.ensureKubeSystemNSAccess(ctx, clusterBinding); err != nil { + // errs = append(errs, err) + //} r.ensureClusterBindingConditions(clusterBinding) if err := r.ensureRBACRoleBinding(ctx, clusterBinding); err != nil { errs = append(errs, err) diff --git a/pkg/konnector/konnector_controller.go b/pkg/konnector/konnector_controller.go index 6a64e2d1..ab8f6d36 100644 --- a/pkg/konnector/konnector_controller.go +++ b/pkg/konnector/konnector_controller.go @@ -59,7 +59,10 @@ func New( namespaceInformer coreinformers.NamespaceInformer, crdInformer crdinformers.CustomResourceDefinitionInformer, ) (*Controller, error) { - queue := workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), controllerName) + //queue := workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), controllerName) + queue := workqueue.NewRateLimitingQueueWithConfig(workqueue.DefaultControllerRateLimiter(), workqueue.RateLimitingQueueConfig{ + Name: controllerName, + }) logger := klog.Background().WithValues("Controller", controllerName) diff --git a/pkg/konnector/konnector_reconcile.go b/pkg/konnector/konnector_reconcile.go index 306fa5a3..085d4b77 100644 --- a/pkg/konnector/konnector_reconcile.go +++ b/pkg/konnector/konnector_reconcile.go @@ -26,14 +26,12 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/sets" - kubernetesclient "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/clientcmd" "k8s.io/klog/v2" ) -const namespaceKubeSystem = "kube-system" +//const namespaceKubeSystem = "kube-system" type startable interface { Start(ctx context.Context) @@ -56,7 +54,7 @@ type controllerContext struct { } type providerIdentifier struct { - kubeconfig, secretRefName, secretRefNamespace string + kubeconfig, secretRefName, secretRefNamespace, clusterUID string } func (r *reconciler) reconcile(ctx context.Context, binding *kubebindv1alpha1.APIServiceBinding) error { @@ -74,11 +72,17 @@ func (r *reconciler) reconcile(ctx context.Context, binding *kubebindv1alpha1.AP logger.V(2).Info("secret not found", "secret", ref.Namespace+"/"+ref.Name) } else { kubeconfigs = append(kubeconfigs, string(secret.Data[ref.Key])) - identifiers = append(identifiers, providerIdentifier{ + idf := providerIdentifier{ kubeconfig: string(secret.Data[ref.Key]), secretRefName: ref.Name, secretRefNamespace: ref.Namespace, - }) + } + for _, p := range binding.Status.Providers { + if p.Kubeconfig.Namespace == ref.Namespace { + idf.clusterUID = p.ClusterUID + } + } + identifiers = append(identifiers, idf) } } @@ -141,16 +145,18 @@ func (r *reconciler) reconcile(ctx context.Context, binding *kubebindv1alpha1.AP provider.ConsumerSecretRefKey = identifier.secretRefNamespace + "/" + identifier.secretRefName // set cluster uid - kubeclient, err := kubernetesclient.NewForConfig(provider.Config) - if err != nil { - return err - } - ns, err := kubeclient.CoreV1().Namespaces().Get(ctx, namespaceKubeSystem, metav1.GetOptions{}) - if err != nil { - klog.Error(err.Error()) - return err - } - provider.ClusterID = string(ns.GetUID()) + //kubeclient, err := kubernetesclient.NewForConfig(provider.Config) + //if err != nil { + // return err + //} + //ns, err := kubeclient.CoreV1().Namespaces().Get(ctx, namespaceKubeSystem, metav1.GetOptions{}) + //if err != nil { + // klog.Error(err.Error()) + // return err + //} + //provider.ClusterID = string(ns.GetUID()) + + provider.ClusterID = identifier.clusterUID providerInfos = append(providerInfos, &provider) } From 0ec41cf0d8b7197f467f197d1d32f0e7e119c760 Mon Sep 17 00:00:00 2001 From: rasel Date: Wed, 6 Mar 2024 15:27:27 +0600 Subject: [PATCH 2/3] Restructure APIServiceBinding to remove konnector's kube-system namespace access permissions Signed-off-by: rasel --- .../v1alpha1/apiservicebinding_types.go | 11 +-- .../v1alpha1/zz_generated.deepcopy.go | 19 +---- client/clientset/versioned/clientset.go | 1 - .../versioned/fake/clientset_generated.go | 1 - client/clientset/versioned/fake/register.go | 1 - client/clientset/versioned/scheme/register.go | 1 - .../kubebind/v1alpha1/apiservicebinding.go | 1 - .../kubebind/v1alpha1/apiserviceexport.go | 1 - .../v1alpha1/apiserviceexportrequest.go | 1 - .../kubebind/v1alpha1/apiservicenamespace.go | 1 - .../typed/kubebind/v1alpha1/clusterbinding.go | 1 - .../v1alpha1/fake/fake_apiservicebinding.go | 1 - .../v1alpha1/fake/fake_apiserviceexport.go | 1 - .../fake/fake_apiserviceexportrequest.go | 1 - .../v1alpha1/fake/fake_apiservicenamespace.go | 1 - .../v1alpha1/fake/fake_clusterbinding.go | 1 - .../v1alpha1/fake/fake_kubebind_client.go | 1 - .../kubebind/v1alpha1/kubebind_client.go | 1 - client/informers/externalversions/factory.go | 1 - client/informers/externalversions/generic.go | 1 - .../internalinterfaces/factory_interfaces.go | 1 - .../kubebind/v1alpha1/apiservicebinding.go | 1 - .../kubebind/v1alpha1/apiserviceexport.go | 1 - .../v1alpha1/apiserviceexportrequest.go | 1 - .../kubebind/v1alpha1/apiservicenamespace.go | 1 - .../kubebind/v1alpha1/clusterbinding.go | 1 - .../kubebind/v1alpha1/apiservicebinding.go | 1 - .../kubebind/v1alpha1/apiserviceexport.go | 1 - .../v1alpha1/apiserviceexportrequest.go | 1 - .../kubebind/v1alpha1/apiservicenamespace.go | 1 - .../kubebind/v1alpha1/clusterbinding.go | 1 - ...-bind.appscode.com_apiservicebindings.yaml | 79 +++++++------------ hack/examples/docker-machine.yaml | 2 +- pkg/indexers/servicebinding.go | 6 +- .../clusterbinding_controller.go | 9 +++ .../clusterbinding_reconcile.go | 32 ++++++++ .../servicebinding_reconcile.go | 52 ++++++------ .../servicebinding_reconcile.go | 30 +++---- pkg/konnector/konnector_reconcile.go | 22 +++--- pkg/kubectl/bind-apiservice/plugin/bind.go | 2 +- .../bind-apiservice/plugin/konnector.go | 5 +- .../bind-apiservice/plugin/servicebindings.go | 37 +++++---- pkg/kubectl/bind/plugin/bind.go | 2 +- 43 files changed, 156 insertions(+), 181 deletions(-) diff --git a/apis/kubebind/v1alpha1/apiservicebinding_types.go b/apis/kubebind/v1alpha1/apiservicebinding_types.go index f50dbf29..7c9fc726 100644 --- a/apis/kubebind/v1alpha1/apiservicebinding_types.go +++ b/apis/kubebind/v1alpha1/apiservicebinding_types.go @@ -85,17 +85,17 @@ func (in *APIServiceBinding) SetConditions(conditions conditionsapi.Conditions) } type APIServiceBindingSpec struct { - // kubeconfigSecretName is the secret ref that contains the kubeconfig of the service cluster. - // // +required // +kubebuilder:validation:Required - KubeconfigSecretRefs []ClusterSecretKeyRef `json:"kubeconfigSecretRefs"` + // Providers contains the provider ClusterIdentity and KubeconfigSecretRef of the provider cluster + Providers []Provider `json:"providers,omitempty"` } type Provider struct { ClusterIdentity `json:",inline"` + RemoteNamespace string `json:"remoteNamespace,omitempty"` - Kubeconfig *ClusterSecretKeyRef `json:"kubeconfigs,omitempty"` + Kubeconfig ClusterSecretKeyRef `json:"kubeconfig,omitempty"` } type ClusterIdentity struct { @@ -104,9 +104,6 @@ type ClusterIdentity struct { } type APIServiceBindingStatus struct { - // Providers contains the provider ClusterIdentity and KubeconfigSecretRef of the provider cluster - Providers []Provider `json:"providers,omitempty"` - // conditions is a list of conditions that apply to the APIServiceBinding. Conditions conditionsapi.Conditions `json:"conditions,omitempty"` } diff --git a/apis/kubebind/v1alpha1/zz_generated.deepcopy.go b/apis/kubebind/v1alpha1/zz_generated.deepcopy.go index 314fc6d4..30745cb4 100644 --- a/apis/kubebind/v1alpha1/zz_generated.deepcopy.go +++ b/apis/kubebind/v1alpha1/zz_generated.deepcopy.go @@ -91,9 +91,9 @@ func (in *APIServiceBindingList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *APIServiceBindingSpec) DeepCopyInto(out *APIServiceBindingSpec) { *out = *in - if in.KubeconfigSecretRefs != nil { - in, out := &in.KubeconfigSecretRefs, &out.KubeconfigSecretRefs - *out = make([]ClusterSecretKeyRef, len(*in)) + if in.Providers != nil { + in, out := &in.Providers, &out.Providers + *out = make([]Provider, len(*in)) copy(*out, *in) } return @@ -112,13 +112,6 @@ func (in *APIServiceBindingSpec) DeepCopy() *APIServiceBindingSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *APIServiceBindingStatus) DeepCopyInto(out *APIServiceBindingStatus) { *out = *in - if in.Providers != nil { - in, out := &in.Providers, &out.Providers - *out = make([]Provider, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions *out = make(v1.Conditions, len(*in)) @@ -908,11 +901,7 @@ func (in *OAuth2CodeGrant) DeepCopy() *OAuth2CodeGrant { func (in *Provider) DeepCopyInto(out *Provider) { *out = *in out.ClusterIdentity = in.ClusterIdentity - if in.Kubeconfig != nil { - in, out := &in.Kubeconfig, &out.Kubeconfig - *out = new(ClusterSecretKeyRef) - **out = **in - } + out.Kubeconfig = in.Kubeconfig return } diff --git a/client/clientset/versioned/clientset.go b/client/clientset/versioned/clientset.go index 42398b71..7644fcf6 100644 --- a/client/clientset/versioned/clientset.go +++ b/client/clientset/versioned/clientset.go @@ -23,7 +23,6 @@ import ( "net/http" kubebindv1alpha1 "go.bytebuilders.dev/kube-bind/client/clientset/versioned/typed/kubebind/v1alpha1" - discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" diff --git a/client/clientset/versioned/fake/clientset_generated.go b/client/clientset/versioned/fake/clientset_generated.go index 8f738510..eb09f2aa 100644 --- a/client/clientset/versioned/fake/clientset_generated.go +++ b/client/clientset/versioned/fake/clientset_generated.go @@ -22,7 +22,6 @@ import ( clientset "go.bytebuilders.dev/kube-bind/client/clientset/versioned" kubebindv1alpha1 "go.bytebuilders.dev/kube-bind/client/clientset/versioned/typed/kubebind/v1alpha1" fakekubebindv1alpha1 "go.bytebuilders.dev/kube-bind/client/clientset/versioned/typed/kubebind/v1alpha1/fake" - "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/discovery" diff --git a/client/clientset/versioned/fake/register.go b/client/clientset/versioned/fake/register.go index e55662ce..79c40bc5 100644 --- a/client/clientset/versioned/fake/register.go +++ b/client/clientset/versioned/fake/register.go @@ -20,7 +20,6 @@ package fake import ( kubebindv1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/client/clientset/versioned/scheme/register.go b/client/clientset/versioned/scheme/register.go index 241f9af3..964b9476 100644 --- a/client/clientset/versioned/scheme/register.go +++ b/client/clientset/versioned/scheme/register.go @@ -20,7 +20,6 @@ package scheme import ( kubebindv1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/client/clientset/versioned/typed/kubebind/v1alpha1/apiservicebinding.go b/client/clientset/versioned/typed/kubebind/v1alpha1/apiservicebinding.go index 983b621e..4fa13857 100644 --- a/client/clientset/versioned/typed/kubebind/v1alpha1/apiservicebinding.go +++ b/client/clientset/versioned/typed/kubebind/v1alpha1/apiservicebinding.go @@ -24,7 +24,6 @@ import ( v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" scheme "go.bytebuilders.dev/kube-bind/client/clientset/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/client/clientset/versioned/typed/kubebind/v1alpha1/apiserviceexport.go b/client/clientset/versioned/typed/kubebind/v1alpha1/apiserviceexport.go index 97e87109..c00b89e4 100644 --- a/client/clientset/versioned/typed/kubebind/v1alpha1/apiserviceexport.go +++ b/client/clientset/versioned/typed/kubebind/v1alpha1/apiserviceexport.go @@ -24,7 +24,6 @@ import ( v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" scheme "go.bytebuilders.dev/kube-bind/client/clientset/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/client/clientset/versioned/typed/kubebind/v1alpha1/apiserviceexportrequest.go b/client/clientset/versioned/typed/kubebind/v1alpha1/apiserviceexportrequest.go index eaeda2f6..b023b4a6 100644 --- a/client/clientset/versioned/typed/kubebind/v1alpha1/apiserviceexportrequest.go +++ b/client/clientset/versioned/typed/kubebind/v1alpha1/apiserviceexportrequest.go @@ -24,7 +24,6 @@ import ( v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" scheme "go.bytebuilders.dev/kube-bind/client/clientset/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/client/clientset/versioned/typed/kubebind/v1alpha1/apiservicenamespace.go b/client/clientset/versioned/typed/kubebind/v1alpha1/apiservicenamespace.go index 8e0a14cb..33d55df6 100644 --- a/client/clientset/versioned/typed/kubebind/v1alpha1/apiservicenamespace.go +++ b/client/clientset/versioned/typed/kubebind/v1alpha1/apiservicenamespace.go @@ -24,7 +24,6 @@ import ( v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" scheme "go.bytebuilders.dev/kube-bind/client/clientset/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/client/clientset/versioned/typed/kubebind/v1alpha1/clusterbinding.go b/client/clientset/versioned/typed/kubebind/v1alpha1/clusterbinding.go index 08a2d16b..ccef3f89 100644 --- a/client/clientset/versioned/typed/kubebind/v1alpha1/clusterbinding.go +++ b/client/clientset/versioned/typed/kubebind/v1alpha1/clusterbinding.go @@ -24,7 +24,6 @@ import ( v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" scheme "go.bytebuilders.dev/kube-bind/client/clientset/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/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiservicebinding.go b/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiservicebinding.go index 8c194366..31d20a50 100644 --- a/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiservicebinding.go +++ b/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiservicebinding.go @@ -22,7 +22,6 @@ import ( "context" v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" types "k8s.io/apimachinery/pkg/types" diff --git a/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiserviceexport.go b/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiserviceexport.go index 77bca648..3551b3b7 100644 --- a/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiserviceexport.go +++ b/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiserviceexport.go @@ -22,7 +22,6 @@ import ( "context" v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" types "k8s.io/apimachinery/pkg/types" diff --git a/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiserviceexportrequest.go b/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiserviceexportrequest.go index 402d992a..d1e9d810 100644 --- a/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiserviceexportrequest.go +++ b/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiserviceexportrequest.go @@ -22,7 +22,6 @@ import ( "context" v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" types "k8s.io/apimachinery/pkg/types" diff --git a/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiservicenamespace.go b/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiservicenamespace.go index 55f5a3e1..06bd485e 100644 --- a/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiservicenamespace.go +++ b/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiservicenamespace.go @@ -22,7 +22,6 @@ import ( "context" v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" types "k8s.io/apimachinery/pkg/types" diff --git a/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_clusterbinding.go b/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_clusterbinding.go index 908644bf..0690153f 100644 --- a/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_clusterbinding.go +++ b/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_clusterbinding.go @@ -22,7 +22,6 @@ import ( "context" v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" types "k8s.io/apimachinery/pkg/types" diff --git a/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_kubebind_client.go b/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_kubebind_client.go index 02aa9b5b..79754868 100644 --- a/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_kubebind_client.go +++ b/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_kubebind_client.go @@ -20,7 +20,6 @@ package fake import ( v1alpha1 "go.bytebuilders.dev/kube-bind/client/clientset/versioned/typed/kubebind/v1alpha1" - rest "k8s.io/client-go/rest" testing "k8s.io/client-go/testing" ) diff --git a/client/clientset/versioned/typed/kubebind/v1alpha1/kubebind_client.go b/client/clientset/versioned/typed/kubebind/v1alpha1/kubebind_client.go index da279d73..30ff921e 100644 --- a/client/clientset/versioned/typed/kubebind/v1alpha1/kubebind_client.go +++ b/client/clientset/versioned/typed/kubebind/v1alpha1/kubebind_client.go @@ -23,7 +23,6 @@ import ( v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" "go.bytebuilders.dev/kube-bind/client/clientset/versioned/scheme" - rest "k8s.io/client-go/rest" ) diff --git a/client/informers/externalversions/factory.go b/client/informers/externalversions/factory.go index e2900ed4..4079fd81 100644 --- a/client/informers/externalversions/factory.go +++ b/client/informers/externalversions/factory.go @@ -26,7 +26,6 @@ import ( versioned "go.bytebuilders.dev/kube-bind/client/clientset/versioned" internalinterfaces "go.bytebuilders.dev/kube-bind/client/informers/externalversions/internalinterfaces" kubebind "go.bytebuilders.dev/kube-bind/client/informers/externalversions/kubebind" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/client/informers/externalversions/generic.go b/client/informers/externalversions/generic.go index 9cd6b085..625df14a 100644 --- a/client/informers/externalversions/generic.go +++ b/client/informers/externalversions/generic.go @@ -22,7 +22,6 @@ import ( "fmt" v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" - schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" ) diff --git a/client/informers/externalversions/internalinterfaces/factory_interfaces.go b/client/informers/externalversions/internalinterfaces/factory_interfaces.go index e2a8c919..34e94803 100644 --- a/client/informers/externalversions/internalinterfaces/factory_interfaces.go +++ b/client/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -22,7 +22,6 @@ import ( time "time" versioned "go.bytebuilders.dev/kube-bind/client/clientset/versioned" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" cache "k8s.io/client-go/tools/cache" diff --git a/client/informers/externalversions/kubebind/v1alpha1/apiservicebinding.go b/client/informers/externalversions/kubebind/v1alpha1/apiservicebinding.go index e6aef4aa..2076607e 100644 --- a/client/informers/externalversions/kubebind/v1alpha1/apiservicebinding.go +++ b/client/informers/externalversions/kubebind/v1alpha1/apiservicebinding.go @@ -26,7 +26,6 @@ import ( versioned "go.bytebuilders.dev/kube-bind/client/clientset/versioned" internalinterfaces "go.bytebuilders.dev/kube-bind/client/informers/externalversions/internalinterfaces" v1alpha1 "go.bytebuilders.dev/kube-bind/client/listers/kubebind/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" diff --git a/client/informers/externalversions/kubebind/v1alpha1/apiserviceexport.go b/client/informers/externalversions/kubebind/v1alpha1/apiserviceexport.go index bffa7049..caba1d0a 100644 --- a/client/informers/externalversions/kubebind/v1alpha1/apiserviceexport.go +++ b/client/informers/externalversions/kubebind/v1alpha1/apiserviceexport.go @@ -26,7 +26,6 @@ import ( versioned "go.bytebuilders.dev/kube-bind/client/clientset/versioned" internalinterfaces "go.bytebuilders.dev/kube-bind/client/informers/externalversions/internalinterfaces" v1alpha1 "go.bytebuilders.dev/kube-bind/client/listers/kubebind/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" diff --git a/client/informers/externalversions/kubebind/v1alpha1/apiserviceexportrequest.go b/client/informers/externalversions/kubebind/v1alpha1/apiserviceexportrequest.go index 2bdc3066..56a01564 100644 --- a/client/informers/externalversions/kubebind/v1alpha1/apiserviceexportrequest.go +++ b/client/informers/externalversions/kubebind/v1alpha1/apiserviceexportrequest.go @@ -26,7 +26,6 @@ import ( versioned "go.bytebuilders.dev/kube-bind/client/clientset/versioned" internalinterfaces "go.bytebuilders.dev/kube-bind/client/informers/externalversions/internalinterfaces" v1alpha1 "go.bytebuilders.dev/kube-bind/client/listers/kubebind/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" diff --git a/client/informers/externalversions/kubebind/v1alpha1/apiservicenamespace.go b/client/informers/externalversions/kubebind/v1alpha1/apiservicenamespace.go index 10e85464..eec4b358 100644 --- a/client/informers/externalversions/kubebind/v1alpha1/apiservicenamespace.go +++ b/client/informers/externalversions/kubebind/v1alpha1/apiservicenamespace.go @@ -26,7 +26,6 @@ import ( versioned "go.bytebuilders.dev/kube-bind/client/clientset/versioned" internalinterfaces "go.bytebuilders.dev/kube-bind/client/informers/externalversions/internalinterfaces" v1alpha1 "go.bytebuilders.dev/kube-bind/client/listers/kubebind/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" diff --git a/client/informers/externalversions/kubebind/v1alpha1/clusterbinding.go b/client/informers/externalversions/kubebind/v1alpha1/clusterbinding.go index 3d860f5c..03dfa010 100644 --- a/client/informers/externalversions/kubebind/v1alpha1/clusterbinding.go +++ b/client/informers/externalversions/kubebind/v1alpha1/clusterbinding.go @@ -26,7 +26,6 @@ import ( versioned "go.bytebuilders.dev/kube-bind/client/clientset/versioned" internalinterfaces "go.bytebuilders.dev/kube-bind/client/informers/externalversions/internalinterfaces" v1alpha1 "go.bytebuilders.dev/kube-bind/client/listers/kubebind/v1alpha1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" diff --git a/client/listers/kubebind/v1alpha1/apiservicebinding.go b/client/listers/kubebind/v1alpha1/apiservicebinding.go index e1a48125..0677abe4 100644 --- a/client/listers/kubebind/v1alpha1/apiservicebinding.go +++ b/client/listers/kubebind/v1alpha1/apiservicebinding.go @@ -20,7 +20,6 @@ package v1alpha1 import ( v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" diff --git a/client/listers/kubebind/v1alpha1/apiserviceexport.go b/client/listers/kubebind/v1alpha1/apiserviceexport.go index 18547a54..33f03fce 100644 --- a/client/listers/kubebind/v1alpha1/apiserviceexport.go +++ b/client/listers/kubebind/v1alpha1/apiserviceexport.go @@ -20,7 +20,6 @@ package v1alpha1 import ( v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" diff --git a/client/listers/kubebind/v1alpha1/apiserviceexportrequest.go b/client/listers/kubebind/v1alpha1/apiserviceexportrequest.go index df065c91..268dd085 100644 --- a/client/listers/kubebind/v1alpha1/apiserviceexportrequest.go +++ b/client/listers/kubebind/v1alpha1/apiserviceexportrequest.go @@ -20,7 +20,6 @@ package v1alpha1 import ( v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" diff --git a/client/listers/kubebind/v1alpha1/apiservicenamespace.go b/client/listers/kubebind/v1alpha1/apiservicenamespace.go index 54e85592..1f7ed16b 100644 --- a/client/listers/kubebind/v1alpha1/apiservicenamespace.go +++ b/client/listers/kubebind/v1alpha1/apiservicenamespace.go @@ -20,7 +20,6 @@ package v1alpha1 import ( v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" diff --git a/client/listers/kubebind/v1alpha1/clusterbinding.go b/client/listers/kubebind/v1alpha1/clusterbinding.go index 40572766..e09e14e9 100644 --- a/client/listers/kubebind/v1alpha1/clusterbinding.go +++ b/client/listers/kubebind/v1alpha1/clusterbinding.go @@ -20,7 +20,6 @@ package v1alpha1 import ( v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" diff --git a/crds/kube-bind.appscode.com_apiservicebindings.yaml b/crds/kube-bind.appscode.com_apiservicebindings.yaml index d1b54fc4..f986e57c 100644 --- a/crds/kube-bind.appscode.com_apiservicebindings.yaml +++ b/crds/kube-bind.appscode.com_apiservicebindings.yaml @@ -55,33 +55,42 @@ spec: description: spec specifies how an API service from a service provider should be bound in the local consumer cluster. properties: - kubeconfigSecretRefs: - description: kubeconfigSecretName is the secret ref that contains - the kubeconfig of the service cluster. + providers: + description: Providers contains the provider ClusterIdentity and KubeconfigSecretRef + of the provider cluster items: properties: - key: - description: The key of the secret to select from. Must be - "kubeconfig". - enum: - - kubeconfig + clusterName: type: string - name: - description: Name of the referent. - minLength: 1 + clusterUID: type: string - namespace: - description: Namespace of the referent. - minLength: 1 + kubeconfig: + properties: + key: + description: The key of the secret to select from. Must + be "kubeconfig". + enum: + - kubeconfig + type: string + name: + description: Name of the referent. + minLength: 1 + type: string + namespace: + description: Namespace of the referent. + minLength: 1 + type: string + required: + - key + - name + - namespace + type: object + remoteNamespace: type: string - required: - - key - - name - - namespace type: object type: array required: - - kubeconfigSecretRefs + - providers type: object status: description: status contains reconciliation information for a service @@ -139,38 +148,6 @@ spec: - type type: object type: array - providers: - description: Providers contains the provider ClusterIdentity and KubeconfigSecretRef - of the provider cluster - items: - properties: - clusterName: - type: string - clusterUID: - type: string - kubeconfigs: - properties: - key: - description: The key of the secret to select from. Must - be "kubeconfig". - enum: - - kubeconfig - type: string - name: - description: Name of the referent. - minLength: 1 - type: string - namespace: - description: Namespace of the referent. - minLength: 1 - type: string - required: - - key - - name - - namespace - type: object - type: object - type: array type: object type: object served: true diff --git a/hack/examples/docker-machine.yaml b/hack/examples/docker-machine.yaml index 56c15be5..829cd2ac 100644 --- a/hack/examples/docker-machine.yaml +++ b/hack/examples/docker-machine.yaml @@ -5,7 +5,7 @@ metadata: namespace: demo annotations: # provider.kube-bind.appscode.com/cluster-id: 71a87546-b339-45ee-bca5-033d277faca2 - provider.kube-bind.appscode.com/cluster-id: e95736c6-06f2-43ae-9f17-bbcc0c38c4ed + provider.kube-bind.appscode.com/cluster-id: 68d95713-cdbf-4fc1-96ed-ca2fc743ec7c spec: driver: name: google diff --git a/pkg/indexers/servicebinding.go b/pkg/indexers/servicebinding.go index 96221d2c..5115f1fc 100644 --- a/pkg/indexers/servicebinding.go +++ b/pkg/indexers/servicebinding.go @@ -33,10 +33,10 @@ func IndexServiceBindingByKubeconfigSecret(obj interface{}) ([]string, error) { } func ByServiceBindingKubeconfigSecretKey(binding *kubebindv1alpha1.APIServiceBinding) []string { - refs := binding.Spec.KubeconfigSecretRefs + ps := binding.Spec.Providers var secretRefs []string - for _, ref := range refs { - secretRefs = append(secretRefs, ref.Namespace+"/"+ref.Name) + for _, p := range ps { + secretRefs = append(secretRefs, p.Kubeconfig.Namespace+"/"+p.Kubeconfig.Name) } return secretRefs } diff --git a/pkg/konnector/controllers/cluster/clusterbinding/clusterbinding_controller.go b/pkg/konnector/controllers/cluster/clusterbinding/clusterbinding_controller.go index 16584ff4..f4d71c32 100644 --- a/pkg/konnector/controllers/cluster/clusterbinding/clusterbinding_controller.go +++ b/pkg/konnector/controllers/cluster/clusterbinding/clusterbinding_controller.go @@ -101,6 +101,15 @@ func NewController( heartbeatInterval: heartbeatInterval, providerInfos: providerInfos, + updateServiceBinding: func(ctx context.Context, sbinding *v1alpha1.APIServiceBinding) error { + if _, err = consumerBindClient.KubeBindV1alpha1().APIServiceBindings().Update(ctx, sbinding, metav1.UpdateOptions{}); err != nil { + return err + } + return nil + }, + getServiceBinding: func(ctx context.Context) (*v1alpha1.APIServiceBindingList, error) { + return consumerBindClient.KubeBindV1alpha1().APIServiceBindings().List(ctx, metav1.ListOptions{}) + }, getProviderInfo: func(clusterID string) (*konnectormodels.ProviderInfo, error) { for _, provider := range providerInfos { if provider.ClusterID == clusterID { diff --git a/pkg/konnector/controllers/cluster/clusterbinding/clusterbinding_reconcile.go b/pkg/konnector/controllers/cluster/clusterbinding/clusterbinding_reconcile.go index a92f40b4..8ed014a6 100644 --- a/pkg/konnector/controllers/cluster/clusterbinding/clusterbinding_reconcile.go +++ b/pkg/konnector/controllers/cluster/clusterbinding/clusterbinding_reconcile.go @@ -18,6 +18,7 @@ package clusterbinding import ( "context" + "fmt" "time" kubebindv1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" @@ -38,6 +39,8 @@ import ( type reconciler struct { heartbeatInterval time.Duration + updateServiceBinding func(ctx context.Context, sbinding *kubebindv1alpha1.APIServiceBinding) error + getServiceBinding func(ctx context.Context) (*kubebindv1alpha1.APIServiceBindingList, error) getProviderSecret func(porvider *konnectormodels.ProviderInfo) (*corev1.Secret, error) getConsumerSecret func(provider *konnectormodels.ProviderInfo) (*corev1.Secret, error) updateConsumerSecret func(ctx context.Context, secret *corev1.Secret) (*corev1.Secret, error) @@ -66,11 +69,40 @@ func (r *reconciler) reconcile(ctx context.Context, binding *kubebindv1alpha1.Cl errs = append(errs, err) } + if err := r.ensureRightScopedServiceBinding(ctx, binding); err != nil { + errs = append(errs, err) + } + conditions.SetSummary(binding) return utilerrors.NewAggregate(errs) } +func (r *reconciler) ensureRightScopedServiceBinding(ctx context.Context, binding *kubebindv1alpha1.ClusterBinding) error { + // return error if provider info is not set in clusterBinding status + if binding.Status.Provider.ClusterName == "" || binding.Status.Provider.ClusterUID == "" { + return fmt.Errorf("cluster name or uid is missing in ClusterBinding status") + } + + sblist, err := r.getServiceBinding(ctx) + if err != nil { + return err + } + for _, sb := range sblist.Items { + for i := range sb.Spec.Providers { + if sb.Spec.Providers[i].RemoteNamespace == binding.Namespace && (sb.Spec.Providers[i].ClusterUID == "" || sb.Spec.Providers[i].ClusterName == "") { + sb.Spec.Providers[i].ClusterUID = binding.Status.Provider.ClusterUID + sb.Spec.Providers[i].ClusterName = binding.Status.Provider.ClusterName + if err = r.updateServiceBinding(ctx, &sb); err != nil { + return err + } + break + } + } + } + return nil +} + func (r *reconciler) ensureHeartbeat(ctx context.Context, binding *kubebindv1alpha1.ClusterBinding) error { binding.Status.HeartbeatInterval.Duration = r.heartbeatInterval if now := time.Now(); binding.Status.LastHeartbeatTime.IsZero() || now.After(binding.Status.LastHeartbeatTime.Add(r.heartbeatInterval/2)) { diff --git a/pkg/konnector/controllers/cluster/servicebinding/servicebinding_reconcile.go b/pkg/konnector/controllers/cluster/servicebinding/servicebinding_reconcile.go index dc87e1d3..2b165e07 100644 --- a/pkg/konnector/controllers/cluster/servicebinding/servicebinding_reconcile.go +++ b/pkg/konnector/controllers/cluster/servicebinding/servicebinding_reconcile.go @@ -64,9 +64,9 @@ func (r *reconciler) reconcile(ctx context.Context, binding *v1alpha1.APIService errs = append(errs, err) } - if err := r.ensureClusterName(ctx, binding); err != nil { - errs = append(errs, err) - } + //if err := r.ensureClusterName(ctx, binding); err != nil { + // errs = append(errs, err) + //} conditions.SetSummary(binding) @@ -197,26 +197,26 @@ func (r *reconciler) ensureCRDs(ctx context.Context, binding *v1alpha1.APIServic return utilerrors.NewAggregate(errs) } -func (r *reconciler) ensureClusterName(ctx context.Context, binding *v1alpha1.APIServiceBinding) error { - binding.Status.Providers = []v1alpha1.Provider{} - for _, provider := range r.providerInfos { - clusterBinding, err := r.getClusterBinding(ctx, provider) - if err != nil && !errors.IsNotFound(err) { - return err - } else if errors.IsNotFound(err) { - return nil - } - prov := v1alpha1.Provider{} - prov.Kubeconfig = &v1alpha1.ClusterSecretKeyRef{ - LocalSecretKeyRef: clusterBinding.Spec.KubeconfigSecretRef, - Namespace: clusterBinding.Namespace, - } - if clusterBinding.Status.Provider != nil { - prov.ClusterIdentity.ClusterName = clusterBinding.Spec.ProviderClusterName - prov.ClusterIdentity.ClusterUID = clusterBinding.Status.Provider.ClusterUID - } - binding.Status.Providers = append(binding.Status.Providers, prov) - } - - return nil -} +//func (r *reconciler) ensureClusterName(ctx context.Context, binding *v1alpha1.APIServiceBinding) error { +// binding.Status.Providers = []v1alpha1.Provider{} +// for _, provider := range r.providerInfos { +// clusterBinding, err := r.getClusterBinding(ctx, provider) +// if err != nil && !errors.IsNotFound(err) { +// return err +// } else if errors.IsNotFound(err) { +// return nil +// } +// prov := v1alpha1.Provider{} +// prov.Kubeconfig = &v1alpha1.ClusterSecretKeyRef{ +// LocalSecretKeyRef: clusterBinding.Spec.KubeconfigSecretRef, +// Namespace: clusterBinding.Namespace, +// } +// if clusterBinding.Status.Provider != nil { +// prov.ClusterIdentity.ClusterName = clusterBinding.Spec.ProviderClusterName +// prov.ClusterIdentity.ClusterUID = clusterBinding.Status.Provider.ClusterUID +// } +// binding.Status.Providers = append(binding.Status.Providers, prov) +// } +// +// return nil +//} diff --git a/pkg/konnector/controllers/servicebinding/servicebinding_reconcile.go b/pkg/konnector/controllers/servicebinding/servicebinding_reconcile.go index 1acef380..ff605ed6 100644 --- a/pkg/konnector/controllers/servicebinding/servicebinding_reconcile.go +++ b/pkg/konnector/controllers/servicebinding/servicebinding_reconcile.go @@ -46,8 +46,8 @@ func (r *reconciler) reconcile(ctx context.Context, binding *kubebindv1alpha1.AP } func (r *reconciler) ensureValidKubeconfigSecret(ctx context.Context, binding *kubebindv1alpha1.APIServiceBinding) error { - for _, ref := range binding.Spec.KubeconfigSecretRefs { - secret, err := r.getConsumerSecret(ref.Namespace, ref.Name) + for _, p := range binding.Spec.Providers { + secret, err := r.getConsumerSecret(p.Kubeconfig.Namespace, p.Kubeconfig.Name) if err != nil && !errors.IsNotFound(err) { return err } else if errors.IsNotFound(err) { @@ -57,12 +57,12 @@ func (r *reconciler) ensureValidKubeconfigSecret(ctx context.Context, binding *k "KubeconfigSecretNotFound", conditionsapi.ConditionSeverityError, "Kubeconfig secret %s/%s not found. Rerun kubectl bind for repair.", - ref.Namespace, ref.Name, + p.Kubeconfig.Namespace, p.Kubeconfig.Name, ) return nil } - kubeconfig, found := secret.Data[ref.Key] + kubeconfig, found := secret.Data[p.Kubeconfig.Key] if !found { conditions.MarkFalse( binding, @@ -70,9 +70,9 @@ func (r *reconciler) ensureValidKubeconfigSecret(ctx context.Context, binding *k "KubeconfigSecretInvalid", conditionsapi.ConditionSeverityError, "Kubeconfig secret %s/%s is missing %q string key.", - ref.Namespace, - ref.Name, - ref.Key, + p.Kubeconfig.Namespace, + p.Kubeconfig.Name, + p.Kubeconfig.Key, ) return nil } @@ -85,8 +85,8 @@ func (r *reconciler) ensureValidKubeconfigSecret(ctx context.Context, binding *k "KubeconfigSecretInvalid", conditionsapi.ConditionSeverityError, "Kubeconfig secret %s/%s has an invalid kubeconfig: %v", - ref.Namespace, - ref.Name, + p.Kubeconfig.Namespace, + p.Kubeconfig.Name, err, ) return nil @@ -99,8 +99,8 @@ func (r *reconciler) ensureValidKubeconfigSecret(ctx context.Context, binding *k "KubeconfigSecretInvalid", conditionsapi.ConditionSeverityError, "Kubeconfig secret %s/%s has an invalid kubeconfig: current context %q not found", - ref.Namespace, - ref.Name, + p.Kubeconfig.Namespace, + p.Kubeconfig.Name, cfg.CurrentContext, ) return nil @@ -112,8 +112,8 @@ func (r *reconciler) ensureValidKubeconfigSecret(ctx context.Context, binding *k "KubeconfigSecretInvalid", conditionsapi.ConditionSeverityError, "Kubeconfig secret %s/%s has an invalid kubeconfig: current context %q has no namespace set", - ref.Namespace, - ref.Name, + p.Kubeconfig.Namespace, + p.Kubeconfig.Name, cfg.CurrentContext, ) return nil @@ -125,8 +125,8 @@ func (r *reconciler) ensureValidKubeconfigSecret(ctx context.Context, binding *k "KubeconfigSecretInvalid", conditionsapi.ConditionSeverityError, "Kubeconfig secret %s/%s has an invalid kubeconfig: %v", - ref.Namespace, - ref.Name, + p.Kubeconfig.Namespace, + p.Kubeconfig.Name, err, ) return nil diff --git a/pkg/konnector/konnector_reconcile.go b/pkg/konnector/konnector_reconcile.go index 085d4b77..bf3f01bf 100644 --- a/pkg/konnector/konnector_reconcile.go +++ b/pkg/konnector/konnector_reconcile.go @@ -63,25 +63,23 @@ func (r *reconciler) reconcile(ctx context.Context, binding *kubebindv1alpha1.AP var kubeconfigs []string var identifiers []providerIdentifier - refs := binding.Spec.KubeconfigSecretRefs - for _, ref := range refs { - secret, err := r.getSecret(ref.Namespace, ref.Name) + for _, p := range binding.Spec.Providers { + secret, err := r.getSecret(p.Kubeconfig.Namespace, p.Kubeconfig.Name) if err != nil && !errors.IsNotFound(err) { return err } else if errors.IsNotFound(err) { - logger.V(2).Info("secret not found", "secret", ref.Namespace+"/"+ref.Name) + logger.V(2).Info("secret not found", "secret", p.Kubeconfig.Namespace+"/"+p.Kubeconfig.Name) } else { - kubeconfigs = append(kubeconfigs, string(secret.Data[ref.Key])) + kubeconfigs = append(kubeconfigs, string(secret.Data[p.Kubeconfig.Key])) idf := providerIdentifier{ - kubeconfig: string(secret.Data[ref.Key]), - secretRefName: ref.Name, - secretRefNamespace: ref.Namespace, + kubeconfig: string(secret.Data[p.Kubeconfig.Key]), + secretRefName: p.Kubeconfig.Name, + secretRefNamespace: p.Kubeconfig.Namespace, } - for _, p := range binding.Status.Providers { - if p.Kubeconfig.Namespace == ref.Namespace { - idf.clusterUID = p.ClusterUID - } + if p.ClusterUID != "" { + idf.clusterUID = p.ClusterUID } + identifiers = append(identifiers, idf) } } diff --git a/pkg/kubectl/bind-apiservice/plugin/bind.go b/pkg/kubectl/bind-apiservice/plugin/bind.go index f7cfab35..d9a80749 100644 --- a/pkg/kubectl/bind-apiservice/plugin/bind.go +++ b/pkg/kubectl/bind-apiservice/plugin/bind.go @@ -172,7 +172,7 @@ func (b *BindAPIServiceOptions) Run(ctx context.Context) error { if err != nil { return err } - bindings, err := b.createAPIServiceBindings(ctx, config, result, secretName) + bindings, err := b.createAPIServiceBindings(ctx, config, result, secretName, remoteNamespace) if err != nil { return err } diff --git a/pkg/kubectl/bind-apiservice/plugin/konnector.go b/pkg/kubectl/bind-apiservice/plugin/konnector.go index 1db1ba7a..1028f36e 100644 --- a/pkg/kubectl/bind-apiservice/plugin/konnector.go +++ b/pkg/kubectl/bind-apiservice/plugin/konnector.go @@ -40,8 +40,7 @@ import ( ) const ( - // konnectorImage = "ghcr.io/kube-bind/konnector" - konnectorImage = "superm4n/konnector" + konnectorImage = "ghcr.io/kube-bind/konnector" ) // nolint: unused @@ -71,7 +70,7 @@ func (b *BindAPIServiceOptions) deployKonnector(ctx context.Context, config *res } if b.KonnectorImageOverride != "" { - fmt.Fprintf(b.Options.ErrOut, "🚀 Deploying konnector %s to namespace kube-bind with custom image %q.\n", bindVersion, b.KonnectorImageOverride) // nolint: errcheck + fmt.Fprintf(b.Options.ErrOut, "🚀 Deploying konnector %s to namespace %s with custom image %q.\n", bindVersion, models.KonnectorNamespace, b.KonnectorImageOverride) // nolint: errcheck if err := konnector.Bootstrap(ctx, discoveryClient, dynamicClient, b.KonnectorImageOverride); err != nil { return err } diff --git a/pkg/kubectl/bind-apiservice/plugin/servicebindings.go b/pkg/kubectl/bind-apiservice/plugin/servicebindings.go index dce6e2e9..ce178603 100644 --- a/pkg/kubectl/bind-apiservice/plugin/servicebindings.go +++ b/pkg/kubectl/bind-apiservice/plugin/servicebindings.go @@ -35,7 +35,7 @@ import ( "kmodules.xyz/client-go/conditions" ) -func (b *BindAPIServiceOptions) createAPIServiceBindings(ctx context.Context, config *rest.Config, request *v1alpha1.APIServiceExportRequest, secretName string) ([]*v1alpha1.APIServiceBinding, error) { +func (b *BindAPIServiceOptions) createAPIServiceBindings(ctx context.Context, config *rest.Config, request *v1alpha1.APIServiceExportRequest, secretName, remoteNs string) ([]*v1alpha1.APIServiceBinding, error) { bindClient, err := bindclient.NewForConfig(config) if err != nil { return nil, err @@ -52,30 +52,30 @@ func (b *BindAPIServiceOptions) createAPIServiceBindings(ctx context.Context, co if err != nil && !apierrors.IsNotFound(err) { return nil, err } else if err == nil { - //if existing.Spec.KubeconfigSecretRef.Namespace != "kube-bind" || existing.Spec.KubeconfigSecretRef.Name != secretName { - // return nil, fmt.Errorf("found existing APIServiceBinding %s not from this service provider", name) - //} - hasSecret := false - for _, secRef := range existing.Spec.KubeconfigSecretRefs { - if secRef.Namespace == models.KonnectorNamespace && secRef.Name == secretName { + for _, p := range existing.Spec.Providers { + if p.Kubeconfig.Namespace == models.KonnectorNamespace && p.Kubeconfig.Name == secretName { hasSecret = true fmt.Fprintf(b.Options.IOStreams.ErrOut, "✅ Existing APIServiceBinding \"%s\" already has the secret \"%s\".\n", existing.Name, secretName) // nolint: errcheck break } } + if hasSecret { continue } fmt.Fprintf(b.Options.IOStreams.ErrOut, "✅ Updating existing APIServiceBinding %s.\n", existing.Name) // nolint: errcheck - existing.Spec.KubeconfigSecretRefs = append(existing.Spec.KubeconfigSecretRefs, v1alpha1.ClusterSecretKeyRef{ - LocalSecretKeyRef: v1alpha1.LocalSecretKeyRef{ - Name: secretName, - Key: "kubeconfig", + existing.Spec.Providers = append(existing.Spec.Providers, v1alpha1.Provider{ + Kubeconfig: v1alpha1.ClusterSecretKeyRef{ + LocalSecretKeyRef: v1alpha1.LocalSecretKeyRef{ + Name: secretName, + Key: "kubeconfig", + }, + Namespace: models.KonnectorNamespace, }, - Namespace: models.KonnectorNamespace, + RemoteNamespace: remoteNs, }) existing, err = bindClient.KubeBindV1alpha1().APIServiceBindings().Update(ctx, existing, metav1.UpdateOptions{}) @@ -110,13 +110,16 @@ func (b *BindAPIServiceOptions) createAPIServiceBindings(ctx context.Context, co Namespace: models.KonnectorNamespace, }, Spec: v1alpha1.APIServiceBindingSpec{ - KubeconfigSecretRefs: []v1alpha1.ClusterSecretKeyRef{ + Providers: []v1alpha1.Provider{ { - LocalSecretKeyRef: v1alpha1.LocalSecretKeyRef{ - Name: secretName, - Key: "kubeconfig", + Kubeconfig: v1alpha1.ClusterSecretKeyRef{ + LocalSecretKeyRef: v1alpha1.LocalSecretKeyRef{ + Name: secretName, + Key: "kubeconfig", + }, + Namespace: models.KonnectorNamespace, }, - Namespace: models.KonnectorNamespace, + RemoteNamespace: remoteNs, }, }, }, diff --git a/pkg/kubectl/bind/plugin/bind.go b/pkg/kubectl/bind/plugin/bind.go index 3c651814..f6c8f4cd 100644 --- a/pkg/kubectl/bind/plugin/bind.go +++ b/pkg/kubectl/bind/plugin/bind.go @@ -279,7 +279,7 @@ func (b *BindOptions) Run(ctx context.Context, urlCh chan<- string) error { "--remote-kubeconfig-name", secret.Name, // comment the remote namespace "--remote-namespace", remoteNamespace, - "--konnector-image", "superm4n/konnector:latest", + //"--konnector-image", "superm4n/konnector:v0.5.0_linux_amd64", "-f", "-", } b.flags.VisitAll(func(flag *pflag.Flag) { From f119981d1d6bb0800a9388a1adda5f792b068230 Mon Sep 17 00:00:00 2001 From: Tamal Saha Date: Wed, 6 Mar 2024 02:14:00 -0800 Subject: [PATCH 3/3] fmt Signed-off-by: Tamal Saha --- client/clientset/versioned/clientset.go | 1 + client/clientset/versioned/fake/clientset_generated.go | 1 + client/clientset/versioned/fake/register.go | 1 + client/clientset/versioned/scheme/register.go | 1 + .../versioned/typed/kubebind/v1alpha1/apiservicebinding.go | 1 + .../versioned/typed/kubebind/v1alpha1/apiserviceexport.go | 1 + .../typed/kubebind/v1alpha1/apiserviceexportrequest.go | 1 + .../versioned/typed/kubebind/v1alpha1/apiservicenamespace.go | 1 + .../versioned/typed/kubebind/v1alpha1/clusterbinding.go | 1 + .../typed/kubebind/v1alpha1/fake/fake_apiservicebinding.go | 1 + .../typed/kubebind/v1alpha1/fake/fake_apiserviceexport.go | 1 + .../kubebind/v1alpha1/fake/fake_apiserviceexportrequest.go | 1 + .../typed/kubebind/v1alpha1/fake/fake_apiservicenamespace.go | 1 + .../typed/kubebind/v1alpha1/fake/fake_clusterbinding.go | 1 + .../typed/kubebind/v1alpha1/fake/fake_kubebind_client.go | 1 + .../versioned/typed/kubebind/v1alpha1/kubebind_client.go | 1 + client/informers/externalversions/factory.go | 1 + client/informers/externalversions/generic.go | 1 + .../externalversions/internalinterfaces/factory_interfaces.go | 1 + .../externalversions/kubebind/v1alpha1/apiservicebinding.go | 1 + .../externalversions/kubebind/v1alpha1/apiserviceexport.go | 1 + .../kubebind/v1alpha1/apiserviceexportrequest.go | 1 + .../externalversions/kubebind/v1alpha1/apiservicenamespace.go | 1 + .../externalversions/kubebind/v1alpha1/clusterbinding.go | 1 + client/listers/kubebind/v1alpha1/apiservicebinding.go | 1 + client/listers/kubebind/v1alpha1/apiserviceexport.go | 1 + client/listers/kubebind/v1alpha1/apiserviceexportrequest.go | 1 + client/listers/kubebind/v1alpha1/apiservicenamespace.go | 1 + client/listers/kubebind/v1alpha1/clusterbinding.go | 1 + pkg/konnector/konnector_controller.go | 2 +- pkg/konnector/konnector_reconcile.go | 3 +-- 31 files changed, 31 insertions(+), 3 deletions(-) diff --git a/client/clientset/versioned/clientset.go b/client/clientset/versioned/clientset.go index 7644fcf6..42398b71 100644 --- a/client/clientset/versioned/clientset.go +++ b/client/clientset/versioned/clientset.go @@ -23,6 +23,7 @@ import ( "net/http" kubebindv1alpha1 "go.bytebuilders.dev/kube-bind/client/clientset/versioned/typed/kubebind/v1alpha1" + discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" diff --git a/client/clientset/versioned/fake/clientset_generated.go b/client/clientset/versioned/fake/clientset_generated.go index eb09f2aa..8f738510 100644 --- a/client/clientset/versioned/fake/clientset_generated.go +++ b/client/clientset/versioned/fake/clientset_generated.go @@ -22,6 +22,7 @@ import ( clientset "go.bytebuilders.dev/kube-bind/client/clientset/versioned" kubebindv1alpha1 "go.bytebuilders.dev/kube-bind/client/clientset/versioned/typed/kubebind/v1alpha1" fakekubebindv1alpha1 "go.bytebuilders.dev/kube-bind/client/clientset/versioned/typed/kubebind/v1alpha1/fake" + "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/discovery" diff --git a/client/clientset/versioned/fake/register.go b/client/clientset/versioned/fake/register.go index 79c40bc5..e55662ce 100644 --- a/client/clientset/versioned/fake/register.go +++ b/client/clientset/versioned/fake/register.go @@ -20,6 +20,7 @@ package fake import ( kubebindv1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/client/clientset/versioned/scheme/register.go b/client/clientset/versioned/scheme/register.go index 964b9476..241f9af3 100644 --- a/client/clientset/versioned/scheme/register.go +++ b/client/clientset/versioned/scheme/register.go @@ -20,6 +20,7 @@ package scheme import ( kubebindv1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/client/clientset/versioned/typed/kubebind/v1alpha1/apiservicebinding.go b/client/clientset/versioned/typed/kubebind/v1alpha1/apiservicebinding.go index 4fa13857..983b621e 100644 --- a/client/clientset/versioned/typed/kubebind/v1alpha1/apiservicebinding.go +++ b/client/clientset/versioned/typed/kubebind/v1alpha1/apiservicebinding.go @@ -24,6 +24,7 @@ import ( v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" scheme "go.bytebuilders.dev/kube-bind/client/clientset/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/client/clientset/versioned/typed/kubebind/v1alpha1/apiserviceexport.go b/client/clientset/versioned/typed/kubebind/v1alpha1/apiserviceexport.go index c00b89e4..97e87109 100644 --- a/client/clientset/versioned/typed/kubebind/v1alpha1/apiserviceexport.go +++ b/client/clientset/versioned/typed/kubebind/v1alpha1/apiserviceexport.go @@ -24,6 +24,7 @@ import ( v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" scheme "go.bytebuilders.dev/kube-bind/client/clientset/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/client/clientset/versioned/typed/kubebind/v1alpha1/apiserviceexportrequest.go b/client/clientset/versioned/typed/kubebind/v1alpha1/apiserviceexportrequest.go index b023b4a6..eaeda2f6 100644 --- a/client/clientset/versioned/typed/kubebind/v1alpha1/apiserviceexportrequest.go +++ b/client/clientset/versioned/typed/kubebind/v1alpha1/apiserviceexportrequest.go @@ -24,6 +24,7 @@ import ( v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" scheme "go.bytebuilders.dev/kube-bind/client/clientset/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/client/clientset/versioned/typed/kubebind/v1alpha1/apiservicenamespace.go b/client/clientset/versioned/typed/kubebind/v1alpha1/apiservicenamespace.go index 33d55df6..8e0a14cb 100644 --- a/client/clientset/versioned/typed/kubebind/v1alpha1/apiservicenamespace.go +++ b/client/clientset/versioned/typed/kubebind/v1alpha1/apiservicenamespace.go @@ -24,6 +24,7 @@ import ( v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" scheme "go.bytebuilders.dev/kube-bind/client/clientset/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/client/clientset/versioned/typed/kubebind/v1alpha1/clusterbinding.go b/client/clientset/versioned/typed/kubebind/v1alpha1/clusterbinding.go index ccef3f89..08a2d16b 100644 --- a/client/clientset/versioned/typed/kubebind/v1alpha1/clusterbinding.go +++ b/client/clientset/versioned/typed/kubebind/v1alpha1/clusterbinding.go @@ -24,6 +24,7 @@ import ( v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" scheme "go.bytebuilders.dev/kube-bind/client/clientset/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/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiservicebinding.go b/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiservicebinding.go index 31d20a50..8c194366 100644 --- a/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiservicebinding.go +++ b/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiservicebinding.go @@ -22,6 +22,7 @@ import ( "context" v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" types "k8s.io/apimachinery/pkg/types" diff --git a/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiserviceexport.go b/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiserviceexport.go index 3551b3b7..77bca648 100644 --- a/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiserviceexport.go +++ b/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiserviceexport.go @@ -22,6 +22,7 @@ import ( "context" v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" types "k8s.io/apimachinery/pkg/types" diff --git a/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiserviceexportrequest.go b/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiserviceexportrequest.go index d1e9d810..402d992a 100644 --- a/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiserviceexportrequest.go +++ b/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiserviceexportrequest.go @@ -22,6 +22,7 @@ import ( "context" v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" types "k8s.io/apimachinery/pkg/types" diff --git a/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiservicenamespace.go b/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiservicenamespace.go index 06bd485e..55f5a3e1 100644 --- a/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiservicenamespace.go +++ b/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_apiservicenamespace.go @@ -22,6 +22,7 @@ import ( "context" v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" types "k8s.io/apimachinery/pkg/types" diff --git a/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_clusterbinding.go b/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_clusterbinding.go index 0690153f..908644bf 100644 --- a/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_clusterbinding.go +++ b/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_clusterbinding.go @@ -22,6 +22,7 @@ import ( "context" v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" types "k8s.io/apimachinery/pkg/types" diff --git a/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_kubebind_client.go b/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_kubebind_client.go index 79754868..02aa9b5b 100644 --- a/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_kubebind_client.go +++ b/client/clientset/versioned/typed/kubebind/v1alpha1/fake/fake_kubebind_client.go @@ -20,6 +20,7 @@ package fake import ( v1alpha1 "go.bytebuilders.dev/kube-bind/client/clientset/versioned/typed/kubebind/v1alpha1" + rest "k8s.io/client-go/rest" testing "k8s.io/client-go/testing" ) diff --git a/client/clientset/versioned/typed/kubebind/v1alpha1/kubebind_client.go b/client/clientset/versioned/typed/kubebind/v1alpha1/kubebind_client.go index 30ff921e..da279d73 100644 --- a/client/clientset/versioned/typed/kubebind/v1alpha1/kubebind_client.go +++ b/client/clientset/versioned/typed/kubebind/v1alpha1/kubebind_client.go @@ -23,6 +23,7 @@ import ( v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" "go.bytebuilders.dev/kube-bind/client/clientset/versioned/scheme" + rest "k8s.io/client-go/rest" ) diff --git a/client/informers/externalversions/factory.go b/client/informers/externalversions/factory.go index 4079fd81..e2900ed4 100644 --- a/client/informers/externalversions/factory.go +++ b/client/informers/externalversions/factory.go @@ -26,6 +26,7 @@ import ( versioned "go.bytebuilders.dev/kube-bind/client/clientset/versioned" internalinterfaces "go.bytebuilders.dev/kube-bind/client/informers/externalversions/internalinterfaces" kubebind "go.bytebuilders.dev/kube-bind/client/informers/externalversions/kubebind" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/client/informers/externalversions/generic.go b/client/informers/externalversions/generic.go index 625df14a..9cd6b085 100644 --- a/client/informers/externalversions/generic.go +++ b/client/informers/externalversions/generic.go @@ -22,6 +22,7 @@ import ( "fmt" v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" + schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" ) diff --git a/client/informers/externalversions/internalinterfaces/factory_interfaces.go b/client/informers/externalversions/internalinterfaces/factory_interfaces.go index 34e94803..e2a8c919 100644 --- a/client/informers/externalversions/internalinterfaces/factory_interfaces.go +++ b/client/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -22,6 +22,7 @@ import ( time "time" versioned "go.bytebuilders.dev/kube-bind/client/clientset/versioned" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" cache "k8s.io/client-go/tools/cache" diff --git a/client/informers/externalversions/kubebind/v1alpha1/apiservicebinding.go b/client/informers/externalversions/kubebind/v1alpha1/apiservicebinding.go index 2076607e..e6aef4aa 100644 --- a/client/informers/externalversions/kubebind/v1alpha1/apiservicebinding.go +++ b/client/informers/externalversions/kubebind/v1alpha1/apiservicebinding.go @@ -26,6 +26,7 @@ import ( versioned "go.bytebuilders.dev/kube-bind/client/clientset/versioned" internalinterfaces "go.bytebuilders.dev/kube-bind/client/informers/externalversions/internalinterfaces" v1alpha1 "go.bytebuilders.dev/kube-bind/client/listers/kubebind/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" diff --git a/client/informers/externalversions/kubebind/v1alpha1/apiserviceexport.go b/client/informers/externalversions/kubebind/v1alpha1/apiserviceexport.go index caba1d0a..bffa7049 100644 --- a/client/informers/externalversions/kubebind/v1alpha1/apiserviceexport.go +++ b/client/informers/externalversions/kubebind/v1alpha1/apiserviceexport.go @@ -26,6 +26,7 @@ import ( versioned "go.bytebuilders.dev/kube-bind/client/clientset/versioned" internalinterfaces "go.bytebuilders.dev/kube-bind/client/informers/externalversions/internalinterfaces" v1alpha1 "go.bytebuilders.dev/kube-bind/client/listers/kubebind/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" diff --git a/client/informers/externalversions/kubebind/v1alpha1/apiserviceexportrequest.go b/client/informers/externalversions/kubebind/v1alpha1/apiserviceexportrequest.go index 56a01564..2bdc3066 100644 --- a/client/informers/externalversions/kubebind/v1alpha1/apiserviceexportrequest.go +++ b/client/informers/externalversions/kubebind/v1alpha1/apiserviceexportrequest.go @@ -26,6 +26,7 @@ import ( versioned "go.bytebuilders.dev/kube-bind/client/clientset/versioned" internalinterfaces "go.bytebuilders.dev/kube-bind/client/informers/externalversions/internalinterfaces" v1alpha1 "go.bytebuilders.dev/kube-bind/client/listers/kubebind/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" diff --git a/client/informers/externalversions/kubebind/v1alpha1/apiservicenamespace.go b/client/informers/externalversions/kubebind/v1alpha1/apiservicenamespace.go index eec4b358..10e85464 100644 --- a/client/informers/externalversions/kubebind/v1alpha1/apiservicenamespace.go +++ b/client/informers/externalversions/kubebind/v1alpha1/apiservicenamespace.go @@ -26,6 +26,7 @@ import ( versioned "go.bytebuilders.dev/kube-bind/client/clientset/versioned" internalinterfaces "go.bytebuilders.dev/kube-bind/client/informers/externalversions/internalinterfaces" v1alpha1 "go.bytebuilders.dev/kube-bind/client/listers/kubebind/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" diff --git a/client/informers/externalversions/kubebind/v1alpha1/clusterbinding.go b/client/informers/externalversions/kubebind/v1alpha1/clusterbinding.go index 03dfa010..3d860f5c 100644 --- a/client/informers/externalversions/kubebind/v1alpha1/clusterbinding.go +++ b/client/informers/externalversions/kubebind/v1alpha1/clusterbinding.go @@ -26,6 +26,7 @@ import ( versioned "go.bytebuilders.dev/kube-bind/client/clientset/versioned" internalinterfaces "go.bytebuilders.dev/kube-bind/client/informers/externalversions/internalinterfaces" v1alpha1 "go.bytebuilders.dev/kube-bind/client/listers/kubebind/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" diff --git a/client/listers/kubebind/v1alpha1/apiservicebinding.go b/client/listers/kubebind/v1alpha1/apiservicebinding.go index 0677abe4..e1a48125 100644 --- a/client/listers/kubebind/v1alpha1/apiservicebinding.go +++ b/client/listers/kubebind/v1alpha1/apiservicebinding.go @@ -20,6 +20,7 @@ package v1alpha1 import ( v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" diff --git a/client/listers/kubebind/v1alpha1/apiserviceexport.go b/client/listers/kubebind/v1alpha1/apiserviceexport.go index 33f03fce..18547a54 100644 --- a/client/listers/kubebind/v1alpha1/apiserviceexport.go +++ b/client/listers/kubebind/v1alpha1/apiserviceexport.go @@ -20,6 +20,7 @@ package v1alpha1 import ( v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" diff --git a/client/listers/kubebind/v1alpha1/apiserviceexportrequest.go b/client/listers/kubebind/v1alpha1/apiserviceexportrequest.go index 268dd085..df065c91 100644 --- a/client/listers/kubebind/v1alpha1/apiserviceexportrequest.go +++ b/client/listers/kubebind/v1alpha1/apiserviceexportrequest.go @@ -20,6 +20,7 @@ package v1alpha1 import ( v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" diff --git a/client/listers/kubebind/v1alpha1/apiservicenamespace.go b/client/listers/kubebind/v1alpha1/apiservicenamespace.go index 1f7ed16b..54e85592 100644 --- a/client/listers/kubebind/v1alpha1/apiservicenamespace.go +++ b/client/listers/kubebind/v1alpha1/apiservicenamespace.go @@ -20,6 +20,7 @@ package v1alpha1 import ( v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" diff --git a/client/listers/kubebind/v1alpha1/clusterbinding.go b/client/listers/kubebind/v1alpha1/clusterbinding.go index e09e14e9..40572766 100644 --- a/client/listers/kubebind/v1alpha1/clusterbinding.go +++ b/client/listers/kubebind/v1alpha1/clusterbinding.go @@ -20,6 +20,7 @@ package v1alpha1 import ( v1alpha1 "go.bytebuilders.dev/kube-bind/apis/kubebind/v1alpha1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" diff --git a/pkg/konnector/konnector_controller.go b/pkg/konnector/konnector_controller.go index ab8f6d36..da8cee4a 100644 --- a/pkg/konnector/konnector_controller.go +++ b/pkg/konnector/konnector_controller.go @@ -59,7 +59,7 @@ func New( namespaceInformer coreinformers.NamespaceInformer, crdInformer crdinformers.CustomResourceDefinitionInformer, ) (*Controller, error) { - //queue := workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), controllerName) + // queue := workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), controllerName) queue := workqueue.NewRateLimitingQueueWithConfig(workqueue.DefaultControllerRateLimiter(), workqueue.RateLimitingQueueConfig{ Name: controllerName, }) diff --git a/pkg/konnector/konnector_reconcile.go b/pkg/konnector/konnector_reconcile.go index bf3f01bf..f0198a6f 100644 --- a/pkg/konnector/konnector_reconcile.go +++ b/pkg/konnector/konnector_reconcile.go @@ -31,8 +31,7 @@ import ( "k8s.io/klog/v2" ) -//const namespaceKubeSystem = "kube-system" - +// const namespaceKubeSystem = "kube-system" type startable interface { Start(ctx context.Context) }