diff --git a/cmd/spiderpool-controller/cmd/crd_manager.go b/cmd/spiderpool-controller/cmd/crd_manager.go index c91676736c..b5e3363644 100644 --- a/cmd/spiderpool-controller/cmd/crd_manager.go +++ b/cmd/spiderpool-controller/cmd/crd_manager.go @@ -12,6 +12,7 @@ import ( multusv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1" calicov1 "github.com/tigera/operator/pkg/apis/crd.projectcalico.org/v1" + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" @@ -28,6 +29,7 @@ func init() { utilruntime.Must(spiderpoolv2beta1.AddToScheme(scheme)) utilruntime.Must(calicov1.AddToScheme(scheme)) utilruntime.Must(multusv1.AddToScheme(scheme)) + utilruntime.Must(apiextensionsv1.AddToScheme(scheme)) } func newCRDManager() (ctrl.Manager, error) { diff --git a/go.mod b/go.mod index b2fab98797..acfe36de9a 100644 --- a/go.mod +++ b/go.mod @@ -57,11 +57,12 @@ require ( github.com/prometheus/client_golang v1.15.1 github.com/spidernet-io/e2eframework v0.0.0-20230724150324-2eee77078275 github.com/spidernet-io/spiderdoctor v0.3.0 - github.com/tigera/operator v1.30.4 + github.com/tigera/operator v1.30.5 github.com/vishvananda/netlink v1.2.1-beta.2 go.uber.org/multierr v1.11.0 golang.org/x/sync v0.3.0 golang.org/x/sys v0.10.0 + k8s.io/apiextensions-apiserver v0.26.3 k8s.io/kubernetes v1.27.4 ) @@ -155,7 +156,6 @@ require ( google.golang.org/protobuf v1.30.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect - k8s.io/apiextensions-apiserver v0.26.3 // indirect k8s.io/component-base v0.26.3 // indirect k8s.io/gengo v0.0.0-20220902162205-c0856e24416d // indirect k8s.io/klog/v2 v2.90.1 // indirect diff --git a/go.sum b/go.sum index 61f8aca80e..495377c92c 100644 --- a/go.sum +++ b/go.sum @@ -542,8 +542,8 @@ github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tigera/api v0.0.0-20230406222214-ca74195900cb h1:Y7r5Al3V235KaEoAzGBz9RYXEbwDu8CPaZoCq2PlD8w= github.com/tigera/api v0.0.0-20230406222214-ca74195900cb/go.mod h1:ZZghiX3CUsBAc0osBjRvV6y/eun2ObYdvSbjqXAoj/w= -github.com/tigera/operator v1.30.4 h1:Ynbnf+DmqX2Fl6GsS5WG9pIHKFMtufSWv/N+3texq/I= -github.com/tigera/operator v1.30.4/go.mod h1:Lg570QCYYCcB9NkOQ2NWcOOyNsc4KDFttuxcJwuTq7k= +github.com/tigera/operator v1.30.5 h1:uKWVbr5wDt5PZjcpjKqYSq/KudIiqR73qOFv4LRqkvQ= +github.com/tigera/operator v1.30.5/go.mod h1:VB9YGUZymXwhZzgcoAa+B4IxV0D4eUPc0AKIV1l5RNU= github.com/toqueteos/webbrowser v1.2.0 h1:tVP/gpK69Fx+qMJKsLE7TD8LuGWPnEV71wBN9rrstGQ= github.com/toqueteos/webbrowser v1.2.0/go.mod h1:XWoZq4cyp9WeUeak7w7LXRUQf1F1ATJMir8RTqb4ayM= github.com/vishvananda/netlink v1.2.1-beta.2 h1:Llsql0lnQEbHj0I1OuKyp8otXp0r3q0mPkuhwHfStVs= diff --git a/pkg/coordinatormanager/coordinator_informer.go b/pkg/coordinatormanager/coordinator_informer.go index aee472a281..0ca42cda9a 100644 --- a/pkg/coordinatormanager/coordinator_informer.go +++ b/pkg/coordinatormanager/coordinator_informer.go @@ -16,8 +16,10 @@ import ( "go.uber.org/zap" corev1 "k8s.io/api/core/v1" + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/informers" coreinformers "k8s.io/client-go/informers/core/v1" @@ -49,8 +51,8 @@ const ( var SupportedPodCIDRType = []string{cluster, calico, cilium, none} const ( - calicoConfig = "calico-config" - ciliumConfig = "cilium-config" + calicoIPPoolCRDName = "ippools.crd.projectcalico.org" + ciliumConfig = "cilium-config" ) const ( @@ -356,8 +358,11 @@ func (cc *CoordinatorController) syncHandler(ctx context.Context, coordinatorNam } coordCopy.Status.Phase = Synced coordCopy.Status.OverlayPodCIDR = k8sPodCIDR + case calico: - if _, err := cc.ConfigmapLister.ConfigMaps(metav1.NamespaceSystem).Get(calicoConfig); err != nil { + var crd apiextensionsv1.CustomResourceDefinition + err := cc.APIReader.Get(ctx, types.NamespacedName{Name: calicoIPPoolCRDName}, &crd) + if nil != err { if apierrors.IsNotFound(err) { event.EventRecorder.Eventf( coordCopy, @@ -398,6 +403,7 @@ func (cc *CoordinatorController) syncHandler(ctx context.Context, coordinatorNam cc.caliCtrlCanncel = nil } }() + case cilium: if cc.caliCtrlCanncel != nil { cc.caliCtrlCanncel() @@ -442,6 +448,7 @@ func (cc *CoordinatorController) syncHandler(ctx context.Context, coordinatorNam if ipam == "kubernetes" { coordCopy.Status.OverlayPodCIDR = k8sPodCIDR } + case none: coordCopy.Status.Phase = Synced coordCopy.Status.OverlayPodCIDR = []string{} diff --git a/test/Makefile b/test/Makefile index c833529ef0..cfa63b2119 100644 --- a/test/Makefile +++ b/test/Makefile @@ -182,8 +182,14 @@ setup_spiderpool: else \ HELM_OPTION+=" --set coordinator.enabled=false " ; \ fi ; \ - if [ "$(INSTALL_OVERLAY_CNI)" == "true" ] && [ "$(INSTALL_CILIUM)" == "true" ] ; then \ + if [ "$(INSTALL_OVERLAY_CNI)" == "true" ]; then \ + if [ "$(INSTALL_CILIUM)" == "true" ] ; then \ HELM_OPTION+=" --set coordinator.podCIDRType=cilium " ; \ + elif [ "$(INSTALL_CALICO)" == "true" ]; then \ + HELM_OPTION+=" --set coordinator.podCIDRType=calico " ; \ + else \ + HELM_OPTION+=" --set coordinator.podCIDRType=cluster " ; \ + fi ; \ fi ; \ if [ "$(INSTALL_MULTUS)" == "true" ] ; then \ HELM_OPTION+=" --set multus.multusCNI.install=true " ; \ diff --git a/vendor/modules.txt b/vendor/modules.txt index 77835ce0d7..c4d1f633ff 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -453,7 +453,7 @@ github.com/subosito/gotenv # github.com/tigera/api v0.0.0-20230406222214-ca74195900cb ## explicit; go 1.18 github.com/tigera/api/pkg/lib/numorstring -# github.com/tigera/operator v1.30.4 +# github.com/tigera/operator v1.30.5 ## explicit; go 1.20 github.com/tigera/operator/pkg/apis/crd.projectcalico.org/v1 # github.com/toqueteos/webbrowser v1.2.0