From 417f33a8b895a0d023ca4b6aabfb8204ad9dc5da Mon Sep 17 00:00:00 2001 From: hanweisen Date: Fri, 11 Aug 2023 17:10:20 +0800 Subject: [PATCH] refactor controller-manager and fix some bugs Co-authored-by: wangyizhi Co-authored-by: baoyinghai Signed-off-by: hanweisen --- .golangci.yml | 4 +- Makefile | 1 + cmd/agent/app/agent.go | 23 +- cmd/agent/main.go | 2 +- .../app/clusterlink-proxy.go | 2 +- cmd/clusterlink-proxy/app/options/options.go | 2 +- cmd/clusterlink-proxy/main.go | 2 +- .../app/controller-manager.go | 88 ++++--- .../app/controllerstarter.go | 191 ++++++++++++++++ cmd/controller-manager/app/core.go | 63 +++--- cmd/controller-manager/app/options/options.go | 5 +- cmd/controller-manager/main.go | 2 +- cmd/elector/app/elector.go | 10 +- cmd/elector/app/options/options.go | 2 +- cmd/elector/main.go | 2 +- cmd/floater/app/floater.go | 6 +- cmd/floater/main.go | 2 +- cmd/linkctl/main.go | 2 +- cmd/network-manager/app/manager.go | 8 +- cmd/network-manager/app/options/options.go | 2 +- cmd/network-manager/main.go | 2 +- cmd/operator/app/operator.go | 14 +- cmd/operator/app/options/options.go | 2 + cmd/operator/main.go | 2 +- deploy/clusterlink-operator.yml | 7 +- deploy/clusterlink-proxy.yml | 57 +++++ generate/generate.go | 2 +- go.mod | 2 +- hack/cluster.sh | 5 +- hack/update-codegen.sh | 28 +-- hack/util.sh | 10 +- pkg/agent/controller.go | 35 ++- pkg/agent/network-manager/network_manager.go | 8 +- .../network-manager/network_manager_test.go | 4 +- pkg/apis/clusterlink/v1alpha1/proxy_types.go | 9 + .../v1alpha1/zz_generated.deepcopy.go | 25 ++ .../v1alpha1/zz_generated.register.go | 1 + pkg/clusterlinkctl/ctl.go | 8 +- .../floaterclient/cluster-helper.go | 2 +- .../floaterclient/command/curl.go | 2 +- pkg/clusterlinkctl/floaterclient/doctor.go | 8 +- pkg/clusterlinkctl/floaterclient/floater.go | 10 +- .../initmaster/ctlmaster/deploy_configmap.go | 2 +- .../ctlmaster/deploy_deployments.go | 6 +- .../initmaster/ctlmaster/deploy_rbac.go | 4 +- .../initmaster/ctlmaster/install.go | 6 +- .../initmaster/ctlmaster/manifests_crd.go | 2 +- pkg/clusterlinkctl/initmaster/initmaster.go | 6 +- pkg/clusterlinkctl/membercurd/options.go | 8 +- .../calicoippool/calicoippool_controller.go | 47 +++- .../calicoippool_controller_test.go | 2 +- pkg/controllers/calicoippool/manifests.go | 2 +- pkg/controllers/cluster/cluster_controller.go | 16 +- pkg/controllers/cluster/helper.go | 2 +- pkg/controllers/cluster/helper_test.go | 2 +- pkg/controllers/context/context.go | 29 ++- pkg/controllers/node/node_controller.go | 33 ++- pkg/controllers/nodecidr/adapter.go | 4 +- .../nodecidr/nodecidr_controller.go | 39 ++-- pkg/elector/elector.go | 11 +- pkg/elector/elector_test.go | 2 +- .../clientset/versioned/clientset.go | 2 +- .../versioned/fake/clientset_generated.go | 6 +- .../clientset/versioned/fake/register.go | 2 +- .../clientset/versioned/scheme/register.go | 2 +- .../typed/clusterlink/v1alpha1/cluster.go | 4 +- .../v1alpha1/clusterlink_client.go | 4 +- .../typed/clusterlink/v1alpha1/clusternode.go | 4 +- .../clusterlink/v1alpha1/fake/fake_cluster.go | 2 +- .../v1alpha1/fake/fake_clusterlink_client.go | 2 +- .../v1alpha1/fake/fake_clusternode.go | 2 +- .../v1alpha1/fake/fake_nodeconfig.go | 2 +- .../typed/clusterlink/v1alpha1/nodeconfig.go | 4 +- .../externalversions/clusterlink/interface.go | 4 +- .../clusterlink/v1alpha1/cluster.go | 8 +- .../clusterlink/v1alpha1/clusternode.go | 8 +- .../clusterlink/v1alpha1/interface.go | 2 +- .../clusterlink/v1alpha1/nodeconfig.go | 8 +- .../informers/externalversions/factory.go | 6 +- .../informers/externalversions/generic.go | 2 +- .../internalinterfaces/factory_interfaces.go | 2 +- .../listers/clusterlink/v1alpha1/cluster.go | 2 +- .../clusterlink/v1alpha1/clusternode.go | 2 +- .../clusterlink/v1alpha1/nodeconfig.go | 2 +- pkg/generated/openapi/zz_generated.openapi.go | 214 ++++++++++-------- pkg/network-manager/controller.go | 4 +- pkg/network-manager/handlers/context.go | 4 +- pkg/network-manager/handlers/host_network.go | 12 +- pkg/network-manager/handlers/nodeconfig.go | 4 +- pkg/network-manager/handlers/pod_routes.go | 6 +- pkg/network-manager/handlers/svc_routes.go | 6 +- .../handlers/vxbridge_mac_cache.go | 4 +- .../handlers/vxbridge_network.go | 10 +- .../handlers/vxlocal_mac_cache.go | 4 +- .../handlers/vxlocal_network.go | 10 +- pkg/network-manager/helpers/filter.go | 2 +- pkg/network-manager/helpers/network.go | 6 +- pkg/network-manager/helpers/sort.go | 2 +- pkg/network-manager/network_manager.go | 6 +- pkg/network/adapter.go | 2 +- pkg/network/arp.go | 2 +- pkg/network/arp_test.go | 2 +- pkg/network/constant.go | 3 + pkg/network/device.go | 50 ++-- pkg/network/device_test.go | 2 +- pkg/network/env.go | 2 +- pkg/network/fdb.go | 2 +- pkg/network/fdb_test.go | 2 +- pkg/network/interface.go | 2 +- pkg/network/iptables.go | 4 +- pkg/network/iptables_test.go | 2 +- pkg/network/route.go | 2 +- pkg/network/route_test.go | 2 +- pkg/operator/addons/agent/agent.go | 31 +-- pkg/operator/addons/agent/manifests.go | 5 +- pkg/operator/addons/elector/elector.go | 12 +- pkg/operator/addons/elector/manifests.go | 5 +- pkg/operator/addons/global/global.go | 6 +- pkg/operator/addons/install.go | 13 +- pkg/operator/addons/manager/manager.go | 42 +--- pkg/operator/addons/manager/manifests.go | 8 +- pkg/operator/addons/option/option.go | 7 +- pkg/operator/addons/proxy/manifests.go | 75 ++++++ pkg/operator/addons/proxy/proxy.go | 161 +++++++++++++ pkg/operator/operator_controller.go | 29 ++- pkg/proxy/apiserver.go | 4 +- pkg/proxy/storage.go | 14 +- pkg/proxy/store/cluster_cache.go | 33 +-- pkg/proxy/store/resource_cache.go | 5 +- pkg/scheme/scheme.go | 2 +- pkg/utils/constants.go | 13 ++ .../interface-policy/interface-policy.go | 4 +- pkg/utils/ipam/ippool_manager.go | 4 +- pkg/utils/ipam/ippool_test.go | 2 +- pkg/utils/role/role.go | 2 +- pkg/utils/worker.go | 2 +- test/e2e/elector_test.go | 4 +- test/e2e/framework/cluster.go | 6 +- test/e2e/suit_test.go | 4 +- 139 files changed, 1232 insertions(+), 601 deletions(-) create mode 100644 cmd/controller-manager/app/controllerstarter.go create mode 100644 deploy/clusterlink-proxy.yml create mode 100644 pkg/apis/clusterlink/v1alpha1/proxy_types.go create mode 100644 pkg/operator/addons/proxy/manifests.go create mode 100644 pkg/operator/addons/proxy/proxy.go diff --git a/.golangci.yml b/.golangci.yml index 90586d226..651d3f306 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -50,7 +50,7 @@ linters: linters-settings: goimports: - local-prefixes: cnp.io/clusterlink + local-prefixes: github.com/kosmos.io/clusterlink gocyclo: # minimal cyclomatic complexity to report min-complexity: 15 @@ -58,7 +58,7 @@ linters-settings: sections: - Standard - Default - - Prefix(cnp.io/clusterlink) + - Prefix(github.com/kosmos.io/clusterlink) issues: # The list of ids of default excludes to include or disable. By default it's empty. diff --git a/Makefile b/Makefile index 602af32ca..cc7db780f 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,7 @@ TARGETS := clusterlink-controller-manager \ clusterlink-elector \ clusterlink-floater \ clusterlink-network-manager \ + clusterlink-proxy \ CTL_TARGETS := linkctl diff --git a/cmd/agent/app/agent.go b/cmd/agent/app/agent.go index eddd36812..fe4ca03f3 100644 --- a/cmd/agent/app/agent.go +++ b/cmd/agent/app/agent.go @@ -13,14 +13,15 @@ import ( "k8s.io/klog/v2" ctrl "sigs.k8s.io/controller-runtime" - "cnp.io/clusterlink/cmd/agent/app/options" - "cnp.io/clusterlink/pkg/agent" - clusterlinkclientset "cnp.io/clusterlink/pkg/generated/clientset/versioned" - clusterlinkinformer "cnp.io/clusterlink/pkg/generated/informers/externalversions" - "cnp.io/clusterlink/pkg/network" - "cnp.io/clusterlink/pkg/scheme" - "cnp.io/clusterlink/pkg/sharedcli" - "cnp.io/clusterlink/pkg/sharedcli/klogflag" + "github.com/kosmos.io/clusterlink/cmd/agent/app/options" + "github.com/kosmos.io/clusterlink/pkg/agent" + clusterlinkclientset "github.com/kosmos.io/clusterlink/pkg/generated/clientset/versioned" + clusterlinkinformer "github.com/kosmos.io/clusterlink/pkg/generated/informers/externalversions" + "github.com/kosmos.io/clusterlink/pkg/network" + "github.com/kosmos.io/clusterlink/pkg/scheme" + "github.com/kosmos.io/clusterlink/pkg/sharedcli" + "github.com/kosmos.io/clusterlink/pkg/sharedcli/klogflag" + "github.com/kosmos.io/clusterlink/pkg/utils" ) // NewAgentCommand creates a *cobra.Command object with default parameters @@ -101,7 +102,7 @@ func run(ctx context.Context, opts *options.Options) error { HealthProbeBindAddress: "0", }) if err != nil { - klog.Errorf("failed to build controller manager: %v", err) + klog.Fatalf("failed to build controller manager123: %v", err) return err } @@ -117,8 +118,8 @@ func run(ctx context.Context, opts *options.Options) error { clusterNodeController := agent.Reconciler{ Scheme: mgr.GetScheme(), NodeConfigLister: nodeConfigLister, - NodeName: os.Getenv("NODE_NAME"), - ClusterName: os.Getenv("CLUSTER_NAME"), + NodeName: os.Getenv(utils.EnvNodeName), + ClusterName: os.Getenv(utils.EnvClusterName), NetworkManager: agent.NetworkManager(), DebounceFunc: Debounce(5), } diff --git a/cmd/agent/main.go b/cmd/agent/main.go index 4ecadf002..8d9ac384f 100644 --- a/cmd/agent/main.go +++ b/cmd/agent/main.go @@ -6,7 +6,7 @@ import ( apiserver "k8s.io/apiserver/pkg/server" "k8s.io/component-base/cli" - "cnp.io/clusterlink/cmd/agent/app" + "github.com/kosmos.io/clusterlink/cmd/agent/app" ) func main() { diff --git a/cmd/clusterlink-proxy/app/clusterlink-proxy.go b/cmd/clusterlink-proxy/app/clusterlink-proxy.go index 7379d5181..e203b1298 100644 --- a/cmd/clusterlink-proxy/app/clusterlink-proxy.go +++ b/cmd/clusterlink-proxy/app/clusterlink-proxy.go @@ -9,7 +9,7 @@ import ( cliflag "k8s.io/component-base/cli/flag" "k8s.io/component-base/term" - "cnp.io/clusterlink/cmd/clusterlink-proxy/app/options" + "github.com/kosmos.io/clusterlink/cmd/clusterlink-proxy/app/options" ) // NewClusterLinkProxyCommand creates a *cobra.Command object with default parameters diff --git a/cmd/clusterlink-proxy/app/options/options.go b/cmd/clusterlink-proxy/app/options/options.go index 31f39298c..e68b174d2 100644 --- a/cmd/clusterlink-proxy/app/options/options.go +++ b/cmd/clusterlink-proxy/app/options/options.go @@ -17,7 +17,7 @@ import ( "k8s.io/component-base/logs" logsapi "k8s.io/component-base/logs/api/v1" - "cnp.io/clusterlink/pkg/proxy" + "github.com/kosmos.io/clusterlink/pkg/proxy" ) // Options contains command line parameters for clusterlink-proxy diff --git a/cmd/clusterlink-proxy/main.go b/cmd/clusterlink-proxy/main.go index fa20be762..3141a3a84 100644 --- a/cmd/clusterlink-proxy/main.go +++ b/cmd/clusterlink-proxy/main.go @@ -6,7 +6,7 @@ import ( apiserver "k8s.io/apiserver/pkg/server" "k8s.io/component-base/cli" - "cnp.io/clusterlink/cmd/clusterlink-proxy/app" + "github.com/kosmos.io/clusterlink/cmd/clusterlink-proxy/app" ) func main() { diff --git a/cmd/controller-manager/app/controller-manager.go b/cmd/controller-manager/app/controller-manager.go index 102f2055c..c58fcdcf5 100644 --- a/cmd/controller-manager/app/controller-manager.go +++ b/cmd/controller-manager/app/controller-manager.go @@ -13,27 +13,27 @@ import ( "k8s.io/klog/v2" ctrl "sigs.k8s.io/controller-runtime" - "cnp.io/clusterlink/cmd/controller-manager/app/options" - ctrlcontext "cnp.io/clusterlink/pkg/controllers/context" - "cnp.io/clusterlink/pkg/controllers/nodecidr" - "cnp.io/clusterlink/pkg/generated/clientset/versioned" - "cnp.io/clusterlink/pkg/scheme" - "cnp.io/clusterlink/pkg/sharedcli/klogflag" + "github.com/kosmos.io/clusterlink/cmd/controller-manager/app/options" + ctrlcontext "github.com/kosmos.io/clusterlink/pkg/controllers/context" + "github.com/kosmos.io/clusterlink/pkg/generated/clientset/versioned" + "github.com/kosmos.io/clusterlink/pkg/scheme" + "github.com/kosmos.io/clusterlink/pkg/sharedcli/klogflag" ) var ( - controllers = make(ctrlcontext.Initializers) + Controllers = make(ctrlcontext.Initializers) - // controllersDisabledByDefault is the set of controllers which is disabled by default - controllersDisabledByDefault = sets.New[string]() + // ControllersDisabledByDefault is the set of Controllers which is disabled by default + ControllersDisabledByDefault = sets.New[string]() stopOnce sync.Once ) func init() { - controllers["cluster"] = startClusterController - controllers["node"] = startNodeController - controllers["calicoIPPool"] = startCalicoPoolController + Controllers["cluster"] = startClusterController + Controllers["node"] = startNodeController + Controllers["calicoIPPool"] = startCalicoPoolController + Controllers["nodecidr"] = startNodeCIDRController } // NewControllerManagerCommand creates a *cobra.Command object with default parameters @@ -59,7 +59,7 @@ func NewControllerManagerCommand(ctx context.Context) *cobra.Command { // and update the flag usage. genericFlagSet.AddGoFlagSet(flag.CommandLine) genericFlagSet.Lookup("kubeconfig").Usage = "Path to clusterlink control plane kubeconfig file." - opts.AddFlags(genericFlagSet, controllers.ControllerNames(), sets.List(controllersDisabledByDefault)) + opts.AddFlags(genericFlagSet, Controllers.ControllerNames(), sets.List(ControllersDisabledByDefault)) logsFlagSet := fss.FlagSet("logs") klogflag.Add(logsFlagSet) @@ -83,7 +83,6 @@ func Run(ctx context.Context, opts *options.ControllerManagerOptions) error { panic(err) } - // ToDo 创建Manager时配置好自定义资源Schema、选举配置、存活检查和指标监控 controllerManager, err := ctrl.NewManager(config, ctrl.Options{ Scheme: scheme.NewSchema(), }) @@ -92,63 +91,58 @@ func Run(ctx context.Context, opts *options.ControllerManagerOptions) error { return err } - setupControllers(controllerManager, opts, ctx.Done()) + //TODO 整理这块 + controlPanelConfig, err := clientcmd.BuildConfigFromFlags("", opts.ControlPanelConfig) + if err != nil { + klog.Fatalf("build controlpanel config err: %v", err) + panic(err) + } - if err := controllerManager.Start(ctx); err != nil { - klog.Errorf("controller manager exits unexpectedly: %v", err) + clusterLinkClient, err := versioned.NewForConfig(controlPanelConfig) + if err != nil { + klog.Fatalf("Unable to create clusterlinkClient: %v", err) + panic(err) + } + + controller := NewController(clusterLinkClient, controllerManager, opts) + err = controller.Start(ctx) + if err != nil { return err } return nil } -func setupControllers(mgr ctrl.Manager, opts *options.ControllerManagerOptions, stopChan <-chan struct{}) { +func setupControllers(mgr ctrl.Manager, opts *options.ControllerManagerOptions, ctx context.Context) []ctrlcontext.CleanFunc { controlPanelConfig, err := clientcmd.BuildConfigFromFlags("", opts.ControlPanelConfig) if err != nil { klog.Fatalf("build controlpanel config err: %v", err) panic(err) } + clusterLinkClient, err := versioned.NewForConfig(controlPanelConfig) + if err != nil { + klog.Fatalf("Unable to create clusterlinkClient: %v", err) + panic(err) + } + controllerContext := ctrlcontext.Context{ Mgr: mgr, Opts: ctrlcontext.Options{ Controllers: opts.Controllers, ControlPanelConfig: controlPanelConfig, ClusterName: opts.ClusterName, + RateLimiterOpts: opts.RateLimiterOpts, }, - StopChan: stopChan, - } - - if err := controllers.StartControllers(controllerContext, controllersDisabledByDefault); err != nil { - klog.Fatalf("error starting controllers: %v", err) - panic(err) + Ctx: ctx, + ClusterLinkClient: clusterLinkClient, } - config, err := clientcmd.BuildConfigFromFlags("", opts.ControlPanelConfig) - if err != nil { - klog.Fatalf("Unable to create controlPanelConfig: %v", err) - panic(err) - } - clusterLinkClient, err := versioned.NewForConfig(config) + cleanFuns, err := Controllers.StartControllers(controllerContext, ControllersDisabledByDefault) if err != nil { - klog.Fatalf("Unable to create clusterLinkClient: %v", err) - panic(err) - } - nodeCIDRCtl := nodecidr.NewNodeCIDRController(mgr.GetConfig(), opts.ClusterName, clusterLinkClient, opts.RateLimiterOpts, stopChan) - if err := mgr.Add(nodeCIDRCtl); err != nil { - klog.Fatalf("Failed to setup node CIDR Controller: %v", err) + klog.Fatalf("error starting Controllers: %v", err) panic(err) } - // Ensure the InformerManager stops when the stop channel closes - go func() { - <-stopChan - StopInstance() - }() -} - -func StopInstance() { - stopOnce.Do(func() { - close(make(chan struct{})) - }) + return cleanFuns } diff --git a/cmd/controller-manager/app/controllerstarter.go b/cmd/controller-manager/app/controllerstarter.go new file mode 100644 index 000000000..519df4010 --- /dev/null +++ b/cmd/controller-manager/app/controllerstarter.go @@ -0,0 +1,191 @@ +package app + +import ( + "context" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/errors" + "k8s.io/client-go/tools/cache" + "k8s.io/klog/v2" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" + + "github.com/kosmos.io/clusterlink/cmd/controller-manager/app/options" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + ctrlcontext "github.com/kosmos.io/clusterlink/pkg/controllers/context" + "github.com/kosmos.io/clusterlink/pkg/generated/clientset/versioned" + "github.com/kosmos.io/clusterlink/pkg/generated/informers/externalversions" + "github.com/kosmos.io/clusterlink/pkg/generated/listers/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/utils" + "github.com/kosmos.io/clusterlink/pkg/utils/keys" +) + +type Controller struct { + processor utils.AsyncWorker + clusterLinkClient versioned.Interface + clusterLister v1alpha1.ClusterLister + mgr ctrl.Manager + opts *options.ControllerManagerOptions + ctx context.Context + cleanFuncs []ctrlcontext.CleanFunc + cancelFunc context.CancelFunc + start bool +} + +func NewController(clusterLinkClient *versioned.Clientset, mgr ctrl.Manager, opts *options.ControllerManagerOptions) *Controller { + return &Controller{ + clusterLinkClient: clusterLinkClient, + mgr: mgr, + opts: opts, + } +} + +func (c *Controller) Start(ctx context.Context) error { + stopCh := ctx.Done() + c.ctx = ctx + opt := utils.Options{ + Name: "cluster Controller", + KeyFunc: func(obj interface{}) (utils.QueueKey, error) { + return keys.ClusterWideKeyFunc(obj) + }, + ReconcileFunc: c.Reconcile, + RateLimiterOptions: c.opts.RateLimiterOpts, + } + c.processor = utils.NewAsyncWorker(opt) + + clusterInformerFactory := externalversions.NewSharedInformerFactory(c.clusterLinkClient, 0) + clusterInformer := clusterInformerFactory.Clusterlink().V1alpha1().Clusters().Informer() + clusterInformer.AddEventHandler(cache.FilteringResourceEventHandler{ + Handler: cache.ResourceEventHandlerFuncs{ + AddFunc: c.OnAdd, + UpdateFunc: c.OnUpdate, + DeleteFunc: c.OnDelete, + }, + FilterFunc: func(obj interface{}) bool { + cluster, ok := obj.(*clusterlinkv1alpha1.Cluster) + if !ok { + return false + } + return cluster.Name == c.opts.ClusterName + }, + }) + c.clusterLister = clusterInformerFactory.Clusterlink().V1alpha1().Clusters().Lister() + + c.setupControllers() + + c.processor.Run(1, stopCh) + clusterInformerFactory.Start(stopCh) + clusterInformerFactory.WaitForCacheSync(stopCh) + <-stopCh + klog.Infof("Stop controller as process done.") + return nil +} + +// OnAdd handles object add event and push the object to queue. +func (c *Controller) OnAdd(obj interface{}) { + runtimeObj, ok := obj.(runtime.Object) + if !ok { + return + } + c.processor.Enqueue(runtimeObj) +} + +// OnUpdate handles object update event and push the object to queue. +func (c *Controller) OnUpdate(oldObj, newObj interface{}) { + runtimeObj, ok := newObj.(runtime.Object) + if !ok { + return + } + c.processor.Enqueue(runtimeObj) +} + +// OnDelete handles object delete event and push the object to queue. +func (c *Controller) OnDelete(obj interface{}) { + c.OnAdd(obj) +} + +func (c *Controller) Reconcile(key utils.QueueKey) error { + cluster, err := c.clusterLister.Get(c.opts.ClusterName) + if err != nil { + return err + } + if !cluster.DeletionTimestamp.IsZero() { + c.cancelFunc() + klog.Info("stop controllers") + var errs []error + klog.Info("clean resources") + for _, cf := range c.cleanFuncs { + err = cf() + if err != nil { + klog.Errorf("failed clean resource: %v", err) + errs = append(errs, err) + } + } + if len(errs) > 0 { + return errors.NewAggregate(errs) + } + err := c.removeFinalizer(cluster) + if err != nil { + return err + } + return nil + } + + //start controller + if !c.start { + c.startControllers() + c.start = true + err := c.ensureFinalizer(cluster) + if err != nil { + return err + } + } + + return nil +} + +func (c *Controller) ensureFinalizer(cluster *clusterlinkv1alpha1.Cluster) error { + if controllerutil.ContainsFinalizer(cluster, utils.ClusterStartControllerFinalizer) { + return nil + } + + controllerutil.AddFinalizer(cluster, utils.ClusterStartControllerFinalizer) + _, err := c.clusterLinkClient.ClusterlinkV1alpha1().Clusters().Update(context.TODO(), cluster, metav1.UpdateOptions{}) + if err != nil { + klog.Errorf("cluster %s failed add finalizer: %v", cluster.Name, err) + return err + } + + return nil +} + +func (c *Controller) removeFinalizer(cluster *clusterlinkv1alpha1.Cluster) error { + if !controllerutil.ContainsFinalizer(cluster, utils.ClusterStartControllerFinalizer) { + return nil + } + controllerutil.RemoveFinalizer(cluster, utils.ClusterStartControllerFinalizer) + _, err := c.clusterLinkClient.ClusterlinkV1alpha1().Clusters().Update(context.TODO(), cluster, metav1.UpdateOptions{}) + if err != nil { + klog.Errorf("cluster %s failed remove finalizer: %v", cluster.Name, err) + return err + } + return nil +} +func (c *Controller) setupControllers() { + subCtx, cancelFunc := context.WithCancel(c.ctx) + cleanFuns := setupControllers(c.mgr, c.opts, subCtx) + c.cancelFunc = cancelFunc + c.cleanFuncs = cleanFuns +} + +func (c *Controller) startControllers() { + + //mgr的start会block + go func() { + if err := c.mgr.Start(c.ctx); err != nil { + klog.Errorf("controller manager exits unexpectedly: %v", err) + panic(err) + } + }() +} diff --git a/cmd/controller-manager/app/core.go b/cmd/controller-manager/app/core.go index a56de5482..f8f7e3f06 100644 --- a/cmd/controller-manager/app/core.go +++ b/cmd/controller-manager/app/core.go @@ -5,81 +5,86 @@ import ( "k8s.io/client-go/kubernetes" "k8s.io/klog/v2" - "cnp.io/clusterlink/pkg/controllers/calicoippool" - "cnp.io/clusterlink/pkg/controllers/cluster" - ctrlcontext "cnp.io/clusterlink/pkg/controllers/context" - "cnp.io/clusterlink/pkg/controllers/node" - "cnp.io/clusterlink/pkg/generated/clientset/versioned" + "github.com/kosmos.io/clusterlink/pkg/controllers/calicoippool" + "github.com/kosmos.io/clusterlink/pkg/controllers/cluster" + ctrlcontext "github.com/kosmos.io/clusterlink/pkg/controllers/context" + "github.com/kosmos.io/clusterlink/pkg/controllers/node" + "github.com/kosmos.io/clusterlink/pkg/controllers/nodecidr" + "github.com/kosmos.io/clusterlink/pkg/generated/clientset/versioned" ) -func startClusterController(ctx ctrlcontext.Context) (enabled bool, err error) { +func startClusterController(ctx ctrlcontext.Context) (bool, ctrlcontext.CleanFunc, error) { mgr := ctx.Mgr restConfig := mgr.GetConfig() clientSet, err := kubernetes.NewForConfig(restConfig) if err != nil { klog.Errorf("Unable to create kubeClient: %v", err) - return false, err + return false, nil, err } dynamicClient, err := dynamic.NewForConfig(restConfig) if err != nil { klog.Errorf("Unable to create dynamicClient: %v", err) - return false, err + return false, nil, err } - clusterLinkClient, err := versioned.NewForConfig(ctx.Opts.ControlPanelConfig) - clusterController := cluster.NewController(ctx.Opts.ClusterName, clientSet, dynamicClient, clusterLinkClient) + clusterController := cluster.NewController(ctx.Opts.ClusterName, clientSet, dynamicClient, ctx.ClusterLinkClient) if err := mgr.Add(clusterController); err != nil { klog.Errorf("Failed to setup clustercontroller: %v", err) - return false, err + return false, nil, err } - return true, nil + return true, nil, nil } -func startNodeController(ctx ctrlcontext.Context) (enabled bool, err error) { +func startNodeController(ctx ctrlcontext.Context) (bool, ctrlcontext.CleanFunc, error) { mgr := ctx.Mgr - clusterLinkClient, err := versioned.NewForConfig(ctx.Opts.ControlPanelConfig) - if err != nil { - klog.Errorf("Unable to create clusterLink client: %v", err) - return false, err - } nodeController := &node.Reconciler{ Client: mgr.GetClient(), Scheme: mgr.GetScheme(), ClusterName: ctx.Opts.ClusterName, - ClusterLinkClient: clusterLinkClient, - //IPPoolManager: ipPoolMgr, + ClusterLinkClient: ctx.ClusterLinkClient, } - if err := nodeController.SetupWithManager(mgr, ctx.StopChan); err != nil { - return false, err + if err := nodeController.SetupWithManager(mgr, ctx.Ctx.Done()); err != nil { + return false, nil, err } - return true, nil + return true, nodeController.CleanResource, nil } -func startCalicoPoolController(ctx ctrlcontext.Context) (enabled bool, err error) { +func startCalicoPoolController(ctx ctrlcontext.Context) (bool, ctrlcontext.CleanFunc, error) { mgr := ctx.Mgr restConfig := mgr.GetConfig() kubeClient, err := kubernetes.NewForConfig(restConfig) if err != nil { klog.Errorf("Unable to create kubeClient: %v", err) - return false, err + return false, nil, err } dynamicClient, err := dynamic.NewForConfig(restConfig) if err != nil { klog.Errorf("Unable to create dynamicClient: %v", err) - return false, err + return false, nil, err } clusterLinkClient, err := versioned.NewForConfig(ctx.Opts.ControlPanelConfig) if err != nil { klog.Errorf("Unable to create clusterLinkClient: %v", err) - return false, err + return false, nil, err } controller := calicoippool.NewController(ctx.Opts.ClusterName, kubeClient, dynamicClient, clusterLinkClient) if err := mgr.Add(controller); err != nil { klog.Errorf("Failed to setup calicoippool controller: %v", err) - return false, err + return false, nil, err + } + return true, controller.CleanResource, nil +} + +func startNodeCIDRController(ctx ctrlcontext.Context) (bool, ctrlcontext.CleanFunc, error) { + mgr := ctx.Mgr + + nodeCIDRCtl := nodecidr.NewNodeCIDRController(mgr.GetConfig(), ctx.Opts.ClusterName, ctx.ClusterLinkClient, ctx.Opts.RateLimiterOpts, ctx.Ctx) + if err := mgr.Add(nodeCIDRCtl); err != nil { + klog.Fatalf("Failed to setup node CIDR Controller: %v", err) + return true, nil, nil } - return true, nil + return true, nil, nil } diff --git a/cmd/controller-manager/app/options/options.go b/cmd/controller-manager/app/options/options.go index 9c2ca07fe..3a58d8ed3 100644 --- a/cmd/controller-manager/app/options/options.go +++ b/cmd/controller-manager/app/options/options.go @@ -8,7 +8,8 @@ import ( "github.com/spf13/pflag" "k8s.io/apimachinery/pkg/util/validation/field" - "cnp.io/clusterlink/pkg/utils/flags" + "github.com/kosmos.io/clusterlink/pkg/utils" + "github.com/kosmos.io/clusterlink/pkg/utils/flags" ) type ControllerManagerOptions struct { @@ -39,6 +40,6 @@ func (o *ControllerManagerOptions) AddFlags(fs *pflag.FlagSet, allControllers, d "A list of controllers to enable. '*' enables all on-by-default controllers, 'foo' enables the controller named 'foo', '-foo' disables the controller named 'foo'. \nAll controllers: %s.\nDisabled-by-default controllers: %s", strings.Join(allControllers, ", "), strings.Join(disabledByDefaultControllers, ", "), )) - fs.StringVar(&o.ClusterName, "cluster", os.Getenv("CLUSTER_NAME"), "current cluster name.") + fs.StringVar(&o.ClusterName, "cluster", os.Getenv(utils.EnvClusterName), "current cluster name.") fs.StringVar(&o.ControlPanelConfig, "controlpanelconfig", "", "path to controlpanel kubeconfig file.") } diff --git a/cmd/controller-manager/main.go b/cmd/controller-manager/main.go index 41dee074a..98ccebc57 100644 --- a/cmd/controller-manager/main.go +++ b/cmd/controller-manager/main.go @@ -6,7 +6,7 @@ import ( "k8s.io/component-base/cli" ctrl "sigs.k8s.io/controller-runtime" - "cnp.io/clusterlink/cmd/controller-manager/app" + "github.com/kosmos.io/clusterlink/cmd/controller-manager/app" ) func main() { diff --git a/cmd/elector/app/elector.go b/cmd/elector/app/elector.go index b5f65da4d..baf6282e8 100644 --- a/cmd/elector/app/elector.go +++ b/cmd/elector/app/elector.go @@ -17,11 +17,11 @@ import ( "k8s.io/component-base/term" "k8s.io/klog/v2" - "cnp.io/clusterlink/cmd/elector/app/options" - "cnp.io/clusterlink/pkg/elector" - "cnp.io/clusterlink/pkg/generated/clientset/versioned" - "cnp.io/clusterlink/pkg/sharedcli" - "cnp.io/clusterlink/pkg/sharedcli/klogflag" + "github.com/kosmos.io/clusterlink/cmd/elector/app/options" + "github.com/kosmos.io/clusterlink/pkg/elector" + "github.com/kosmos.io/clusterlink/pkg/generated/clientset/versioned" + "github.com/kosmos.io/clusterlink/pkg/sharedcli" + "github.com/kosmos.io/clusterlink/pkg/sharedcli/klogflag" ) // NewElectorCommand creates a *cobra.Command object with default parameters diff --git a/cmd/elector/app/options/options.go b/cmd/elector/app/options/options.go index 9b11a8003..4d6d7429a 100644 --- a/cmd/elector/app/options/options.go +++ b/cmd/elector/app/options/options.go @@ -9,7 +9,7 @@ import ( "k8s.io/client-go/tools/leaderelection/resourcelock" componentbaseconfig "k8s.io/component-base/config" - "cnp.io/clusterlink/pkg/utils" + "github.com/kosmos.io/clusterlink/pkg/utils" ) var ( diff --git a/cmd/elector/main.go b/cmd/elector/main.go index d27033841..fe4972406 100644 --- a/cmd/elector/main.go +++ b/cmd/elector/main.go @@ -6,7 +6,7 @@ import ( "k8s.io/component-base/cli" ctrl "sigs.k8s.io/controller-runtime" - "cnp.io/clusterlink/cmd/elector/app" + "github.com/kosmos.io/clusterlink/cmd/elector/app" ) func main() { diff --git a/cmd/floater/app/floater.go b/cmd/floater/app/floater.go index ae74aed18..222354fe9 100644 --- a/cmd/floater/app/floater.go +++ b/cmd/floater/app/floater.go @@ -11,9 +11,9 @@ import ( "k8s.io/component-base/term" "k8s.io/klog/v2" - "cnp.io/clusterlink/cmd/floater/app/options" - "cnp.io/clusterlink/pkg/sharedcli" - "cnp.io/clusterlink/pkg/sharedcli/klogflag" + "github.com/kosmos.io/clusterlink/cmd/floater/app/options" + "github.com/kosmos.io/clusterlink/pkg/sharedcli" + "github.com/kosmos.io/clusterlink/pkg/sharedcli/klogflag" ) func NewFloaterCommand(ctx context.Context) *cobra.Command { diff --git a/cmd/floater/main.go b/cmd/floater/main.go index 9bb4a4af6..63b02bfb3 100644 --- a/cmd/floater/main.go +++ b/cmd/floater/main.go @@ -6,7 +6,7 @@ import ( apiserver "k8s.io/apiserver/pkg/server" "k8s.io/component-base/cli" - "cnp.io/clusterlink/cmd/floater/app" + "github.com/kosmos.io/clusterlink/cmd/floater/app" ) func main() { diff --git a/cmd/linkctl/main.go b/cmd/linkctl/main.go index 6cc020a59..73c658083 100644 --- a/cmd/linkctl/main.go +++ b/cmd/linkctl/main.go @@ -4,7 +4,7 @@ import ( "k8s.io/component-base/cli" "k8s.io/kubectl/pkg/cmd/util" - app "cnp.io/clusterlink/pkg/clusterlinkctl" + app "github.com/kosmos.io/clusterlink/pkg/clusterlinkctl" ) func main() { diff --git a/cmd/network-manager/app/manager.go b/cmd/network-manager/app/manager.go index 988eaa497..b760f6f20 100644 --- a/cmd/network-manager/app/manager.go +++ b/cmd/network-manager/app/manager.go @@ -10,10 +10,10 @@ import ( "k8s.io/klog/v2" controllerruntime "sigs.k8s.io/controller-runtime" - "cnp.io/clusterlink/cmd/network-manager/app/options" - "cnp.io/clusterlink/pkg/network-manager" - "cnp.io/clusterlink/pkg/scheme" - "cnp.io/clusterlink/pkg/sharedcli/klogflag" + "github.com/kosmos.io/clusterlink/cmd/network-manager/app/options" + "github.com/kosmos.io/clusterlink/pkg/network-manager" + "github.com/kosmos.io/clusterlink/pkg/scheme" + "github.com/kosmos.io/clusterlink/pkg/sharedcli/klogflag" ) func NewAgentCommand(ctx context.Context) *cobra.Command { diff --git a/cmd/network-manager/app/options/options.go b/cmd/network-manager/app/options/options.go index 7c5a45f21..3300493b2 100644 --- a/cmd/network-manager/app/options/options.go +++ b/cmd/network-manager/app/options/options.go @@ -5,7 +5,7 @@ import ( "k8s.io/client-go/tools/leaderelection/resourcelock" componentbaseconfig "k8s.io/component-base/config" - "cnp.io/clusterlink/pkg/utils" + "github.com/kosmos.io/clusterlink/pkg/utils" ) type Options struct { diff --git a/cmd/network-manager/main.go b/cmd/network-manager/main.go index 29f39a2e5..8991c3611 100644 --- a/cmd/network-manager/main.go +++ b/cmd/network-manager/main.go @@ -6,7 +6,7 @@ import ( apiserver "k8s.io/apiserver/pkg/server" "k8s.io/component-base/cli" - "cnp.io/clusterlink/cmd/network-manager/app" + "github.com/kosmos.io/clusterlink/cmd/network-manager/app" ) func main() { diff --git a/cmd/operator/app/operator.go b/cmd/operator/app/operator.go index 6e782befb..a441837a3 100644 --- a/cmd/operator/app/operator.go +++ b/cmd/operator/app/operator.go @@ -16,12 +16,12 @@ import ( "k8s.io/klog/v2" ctrl "sigs.k8s.io/controller-runtime" - "cnp.io/clusterlink/cmd/operator/app/options" - "cnp.io/clusterlink/pkg/operator" - "cnp.io/clusterlink/pkg/scheme" - "cnp.io/clusterlink/pkg/sharedcli" - "cnp.io/clusterlink/pkg/sharedcli/klogflag" - "cnp.io/clusterlink/pkg/utils" + "github.com/kosmos.io/clusterlink/cmd/operator/app/options" + "github.com/kosmos.io/clusterlink/pkg/operator" + "github.com/kosmos.io/clusterlink/pkg/scheme" + "github.com/kosmos.io/clusterlink/pkg/sharedcli" + "github.com/kosmos.io/clusterlink/pkg/sharedcli/klogflag" + "github.com/kosmos.io/clusterlink/pkg/utils" ) // NewOperatorCommand creates a *cobra.Command object with default parameters @@ -119,7 +119,7 @@ func run(ctx context.Context, opts *options.Options) error { clusterNodeController := operator.Reconciler{ Scheme: mgr.GetScheme(), ControlPanelKubeConfig: controlPanelKubeConfig, - ClusterName: os.Getenv("CLUSTER_NAME"), + ClusterName: os.Getenv(utils.EnvClusterName), Options: opts, } diff --git a/cmd/operator/app/options/options.go b/cmd/operator/app/options/options.go index 00de3c795..ae352643e 100644 --- a/cmd/operator/app/options/options.go +++ b/cmd/operator/app/options/options.go @@ -8,6 +8,7 @@ type Options struct { KubeConfig string ControlPanelKubeConfig string ExternalKubeConfigName string + UseProxy bool } // NewOptions builds a default agent options. @@ -25,4 +26,5 @@ func (o *Options) AddFlags(fs *pflag.FlagSet) { fs.StringVar(&o.KubeConfig, "kubeconfig", "", "Path to control plane kubeconfig file.") fs.StringVar(&o.ControlPanelKubeConfig, "controlpanelconfig", "", "Path to host control plane kubeconfig file.") fs.StringVar(&o.ExternalKubeConfigName, "ExternalKubeConfigName", "external-kubeconfig", "external kube config name.") + fs.BoolVar(&o.UseProxy, "UseProxy", false, "external kube config name.") } diff --git a/cmd/operator/main.go b/cmd/operator/main.go index 479c302d9..df85ffaf6 100644 --- a/cmd/operator/main.go +++ b/cmd/operator/main.go @@ -6,7 +6,7 @@ import ( apiserver "k8s.io/apiserver/pkg/server" "k8s.io/component-base/cli" - "cnp.io/clusterlink/cmd/operator/app" + "github.com/kosmos.io/clusterlink/cmd/operator/app" ) func main() { diff --git a/deploy/clusterlink-operator.yml b/deploy/clusterlink-operator.yml index 4bd565b41..c9356c988 100644 --- a/deploy/clusterlink-operator.yml +++ b/deploy/clusterlink-operator.yml @@ -41,12 +41,13 @@ spec: value: __VERSION__ - name: CLUSTER_NAME value: __CLUSTER_NAME__ + - name: USE_PROXY + value: "true" volumeMounts: - mountPath: /etc/clusterlink name: proxy-config readOnly: true volumes: - name: proxy-config - configMap: - defaultMode: 420 - name: clusterlink-proxy + secret: + secretName: controlpanel-config diff --git a/deploy/clusterlink-proxy.yml b/deploy/clusterlink-proxy.yml new file mode 100644 index 000000000..f4039a1d7 --- /dev/null +++ b/deploy/clusterlink-proxy.yml @@ -0,0 +1,57 @@ +apiVersion: v1 +kind: Service +metadata: + name: clusterlink-proxy-service + namespace: clusterlink-system +spec: + selector: + app: clusterlink-proxy + ports: + - protocol: TCP + port: 443 + targetPort: 443 + nodePort: 32443 + type: ClusterIP +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: clusterlink-proxy + namespace: clusterlink-system + labels: + app: clusterlink-proxy +spec: + replicas: 1 + selector: + matchLabels: + app: clusterlink-proxy + template: + metadata: + labels: + app: clusterlink-proxy + spec: + volumes: + - name: proxy-config + configMap: + defaultMode: 420 + name: clusterlink-agent-proxy + containers: + - name: manager + image: nexus.cmss.com:8086/cnp/clusterlink/clusterlink-proxy:__VERSION__ + imagePullPolicy: IfNotPresent + command: + - clusterlink-proxy + - --kubeconfig=/etc/clusterlink/kubeconfig + - --authentication-kubeconfig=/etc/clusterlink/kubeconfig + - --authorization-kubeconfig=/etc/clusterlink/kubeconfig + resources: + limits: + memory: 500Mi + cpu: 500m + requests: + cpu: 500m + memory: 500Mi + volumeMounts: + - mountPath: /etc/clusterlink + name: proxy-config + readOnly: true diff --git a/generate/generate.go b/generate/generate.go index cc67b3ada..90de96b40 100644 --- a/generate/generate.go +++ b/generate/generate.go @@ -9,7 +9,7 @@ import ( "go/token" "os" - "cnp.io/clusterlink/projectpath" + "github.com/kosmos.io/clusterlink/projectpath" ) func main() { diff --git a/go.mod b/go.mod index 913288530..bebb35245 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module cnp.io/clusterlink +module github.com/kosmos.io/clusterlink go 1.19 diff --git a/hack/cluster.sh b/hack/cluster.sh index b7fc32750..81679231a 100755 --- a/hack/cluster.sh +++ b/hack/cluster.sh @@ -114,8 +114,8 @@ spec: networkType: "gateway" EOF kubectl --context="kind-${member_cluster}" apply -f "$ROOT"/deploy/clusterlink-namespace.yml - kubectl --context="kind-${member_cluster}" -n clusterlink-system delete configmap clusterlink-proxy || true - kubectl --context="kind-${member_cluster}" -n clusterlink-system create configmap clusterlink-proxy --from-file=kubeconfig="${ROOT}/environments/${host_cluster}/kubeconfig" + kubectl --context="kind-${member_cluster}" -n clusterlink-system delete secret controlpanel-config || true + kubectl --context="kind-${member_cluster}" -n clusterlink-system create secret generic controlpanel-config --from-file=kubeconfig="${ROOT}/environments/${host_cluster}/kubeconfig" kubectl --context="kind-${member_cluster}" apply -f "$ROOT"/deploy/clusterlink-datapanel-rbac.yml sed -e "s|__VERSION__|$VERSION|g" -e "s|__CLUSTER_NAME__|$member_cluster|g" -e "w ${ROOT}/environments/${member_cluster}/clusterlink-operator.yml" "$ROOT"/deploy/clusterlink-operator.yml kubectl --context="kind-${member_cluster}" apply -f "${ROOT}/environments/${member_cluster}/clusterlink-operator.yml" @@ -144,6 +144,7 @@ function load_clusterlink_images() { kind load docker-image -n "$clustername" nexus.cmss.com:8086/cnp/clusterlink/clusterlink-elector:"${VERSION}" kind load docker-image -n "$clustername" nexus.cmss.com:8086/cnp/clusterlink/clusterlink-operator:"${VERSION}" kind load docker-image -n "$clustername" nexus.cmss.com:8086/cnp/clusterlink/clusterlink-agent:"${VERSION}" + kind load docker-image -n "$clustername" nexus.cmss.com:8086/cnp/clusterlink/clusterlink-proxy:"${VERSION}" } function delete_cluster() { diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index cf124dc63..8f235e0b9 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -40,7 +40,7 @@ create_gopath_tree "${REPO_ROOT}" "${link_path}" deepcopy-gen \ --go-header-file hack/boilerplate/boilerplate.go.txt \ - --input-dirs=cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1 \ + --input-dirs=github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1 \ --output-base="${REPO_ROOT}" \ --output-package=pkg/apis/clusterlink/v1alpha1 \ --output-file-base=zz_generated.deepcopy @@ -49,7 +49,7 @@ echo "Generating with register-gen" GO111MODULE=on go install k8s.io/code-generator/cmd/register-gen register-gen \ --go-header-file hack/boilerplate/boilerplate.go.txt \ - --input-dirs=cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1 \ + --input-dirs=github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1 \ --output-base="${REPO_ROOT}" \ --output-package=pkg/apis/clusterlink/v1alpha1 \ --output-file-base=zz_generated.register @@ -58,9 +58,9 @@ echo "Generating with conversion-gen" GO111MODULE=on go install k8s.io/code-generator/cmd/conversion-gen conversion-gen \ --go-header-file hack/boilerplate/boilerplate.go.txt \ - --input-dirs=cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1 \ + --input-dirs=github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1 \ --output-base="${REPO_ROOT}" \ - --output-package=cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1 \ + --output-package=github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1 \ --output-file-base=zz_generated.conversion echo "Generating with client-gen" @@ -68,35 +68,35 @@ GO111MODULE=on go install k8s.io/code-generator/cmd/client-gen client-gen \ --go-header-file hack/boilerplate/boilerplate.go.txt \ --input-base="" \ - --input=cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1 \ + --input=github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1 \ --output-base="${REPO_ROOT}" \ - --output-package=cnp.io/clusterlink/pkg/generated/clientset \ + --output-package=github.com/kosmos.io/clusterlink/pkg/generated/clientset \ --clientset-name=versioned echo "Generating with lister-gen" GO111MODULE=on go install k8s.io/code-generator/cmd/lister-gen lister-gen \ --go-header-file hack/boilerplate/boilerplate.go.txt \ - --input-dirs=cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1 \ + --input-dirs=github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1 \ --output-base="${REPO_ROOT}" \ - --output-package=cnp.io/clusterlink/pkg/generated/listers + --output-package=github.com/kosmos.io/clusterlink/pkg/generated/listers echo "Generating with informer-gen" GO111MODULE=on go install k8s.io/code-generator/cmd/informer-gen informer-gen \ --go-header-file hack/boilerplate/boilerplate.go.txt \ - --input-dirs=cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1 \ - --versioned-clientset-package=cnp.io/clusterlink/pkg/generated/clientset/versioned \ - --listers-package=cnp.io/clusterlink/pkg/generated/listers \ + --input-dirs=github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1 \ + --versioned-clientset-package=github.com/kosmos.io/clusterlink/pkg/generated/clientset/versioned \ + --listers-package=github.com/kosmos.io/clusterlink/pkg/generated/listers \ --output-base="${REPO_ROOT}" \ - --output-package=cnp.io/clusterlink/pkg/generated/informers + --output-package=github.com/kosmos.io/clusterlink/pkg/generated/informers echo "Generating with openapi-gen" GO111MODULE=on go install k8s.io/code-generator/cmd/openapi-gen openapi-gen \ --go-header-file hack/boilerplate/boilerplate.go.txt \ - --input-dirs "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" \ + --input-dirs "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" \ --input-dirs "k8s.io/apimachinery/pkg/apis/meta/v1,k8s.io/apimachinery/pkg/runtime,k8s.io/apimachinery/pkg/version" \ --output-base="${REPO_ROOT}" \ - --output-package "cnp.io/clusterlink/pkg/generated/openapi" \ + --output-package "github.com/kosmos.io/clusterlink/pkg/generated/openapi" \ -O zz_generated.openapi diff --git a/hack/util.sh b/hack/util.sh index 0d8c18f87..6eae2e0d6 100755 --- a/hack/util.sh +++ b/hack/util.sh @@ -6,7 +6,7 @@ set -o pipefail # This script holds common bash variables and utility functions. -CLUSTERLINK_GO_PACKAGE="cnp.io/clusterlink" +CLUSTERLINK_GO_PACKAGE="github.com/kosmos.io/clusterlink" @@ -450,10 +450,10 @@ function util::version_ldflags() { fi BUILDDATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') # TODO 弄明白这个地方是干嘛的,然后进行修改 - LDFLAGS="-X cnp.io/clusterlink/pkg/version.gitVersion=${GIT_VERSION} \ - -X cnp.io/clusterlink/pkg/version.gitCommit=${GIT_COMMIT_HASH} \ - -X cnp.io/clusterlink/pkg/version.gitTreeState=${GIT_TREESTATE} \ - -X cnp.io/clusterlink/pkg/version.buildDate=${BUILDDATE}" + LDFLAGS="-X github.com/kosmos.io/clusterlink/pkg/version.gitVersion=${GIT_VERSION} \ + -X github.com/kosmos.io/clusterlink/pkg/version.gitCommit=${GIT_COMMIT_HASH} \ + -X github.com/kosmos.io/clusterlink/pkg/version.gitTreeState=${GIT_TREESTATE} \ + -X github.com/kosmos.io/clusterlink/pkg/version.buildDate=${BUILDDATE}" echo $LDFLAGS } diff --git a/pkg/agent/controller.go b/pkg/agent/controller.go index 911ddec33..20e4fd934 100644 --- a/pkg/agent/controller.go +++ b/pkg/agent/controller.go @@ -2,6 +2,7 @@ package agent import ( "context" + "fmt" "time" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -16,10 +17,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/reconcile" - networkmanager "cnp.io/clusterlink/pkg/agent/network-manager" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - clusterlinkv1alpha1lister "cnp.io/clusterlink/pkg/generated/listers/clusterlink/v1alpha1" - "cnp.io/clusterlink/pkg/network" + networkmanager "github.com/kosmos.io/clusterlink/pkg/agent/network-manager" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + clusterlinkv1alpha1lister "github.com/kosmos.io/clusterlink/pkg/generated/listers/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/network" ) const ( @@ -69,6 +70,16 @@ func (r *Reconciler) SetupWithManager(mgr manager.Manager) error { Complete(r) } +func (r *Reconciler) logResult(nodeConfigSyncStatus networkmanager.NodeConfigSyncStatus) { + if nodeConfigSyncStatus == networkmanager.NodeConfigSyncException { + klog.Warning("sync from crd failed!") + klog.Warning(r.NetworkManager.GetReason()) + } + if nodeConfigSyncStatus == networkmanager.NodeConfigSyncSuccess { + klog.Info("sync from crd successed!") + } +} + func (r *Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error) { klog.Infof("============ agent starts to reconcile %s ============", request.NamespacedName) @@ -84,18 +95,16 @@ func (r *Reconciler) Reconcile(ctx context.Context, request reconcile.Request) ( return reconcile.Result{RequeueAfter: RequeueTime}, nil } - if reconcileNode.Name != r.NodeName { + klog.Infof("reconcile node name: %s, current node name: %s-%s", reconcileNode.Name, r.ClusterName, r.NodeName) + if reconcileNode.Name != fmt.Sprintf("%s-%s", r.ClusterName, r.NodeName) { + klog.Infof("not match, drop this event.") return reconcile.Result{}, nil } r.DebounceFunc(func() { nodeConfigSyncStatus := r.NetworkManager.UpdateFromCRD(&reconcileNode) - if nodeConfigSyncStatus == networkmanager.NodeConfigSyncException { - klog.Warning("sync from crd failed!") - } - if nodeConfigSyncStatus == networkmanager.NodeConfigSyncSuccess { - klog.Info("sync from crd successed!") - } + r.logResult(nodeConfigSyncStatus) + }) return reconcile.Result{}, nil @@ -107,7 +116,9 @@ func (r *Reconciler) StartTimer(ctx context.Context) { for { select { case <-timer.C: - r.NetworkManager.UpdateFromChecker() + klog.Info("###################### start check ######################") + nodeConfigSyncStatus := r.NetworkManager.UpdateFromChecker() + r.logResult(nodeConfigSyncStatus) timer.Reset(RequeueTime) case <-ctx.Done(): klog.Infoln("kill the timer") diff --git a/pkg/agent/network-manager/network_manager.go b/pkg/agent/network-manager/network_manager.go index 0b6332ce7..9b993cfc4 100644 --- a/pkg/agent/network-manager/network_manager.go +++ b/pkg/agent/network-manager/network_manager.go @@ -4,8 +4,8 @@ import ( "fmt" "sync" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - "cnp.io/clusterlink/pkg/network" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/network" "github.com/pkg/errors" "k8s.io/klog/v2" ) @@ -239,6 +239,10 @@ func (e *NetworkManager) UpdateFromCRD(nodeConfig *clusterlinkv1alpha1.NodeConfi return e.UpdateSync() } +func (e *NetworkManager) GetReason() string { + return e.Reason +} + func (e *NetworkManager) UpdateFromChecker() NodeConfigSyncStatus { lock.Lock() defer lock.Unlock() diff --git a/pkg/agent/network-manager/network_manager_test.go b/pkg/agent/network-manager/network_manager_test.go index b08a4925e..27c70810a 100644 --- a/pkg/agent/network-manager/network_manager_test.go +++ b/pkg/agent/network-manager/network_manager_test.go @@ -3,8 +3,8 @@ package networkmanager import ( "testing" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - "cnp.io/clusterlink/pkg/network" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/network" ) func TestNetworkManager(t *testing.T) { diff --git a/pkg/apis/clusterlink/v1alpha1/proxy_types.go b/pkg/apis/clusterlink/v1alpha1/proxy_types.go new file mode 100644 index 000000000..ff95d4f01 --- /dev/null +++ b/pkg/apis/clusterlink/v1alpha1/proxy_types.go @@ -0,0 +1,9 @@ +package v1alpha1 + +import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type Proxy struct { + metav1.TypeMeta +} diff --git a/pkg/apis/clusterlink/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/clusterlink/v1alpha1/zz_generated.deepcopy.go index 220b1e469..c872b5916 100644 --- a/pkg/apis/clusterlink/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/clusterlink/v1alpha1/zz_generated.deepcopy.go @@ -436,6 +436,31 @@ func (in *NodeConfigStatus) DeepCopy() *NodeConfigStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Proxy) DeepCopyInto(out *Proxy) { + *out = *in + out.TypeMeta = in.TypeMeta + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Proxy. +func (in *Proxy) DeepCopy() *Proxy { + if in == nil { + return nil + } + out := new(Proxy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Proxy) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Route) DeepCopyInto(out *Route) { *out = *in diff --git a/pkg/apis/clusterlink/v1alpha1/zz_generated.register.go b/pkg/apis/clusterlink/v1alpha1/zz_generated.register.go index 1952226d6..18aad2e26 100644 --- a/pkg/apis/clusterlink/v1alpha1/zz_generated.register.go +++ b/pkg/apis/clusterlink/v1alpha1/zz_generated.register.go @@ -48,6 +48,7 @@ func addKnownTypes(scheme *runtime.Scheme) error { &ClusterNodeList{}, &NodeConfig{}, &NodeConfigList{}, + &Proxy{}, ) // AddToGroupVersion allows the serialization of client types like ListOptions. v1.AddToGroupVersion(scheme, SchemeGroupVersion) diff --git a/pkg/clusterlinkctl/ctl.go b/pkg/clusterlinkctl/ctl.go index ebeb2a56b..ad831db6e 100644 --- a/pkg/clusterlinkctl/ctl.go +++ b/pkg/clusterlinkctl/ctl.go @@ -10,10 +10,10 @@ import ( "k8s.io/klog/v2" "k8s.io/kubectl/pkg/util/templates" - "cnp.io/clusterlink/pkg/clusterlinkctl/floaterclient" - "cnp.io/clusterlink/pkg/clusterlinkctl/initmaster" - "cnp.io/clusterlink/pkg/clusterlinkctl/membercurd" - "cnp.io/clusterlink/pkg/version" + "github.com/kosmos.io/clusterlink/pkg/clusterlinkctl/floaterclient" + "github.com/kosmos.io/clusterlink/pkg/clusterlinkctl/initmaster" + "github.com/kosmos.io/clusterlink/pkg/clusterlinkctl/membercurd" + "github.com/kosmos.io/clusterlink/pkg/version" ) var ( diff --git a/pkg/clusterlinkctl/floaterclient/cluster-helper.go b/pkg/clusterlinkctl/floaterclient/cluster-helper.go index c78d516f4..1909ac358 100644 --- a/pkg/clusterlinkctl/floaterclient/cluster-helper.go +++ b/pkg/clusterlinkctl/floaterclient/cluster-helper.go @@ -12,7 +12,7 @@ import ( "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" ) const ( diff --git a/pkg/clusterlinkctl/floaterclient/command/curl.go b/pkg/clusterlinkctl/floaterclient/command/curl.go index be0ee8bf8..a08acf2bd 100644 --- a/pkg/clusterlinkctl/floaterclient/command/curl.go +++ b/pkg/clusterlinkctl/floaterclient/command/curl.go @@ -3,7 +3,7 @@ package command import ( "fmt" - "cnp.io/clusterlink/pkg/utils" + "github.com/kosmos.io/clusterlink/pkg/utils" "k8s.io/klog/v2" ) diff --git a/pkg/clusterlinkctl/floaterclient/doctor.go b/pkg/clusterlinkctl/floaterclient/doctor.go index 91b6d09be..39cefdd18 100644 --- a/pkg/clusterlinkctl/floaterclient/doctor.go +++ b/pkg/clusterlinkctl/floaterclient/doctor.go @@ -9,10 +9,10 @@ import ( "github.com/spf13/cobra" apiextensionsclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset" - "cnp.io/clusterlink/pkg/clusterlinkctl/floaterclient/command" - "cnp.io/clusterlink/pkg/clusterlinkctl/floaterclient/netmap" - "cnp.io/clusterlink/pkg/clusterlinkctl/util" - "cnp.io/clusterlink/pkg/version" + "github.com/kosmos.io/clusterlink/pkg/clusterlinkctl/floaterclient/command" + "github.com/kosmos.io/clusterlink/pkg/clusterlinkctl/floaterclient/netmap" + "github.com/kosmos.io/clusterlink/pkg/clusterlinkctl/util" + "github.com/kosmos.io/clusterlink/pkg/version" ) type DoctorOptions struct { diff --git a/pkg/clusterlinkctl/floaterclient/floater.go b/pkg/clusterlinkctl/floaterclient/floater.go index 2ce01b0a2..43f7f82bc 100644 --- a/pkg/clusterlinkctl/floaterclient/floater.go +++ b/pkg/clusterlinkctl/floaterclient/floater.go @@ -18,11 +18,11 @@ import ( "k8s.io/client-go/tools/remotecommand" "k8s.io/klog/v2" - "cnp.io/clusterlink/pkg/clusterlinkctl/floaterclient/command" - "cnp.io/clusterlink/pkg/clusterlinkctl/initmaster/ctlmaster" - "cnp.io/clusterlink/pkg/clusterlinkctl/util/apiclient" - "cnp.io/clusterlink/pkg/operator/addons/utils" - cmdutil "cnp.io/clusterlink/pkg/operator/util" + "github.com/kosmos.io/clusterlink/pkg/clusterlinkctl/floaterclient/command" + "github.com/kosmos.io/clusterlink/pkg/clusterlinkctl/initmaster/ctlmaster" + "github.com/kosmos.io/clusterlink/pkg/clusterlinkctl/util/apiclient" + "github.com/kosmos.io/clusterlink/pkg/operator/addons/utils" + cmdutil "github.com/kosmos.io/clusterlink/pkg/operator/util" ) type FloaterInfo struct { diff --git a/pkg/clusterlinkctl/initmaster/ctlmaster/deploy_configmap.go b/pkg/clusterlinkctl/initmaster/ctlmaster/deploy_configmap.go index f5d65cb01..86207a898 100644 --- a/pkg/clusterlinkctl/initmaster/ctlmaster/deploy_configmap.go +++ b/pkg/clusterlinkctl/initmaster/ctlmaster/deploy_configmap.go @@ -9,7 +9,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/klog/v2" - apiclient "cnp.io/clusterlink/pkg/clusterlinkctl/util/apiclient" + apiclient "github.com/kosmos.io/clusterlink/pkg/clusterlinkctl/util/apiclient" ) func (i *CommandInitOption) initClusterlinkConfigmap() error { diff --git a/pkg/clusterlinkctl/initmaster/ctlmaster/deploy_deployments.go b/pkg/clusterlinkctl/initmaster/ctlmaster/deploy_deployments.go index a9df4b8ae..dfc29b945 100644 --- a/pkg/clusterlinkctl/initmaster/ctlmaster/deploy_deployments.go +++ b/pkg/clusterlinkctl/initmaster/ctlmaster/deploy_deployments.go @@ -11,9 +11,9 @@ import ( clientsetscheme "k8s.io/client-go/kubernetes/scheme" "k8s.io/klog/v2" - "cnp.io/clusterlink/pkg/clusterlinkctl/util/apiclient" - "cnp.io/clusterlink/pkg/operator/addons/utils" - "cnp.io/clusterlink/pkg/version" + "github.com/kosmos.io/clusterlink/pkg/clusterlinkctl/util/apiclient" + "github.com/kosmos.io/clusterlink/pkg/operator/addons/utils" + "github.com/kosmos.io/clusterlink/pkg/version" ) var deploymentTemplateNameMap = map[string]string{ diff --git a/pkg/clusterlinkctl/initmaster/ctlmaster/deploy_rbac.go b/pkg/clusterlinkctl/initmaster/ctlmaster/deploy_rbac.go index 096e27aef..f2ca4af58 100644 --- a/pkg/clusterlinkctl/initmaster/ctlmaster/deploy_rbac.go +++ b/pkg/clusterlinkctl/initmaster/ctlmaster/deploy_rbac.go @@ -12,8 +12,8 @@ import ( clientsetscheme "k8s.io/client-go/kubernetes/scheme" "k8s.io/klog/v2" - apiclient "cnp.io/clusterlink/pkg/clusterlinkctl/util/apiclient" - "cnp.io/clusterlink/pkg/operator/addons/utils" + apiclient "github.com/kosmos.io/clusterlink/pkg/clusterlinkctl/util/apiclient" + "github.com/kosmos.io/clusterlink/pkg/operator/addons/utils" ) var serviceaccountTemplateNameMap = map[string]string{ diff --git a/pkg/clusterlinkctl/initmaster/ctlmaster/install.go b/pkg/clusterlinkctl/initmaster/ctlmaster/install.go index 9c62b2468..eed85b737 100644 --- a/pkg/clusterlinkctl/initmaster/ctlmaster/install.go +++ b/pkg/clusterlinkctl/initmaster/ctlmaster/install.go @@ -11,9 +11,9 @@ import ( "k8s.io/client-go/kubernetes" "k8s.io/klog/v2" - "cnp.io/clusterlink/pkg/clusterlinkctl/util/apiclient" - "cnp.io/clusterlink/pkg/operator/util" - "cnp.io/clusterlink/pkg/version" + "github.com/kosmos.io/clusterlink/pkg/clusterlinkctl/util/apiclient" + "github.com/kosmos.io/clusterlink/pkg/operator/util" + "github.com/kosmos.io/clusterlink/pkg/version" ) var ( diff --git a/pkg/clusterlinkctl/initmaster/ctlmaster/manifests_crd.go b/pkg/clusterlinkctl/initmaster/ctlmaster/manifests_crd.go index a96d05be3..52e02958a 100644 --- a/pkg/clusterlinkctl/initmaster/ctlmaster/manifests_crd.go +++ b/pkg/clusterlinkctl/initmaster/ctlmaster/manifests_crd.go @@ -8,7 +8,7 @@ import ( clientsetscheme "k8s.io/client-go/kubernetes/scheme" "k8s.io/klog/v2" - "cnp.io/clusterlink/pkg/operator/addons/utils" + "github.com/kosmos.io/clusterlink/pkg/operator/addons/utils" ) const ( diff --git a/pkg/clusterlinkctl/initmaster/initmaster.go b/pkg/clusterlinkctl/initmaster/initmaster.go index f145a01cc..041516225 100644 --- a/pkg/clusterlinkctl/initmaster/initmaster.go +++ b/pkg/clusterlinkctl/initmaster/initmaster.go @@ -6,9 +6,9 @@ import ( "github.com/spf13/cobra" "k8s.io/kubectl/pkg/util/templates" - "cnp.io/clusterlink/pkg/clusterlinkctl/initmaster/ctlmaster" - "cnp.io/clusterlink/pkg/clusterlinkctl/util" - "cnp.io/clusterlink/pkg/version" + "github.com/kosmos.io/clusterlink/pkg/clusterlinkctl/initmaster/ctlmaster" + "github.com/kosmos.io/clusterlink/pkg/clusterlinkctl/util" + "github.com/kosmos.io/clusterlink/pkg/version" ) var ( diff --git a/pkg/clusterlinkctl/membercurd/options.go b/pkg/clusterlinkctl/membercurd/options.go index 19dfb0185..09b1c4edb 100644 --- a/pkg/clusterlinkctl/membercurd/options.go +++ b/pkg/clusterlinkctl/membercurd/options.go @@ -13,10 +13,10 @@ import ( "k8s.io/client-go/tools/clientcmd" "k8s.io/klog/v2" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - "cnp.io/clusterlink/pkg/clusterlinkctl/util/apiclient" - "cnp.io/clusterlink/pkg/generated/clientset/versioned" - "cnp.io/clusterlink/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/clusterlinkctl/util/apiclient" + "github.com/kosmos.io/clusterlink/pkg/generated/clientset/versioned" + "github.com/kosmos.io/clusterlink/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1" ) type CommandMemberOption struct { diff --git a/pkg/controllers/calicoippool/calicoippool_controller.go b/pkg/controllers/calicoippool/calicoippool_controller.go index f1192b3e4..2bcd53279 100644 --- a/pkg/controllers/calicoippool/calicoippool_controller.go +++ b/pkg/controllers/calicoippool/calicoippool_controller.go @@ -22,14 +22,14 @@ import ( "k8s.io/client-go/tools/cache" "k8s.io/klog/v2" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - clusterhelper "cnp.io/clusterlink/pkg/controllers/cluster" - "cnp.io/clusterlink/pkg/generated/clientset/versioned" - "cnp.io/clusterlink/pkg/generated/informers/externalversions" - "cnp.io/clusterlink/pkg/generated/listers/clusterlink/v1alpha1" - "cnp.io/clusterlink/pkg/utils" - "cnp.io/clusterlink/pkg/utils/flags" - "cnp.io/clusterlink/pkg/utils/keys" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + clusterhelper "github.com/kosmos.io/clusterlink/pkg/controllers/cluster" + "github.com/kosmos.io/clusterlink/pkg/generated/clientset/versioned" + "github.com/kosmos.io/clusterlink/pkg/generated/informers/externalversions" + "github.com/kosmos.io/clusterlink/pkg/generated/listers/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/utils" + "github.com/kosmos.io/clusterlink/pkg/utils/flags" + "github.com/kosmos.io/clusterlink/pkg/utils/keys" ) type ExternalIPPoolSet = map[ExternalClusterIPPool]struct{} @@ -145,10 +145,13 @@ func (k *KubernetesBackend) DeleteIPPool(ipPools []*ExternalClusterIPPool) error for _, ipPool := range ipPools { klog.Infof("prepare delete ippool, %v", ipPool.String()) err := k.dynamicClient.Resource(calicoIPPoolGVR).Delete(context.TODO(), genCalicoIPPoolName(ipPool.cluster, ipPool.ipType, ipPool.ipPool), metav1.DeleteOptions{}) - if apierrors.IsNotFound(err) { - continue + if err != nil { + if apierrors.IsNotFound(err) { + continue + } + errs = append(errs, err) } - errs = append(errs, err) + } if len(errs) > 0 { @@ -308,6 +311,8 @@ func (c *Controller) Start(ctx context.Context) error { factory.Start(c.stopCh) factory.WaitForCacheSync(c.stopCh) c.processor.Run(1, c.stopCh) + <-ctx.Done() + klog.Infof("Stop calicoippool controller as process done.") return nil } @@ -455,3 +460,23 @@ func (c *Controller) createIPPoolClient(cluster *clusterlinkv1alpha1.Cluster) (I } return ippoolClient, nil } + +func (c *Controller) CleanResource() error { + if c.iPPoolClient == nil { + cluster, err := c.clusterLinkClient.ClusterlinkV1alpha1().Clusters().Get(context.TODO(), c.clusterName, metav1.GetOptions{}) + if err != nil { + return err + } + iPPoolClient, err := c.createIPPoolClient(cluster) + if err != nil { + return err + } + c.iPPoolClient = iPPoolClient + } + c.globalExtIPPoolSet = make(ExternalIPPoolSet) + err := syncIPPool(c.clusterName, c.globalExtIPPoolSet, c.iPPoolClient) + if err != nil { + return fmt.Errorf("calicoippool_controller failed to clean resource: %v", err) + } + return nil +} diff --git a/pkg/controllers/calicoippool/calicoippool_controller_test.go b/pkg/controllers/calicoippool/calicoippool_controller_test.go index 2378c17ad..0676130fe 100644 --- a/pkg/controllers/calicoippool/calicoippool_controller_test.go +++ b/pkg/controllers/calicoippool/calicoippool_controller_test.go @@ -8,7 +8,7 @@ import ( v3 "github.com/projectcalico/api/pkg/apis/projectcalico/v3" - "cnp.io/clusterlink/pkg/utils" + "github.com/kosmos.io/clusterlink/pkg/utils" ) type fakeIPPoolClient struct { diff --git a/pkg/controllers/calicoippool/manifests.go b/pkg/controllers/calicoippool/manifests.go index e14705e14..8c1ea00aa 100644 --- a/pkg/controllers/calicoippool/manifests.go +++ b/pkg/controllers/calicoippool/manifests.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "cnp.io/clusterlink/pkg/utils" + "github.com/kosmos.io/clusterlink/pkg/utils" ) const ( diff --git a/pkg/controllers/cluster/cluster_controller.go b/pkg/controllers/cluster/cluster_controller.go index 100d156a3..f660c32bd 100644 --- a/pkg/controllers/cluster/cluster_controller.go +++ b/pkg/controllers/cluster/cluster_controller.go @@ -28,11 +28,11 @@ import ( "k8s.io/client-go/tools/cache" "k8s.io/klog/v2" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - "cnp.io/clusterlink/pkg/generated/clientset/versioned" - "cnp.io/clusterlink/pkg/utils" - "cnp.io/clusterlink/pkg/utils/flags" - "cnp.io/clusterlink/pkg/utils/keys" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/generated/clientset/versioned" + "github.com/kosmos.io/clusterlink/pkg/utils" + "github.com/kosmos.io/clusterlink/pkg/utils/flags" + "github.com/kosmos.io/clusterlink/pkg/utils/keys" ) type SetClusterPodCIDRFun func(cluster *clusterlinkv1alpha1.Cluster) error @@ -46,12 +46,12 @@ type Controller struct { kubeClient *kubernetes.Clientset dynamicClient *dynamic.DynamicClient podLister v1.PodLister - clusterLinkClient *versioned.Clientset + clusterLinkClient versioned.Interface setClusterPodCIDRFun SetClusterPodCIDRFun stopCh <-chan struct{} } -func NewController(clusterName string, kubeClient *kubernetes.Clientset, dynamicClient *dynamic.DynamicClient, clusterLinkClient *versioned.Clientset) *Controller { +func NewController(clusterName string, kubeClient *kubernetes.Clientset, dynamicClient *dynamic.DynamicClient, clusterLinkClient versioned.Interface) *Controller { return &Controller{ clusterName: clusterName, kubeClient: kubeClient, @@ -130,6 +130,8 @@ func (c *Controller) Start(ctx context.Context) error { factory.Start(c.stopCh) factory.WaitForCacheSync(c.stopCh) c.processor.Run(1, c.stopCh) + <-ctx.Done() + klog.Infof("Stop cluster controller as process done.") return nil } diff --git a/pkg/controllers/cluster/helper.go b/pkg/controllers/cluster/helper.go index 1154da03c..ee841ef81 100644 --- a/pkg/controllers/cluster/helper.go +++ b/pkg/controllers/cluster/helper.go @@ -15,7 +15,7 @@ import ( "k8s.io/klog/v2" ctrl "sigs.k8s.io/controller-runtime" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" ) const ( diff --git a/pkg/controllers/cluster/helper_test.go b/pkg/controllers/cluster/helper_test.go index 2720067ee..ba4eb41c9 100644 --- a/pkg/controllers/cluster/helper_test.go +++ b/pkg/controllers/cluster/helper_test.go @@ -6,7 +6,7 @@ import ( v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" ) func TestResolveServiceCIDRs(t *testing.T) { diff --git a/pkg/controllers/context/context.go b/pkg/controllers/context/context.go index 789427fc7..0334fd4d1 100644 --- a/pkg/controllers/context/context.go +++ b/pkg/controllers/context/context.go @@ -1,13 +1,16 @@ package context import ( + "context" + "k8s.io/apimachinery/pkg/util/sets" - "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" "k8s.io/klog/v2" ctrl "sigs.k8s.io/controller-runtime" - "cnp.io/clusterlink/pkg/generated/informers/externalversions" + "github.com/kosmos.io/clusterlink/pkg/generated/clientset/versioned" + "github.com/kosmos.io/clusterlink/pkg/generated/informers/externalversions" + "github.com/kosmos.io/clusterlink/pkg/utils/flags" ) type Options struct { @@ -15,15 +18,16 @@ type Options struct { Controllers []string ControlPanelConfig *rest.Config ClusterName string + RateLimiterOpts flags.Options } // Context defines the context object for controller. type Context struct { Mgr ctrl.Manager Opts Options - StopChan <-chan struct{} - ClientSet kubernetes.Clientset + Ctx context.Context ControlPlaneInformerManager externalversions.SharedInformerFactory + ClusterLinkClient versioned.Interface } // IsControllerEnabled check if a specified controller enabled or not. @@ -49,10 +53,12 @@ func (c Context) IsControllerEnabled(name string, disabledByDefaultControllers s return !disabledByDefaultControllers.Has(name) } +type CleanFunc func() error + // InitFunc is used to launch a particular controller. // Any error returned will cause the controller process to `Fatal` // The bool indicates whether the controller was enabled. -type InitFunc func(ctx Context) (enabled bool, err error) +type InitFunc func(ctx Context) (enabled bool, cleanFunc CleanFunc, err error) // Initializers is a public map of named controller groups type Initializers map[string]InitFunc @@ -63,23 +69,28 @@ func (i Initializers) ControllerNames() []string { } // StartControllers starts a set of controllers with a specified ControllerContext -func (i Initializers) StartControllers(ctx Context, controllersDisabledByDefault sets.Set[string]) error { +func (i Initializers) StartControllers(ctx Context, controllersDisabledByDefault sets.Set[string]) ([]CleanFunc, error) { + + var cleanFuncs []CleanFunc for controllerName, initFn := range i { if !ctx.IsControllerEnabled(controllerName, controllersDisabledByDefault) { klog.Warningf("%q is disabled", controllerName) continue } klog.V(1).Infof("Starting %q", controllerName) - started, err := initFn(ctx) + started, cleanFun, err := initFn(ctx) if err != nil { klog.Errorf("Error starting %q", controllerName) - return err + return nil, err } if !started { klog.Warningf("Skipping %q", controllerName) continue } + if cleanFun != nil { + cleanFuncs = append(cleanFuncs, cleanFun) + } klog.Infof("Started %q", controllerName) } - return nil + return cleanFuncs, nil } diff --git a/pkg/controllers/node/node_controller.go b/pkg/controllers/node/node_controller.go index 2b3bc74aa..758d5920f 100644 --- a/pkg/controllers/node/node_controller.go +++ b/pkg/controllers/node/node_controller.go @@ -3,7 +3,6 @@ package node import ( "context" "fmt" - "k8s.io/apimachinery/pkg/util/errors" "net" "time" @@ -11,6 +10,7 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/errors" "k8s.io/klog/v2" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/builder" @@ -21,9 +21,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/reconcile" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - "cnp.io/clusterlink/pkg/generated/clientset/versioned" - interfacepolicy "cnp.io/clusterlink/pkg/utils/interface-policy" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/generated/clientset/versioned" + interfacepolicy "github.com/kosmos.io/clusterlink/pkg/utils/interface-policy" ) const ( @@ -35,7 +35,7 @@ const ( type Reconciler struct { client.Client Scheme *runtime.Scheme - ClusterLinkClient *versioned.Clientset + ClusterLinkClient versioned.Interface ClusterName string } @@ -218,6 +218,29 @@ func (r *Reconciler) SetupWithManager(mgr manager.Manager, stopChan <-chan struc Complete(r) } +func (r *Reconciler) CleanResource() error { + list, err := r.ClusterLinkClient.ClusterlinkV1alpha1().ClusterNodes().List(context.TODO(), metav1.ListOptions{ + LabelSelector: fmt.Sprintf("clusterlink.io/cluster=%s", r.ClusterName), + }) + if err != nil { + + } + var errs []error + for _, node := range list.Items { + err := r.ClusterLinkClient.ClusterlinkV1alpha1().ClusterNodes().Delete(context.TODO(), node.GetName(), metav1.DeleteOptions{}) + if err != nil { + if apierrors.IsNotFound(err) { + continue + } + errs = append(errs, err) + } + } + if len(errs) > 0 { + return fmt.Errorf("node controller failed delete clustersNodes: %v", errors.NewAggregate(errs)) + } + return nil +} + func ClusterNodeName(clusterName, nodeName string) string { return clusterName + "-" + nodeName } diff --git a/pkg/controllers/nodecidr/adapter.go b/pkg/controllers/nodecidr/adapter.go index 490739419..70a7233a6 100644 --- a/pkg/controllers/nodecidr/adapter.go +++ b/pkg/controllers/nodecidr/adapter.go @@ -16,8 +16,8 @@ import ( "k8s.io/client-go/tools/cache" "k8s.io/klog/v2" - clusterlister "cnp.io/clusterlink/pkg/generated/listers/clusterlink/v1alpha1" - "cnp.io/clusterlink/pkg/utils" + clusterlister "github.com/kosmos.io/clusterlink/pkg/generated/listers/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/utils" ) type cniAdapter interface { diff --git a/pkg/controllers/nodecidr/nodecidr_controller.go b/pkg/controllers/nodecidr/nodecidr_controller.go index db830e78b..3d5073f42 100644 --- a/pkg/controllers/nodecidr/nodecidr_controller.go +++ b/pkg/controllers/nodecidr/nodecidr_controller.go @@ -14,14 +14,14 @@ import ( "k8s.io/client-go/util/retry" "k8s.io/klog/v2" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - "cnp.io/clusterlink/pkg/generated/clientset/versioned" - "cnp.io/clusterlink/pkg/generated/informers/externalversions" - clusterinformer "cnp.io/clusterlink/pkg/generated/informers/externalversions/clusterlink/v1alpha1" - clusterlister "cnp.io/clusterlink/pkg/generated/listers/clusterlink/v1alpha1" - "cnp.io/clusterlink/pkg/utils" - "cnp.io/clusterlink/pkg/utils/flags" - "cnp.io/clusterlink/pkg/utils/keys" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/generated/clientset/versioned" + "github.com/kosmos.io/clusterlink/pkg/generated/informers/externalversions" + clusterinformer "github.com/kosmos.io/clusterlink/pkg/generated/informers/externalversions/clusterlink/v1alpha1" + clusterlister "github.com/kosmos.io/clusterlink/pkg/generated/listers/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/utils" + "github.com/kosmos.io/clusterlink/pkg/utils/flags" + "github.com/kosmos.io/clusterlink/pkg/utils/keys" ) const ( @@ -34,7 +34,7 @@ type controller struct { clusterName string config *rest.Config - clusterLinkClient *versioned.Clientset + clusterLinkClient versioned.Interface // RateLimiterOptions is the configuration for rate limiter which may significantly influence the performance of // the controller. @@ -45,15 +45,15 @@ type controller struct { cniAdapter cniAdapter sync.RWMutex - stopCh <-chan struct{} + ctx context.Context } -func NewNodeCIDRController(config *rest.Config, clusterName string, clusterLinkClient *versioned.Clientset, RateLimiterOptions flags.Options, stopCh <-chan struct{}) *controller { +func NewNodeCIDRController(config *rest.Config, clusterName string, clusterLinkClient versioned.Interface, RateLimiterOptions flags.Options, context context.Context) *controller { return &controller{ clusterLinkClient: clusterLinkClient, config: config, RateLimiterOptions: RateLimiterOptions, - stopCh: stopCh, + ctx: context, clusterName: clusterName, } } @@ -61,10 +61,6 @@ func NewNodeCIDRController(config *rest.Config, clusterName string, clusterLinkC func (c *controller) Start(ctx context.Context) error { klog.Infof("Starting node cidr controller.") - // first step : init close chan - c.stopCh = ctx.Done() - - //second step: init work processor opt := utils.Options{ Name: "node cidr controller", KeyFunc: ClusterWideKeyFunc, @@ -101,8 +97,9 @@ func (c *controller) Start(ctx context.Context) error { return err } - clusterInformerFactory.Start(c.stopCh) - clusterInformerFactory.WaitForCacheSync(c.stopCh) + stopCh := c.ctx.Done() + clusterInformerFactory.Start(stopCh) + clusterInformerFactory.WaitForCacheSync(stopCh) // third step: init CNI Adapter if cluster.Spec.CNI == calicoCNI { @@ -110,14 +107,14 @@ func (c *controller) Start(ctx context.Context) error { } else { c.cniAdapter = NewCommonAdapter(c.config, c.clusterNodeLister, c.processor) } - err = c.cniAdapter.start(c.stopCh) + err = c.cniAdapter.start(stopCh) if err != nil { return err } // last step : start processor and waiting for close chan - c.processor.Run(workNum, c.stopCh) - <-c.stopCh + c.processor.Run(workNum, stopCh) + <-stopCh klog.Infof("Stop node cidr controller as process done.") return nil } diff --git a/pkg/elector/elector.go b/pkg/elector/elector.go index d945f419a..a5468e7f2 100644 --- a/pkg/elector/elector.go +++ b/pkg/elector/elector.go @@ -7,9 +7,10 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/klog/v2" - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - "cnp.io/clusterlink/pkg/generated/clientset/versioned" - "cnp.io/clusterlink/pkg/utils/role" + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/generated/clientset/versioned" + "github.com/kosmos.io/clusterlink/pkg/utils" + "github.com/kosmos.io/clusterlink/pkg/utils/role" ) type Elector struct { @@ -20,8 +21,8 @@ type Elector struct { func NewElector(controlPanelClient versioned.Interface) *Elector { return &Elector{ - nodeName: os.Getenv("NODE_NAME"), - clusterName: os.Getenv("CLUSTER_NAME"), + nodeName: os.Getenv(utils.EnvNodeName), + clusterName: os.Getenv(utils.EnvClusterName), controlPanelClient: controlPanelClient, } } diff --git a/pkg/elector/elector_test.go b/pkg/elector/elector_test.go index 0fa08e433..1ff991921 100644 --- a/pkg/elector/elector_test.go +++ b/pkg/elector/elector_test.go @@ -8,7 +8,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" ) func TestEnsureGateWayRole(t *testing.T) { diff --git a/pkg/generated/clientset/versioned/clientset.go b/pkg/generated/clientset/versioned/clientset.go index 07227bd43..7795e7305 100644 --- a/pkg/generated/clientset/versioned/clientset.go +++ b/pkg/generated/clientset/versioned/clientset.go @@ -6,7 +6,7 @@ import ( "fmt" "net/http" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1" discovery "k8s.io/client-go/discovery" rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" diff --git a/pkg/generated/clientset/versioned/fake/clientset_generated.go b/pkg/generated/clientset/versioned/fake/clientset_generated.go index 8356480ee..f80c15c9f 100644 --- a/pkg/generated/clientset/versioned/fake/clientset_generated.go +++ b/pkg/generated/clientset/versioned/fake/clientset_generated.go @@ -3,9 +3,9 @@ package fake import ( - clientset "cnp.io/clusterlink/pkg/generated/clientset/versioned" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1" - fakeclusterlinkv1alpha1 "cnp.io/clusterlink/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/fake" + clientset "github.com/kosmos.io/clusterlink/pkg/generated/clientset/versioned" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1" + fakeclusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/fake" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/discovery" diff --git a/pkg/generated/clientset/versioned/fake/register.go b/pkg/generated/clientset/versioned/fake/register.go index 14d9a637f..400ca0a7c 100644 --- a/pkg/generated/clientset/versioned/fake/register.go +++ b/pkg/generated/clientset/versioned/fake/register.go @@ -3,7 +3,7 @@ package fake import ( - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/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/pkg/generated/clientset/versioned/scheme/register.go b/pkg/generated/clientset/versioned/scheme/register.go index 93438a107..7c76515e2 100644 --- a/pkg/generated/clientset/versioned/scheme/register.go +++ b/pkg/generated/clientset/versioned/scheme/register.go @@ -3,7 +3,7 @@ package scheme import ( - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/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/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/cluster.go b/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/cluster.go index 278099f7d..f56fee16d 100644 --- a/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/cluster.go +++ b/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/cluster.go @@ -6,8 +6,8 @@ import ( "context" "time" - v1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - scheme "cnp.io/clusterlink/pkg/generated/clientset/versioned/scheme" + v1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + scheme "github.com/kosmos.io/clusterlink/pkg/generated/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/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/clusterlink_client.go b/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/clusterlink_client.go index b7819bc43..8a9e6dea5 100644 --- a/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/clusterlink_client.go +++ b/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/clusterlink_client.go @@ -5,8 +5,8 @@ package v1alpha1 import ( "net/http" - v1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - "cnp.io/clusterlink/pkg/generated/clientset/versioned/scheme" + v1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/generated/clientset/versioned/scheme" rest "k8s.io/client-go/rest" ) diff --git a/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/clusternode.go b/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/clusternode.go index ab0b93ed0..76c032c14 100644 --- a/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/clusternode.go +++ b/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/clusternode.go @@ -6,8 +6,8 @@ import ( "context" "time" - v1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - scheme "cnp.io/clusterlink/pkg/generated/clientset/versioned/scheme" + v1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + scheme "github.com/kosmos.io/clusterlink/pkg/generated/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/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/fake/fake_cluster.go b/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/fake/fake_cluster.go index 7350d9f97..0de802922 100644 --- a/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/fake/fake_cluster.go +++ b/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/fake/fake_cluster.go @@ -5,7 +5,7 @@ package fake import ( "context" - v1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + v1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" schema "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/fake/fake_clusterlink_client.go b/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/fake/fake_clusterlink_client.go index 8b15df028..4c7fc1ad6 100644 --- a/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/fake/fake_clusterlink_client.go +++ b/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/fake/fake_clusterlink_client.go @@ -3,7 +3,7 @@ package fake import ( - v1alpha1 "cnp.io/clusterlink/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1" + v1alpha1 "github.com/kosmos.io/clusterlink/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1" rest "k8s.io/client-go/rest" testing "k8s.io/client-go/testing" ) diff --git a/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/fake/fake_clusternode.go b/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/fake/fake_clusternode.go index eb3f0852d..144623f25 100644 --- a/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/fake/fake_clusternode.go +++ b/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/fake/fake_clusternode.go @@ -5,7 +5,7 @@ package fake import ( "context" - v1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + v1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" schema "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/fake/fake_nodeconfig.go b/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/fake/fake_nodeconfig.go index 640d425a1..7f97c527a 100644 --- a/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/fake/fake_nodeconfig.go +++ b/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/fake/fake_nodeconfig.go @@ -5,7 +5,7 @@ package fake import ( "context" - v1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + v1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" schema "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/nodeconfig.go b/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/nodeconfig.go index 1c3b2b4fc..9d7d10fbb 100644 --- a/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/nodeconfig.go +++ b/pkg/generated/clientset/versioned/typed/clusterlink/v1alpha1/nodeconfig.go @@ -6,8 +6,8 @@ import ( "context" "time" - v1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - scheme "cnp.io/clusterlink/pkg/generated/clientset/versioned/scheme" + v1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + scheme "github.com/kosmos.io/clusterlink/pkg/generated/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/pkg/generated/informers/externalversions/clusterlink/interface.go b/pkg/generated/informers/externalversions/clusterlink/interface.go index 081a188b2..564a4e249 100644 --- a/pkg/generated/informers/externalversions/clusterlink/interface.go +++ b/pkg/generated/informers/externalversions/clusterlink/interface.go @@ -3,8 +3,8 @@ package clusterlink import ( - v1alpha1 "cnp.io/clusterlink/pkg/generated/informers/externalversions/clusterlink/v1alpha1" - internalinterfaces "cnp.io/clusterlink/pkg/generated/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/kosmos.io/clusterlink/pkg/generated/informers/externalversions/clusterlink/v1alpha1" + internalinterfaces "github.com/kosmos.io/clusterlink/pkg/generated/informers/externalversions/internalinterfaces" ) // Interface provides access to each of this group's versions. diff --git a/pkg/generated/informers/externalversions/clusterlink/v1alpha1/cluster.go b/pkg/generated/informers/externalversions/clusterlink/v1alpha1/cluster.go index fa877ad6b..4a21cd9ab 100644 --- a/pkg/generated/informers/externalversions/clusterlink/v1alpha1/cluster.go +++ b/pkg/generated/informers/externalversions/clusterlink/v1alpha1/cluster.go @@ -6,10 +6,10 @@ import ( "context" time "time" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - versioned "cnp.io/clusterlink/pkg/generated/clientset/versioned" - internalinterfaces "cnp.io/clusterlink/pkg/generated/informers/externalversions/internalinterfaces" - v1alpha1 "cnp.io/clusterlink/pkg/generated/listers/clusterlink/v1alpha1" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + versioned "github.com/kosmos.io/clusterlink/pkg/generated/clientset/versioned" + internalinterfaces "github.com/kosmos.io/clusterlink/pkg/generated/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/kosmos.io/clusterlink/pkg/generated/listers/clusterlink/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" diff --git a/pkg/generated/informers/externalversions/clusterlink/v1alpha1/clusternode.go b/pkg/generated/informers/externalversions/clusterlink/v1alpha1/clusternode.go index 1d87608d8..5bf0a4c3f 100644 --- a/pkg/generated/informers/externalversions/clusterlink/v1alpha1/clusternode.go +++ b/pkg/generated/informers/externalversions/clusterlink/v1alpha1/clusternode.go @@ -6,10 +6,10 @@ import ( "context" time "time" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - versioned "cnp.io/clusterlink/pkg/generated/clientset/versioned" - internalinterfaces "cnp.io/clusterlink/pkg/generated/informers/externalversions/internalinterfaces" - v1alpha1 "cnp.io/clusterlink/pkg/generated/listers/clusterlink/v1alpha1" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + versioned "github.com/kosmos.io/clusterlink/pkg/generated/clientset/versioned" + internalinterfaces "github.com/kosmos.io/clusterlink/pkg/generated/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/kosmos.io/clusterlink/pkg/generated/listers/clusterlink/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" diff --git a/pkg/generated/informers/externalversions/clusterlink/v1alpha1/interface.go b/pkg/generated/informers/externalversions/clusterlink/v1alpha1/interface.go index 9585ff9f8..fb4df5165 100644 --- a/pkg/generated/informers/externalversions/clusterlink/v1alpha1/interface.go +++ b/pkg/generated/informers/externalversions/clusterlink/v1alpha1/interface.go @@ -3,7 +3,7 @@ package v1alpha1 import ( - internalinterfaces "cnp.io/clusterlink/pkg/generated/informers/externalversions/internalinterfaces" + internalinterfaces "github.com/kosmos.io/clusterlink/pkg/generated/informers/externalversions/internalinterfaces" ) // Interface provides access to all the informers in this group version. diff --git a/pkg/generated/informers/externalversions/clusterlink/v1alpha1/nodeconfig.go b/pkg/generated/informers/externalversions/clusterlink/v1alpha1/nodeconfig.go index 46a97db26..c683c4fba 100644 --- a/pkg/generated/informers/externalversions/clusterlink/v1alpha1/nodeconfig.go +++ b/pkg/generated/informers/externalversions/clusterlink/v1alpha1/nodeconfig.go @@ -6,10 +6,10 @@ import ( "context" time "time" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - versioned "cnp.io/clusterlink/pkg/generated/clientset/versioned" - internalinterfaces "cnp.io/clusterlink/pkg/generated/informers/externalversions/internalinterfaces" - v1alpha1 "cnp.io/clusterlink/pkg/generated/listers/clusterlink/v1alpha1" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + versioned "github.com/kosmos.io/clusterlink/pkg/generated/clientset/versioned" + internalinterfaces "github.com/kosmos.io/clusterlink/pkg/generated/informers/externalversions/internalinterfaces" + v1alpha1 "github.com/kosmos.io/clusterlink/pkg/generated/listers/clusterlink/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" diff --git a/pkg/generated/informers/externalversions/factory.go b/pkg/generated/informers/externalversions/factory.go index ef6ea6adf..73535de86 100644 --- a/pkg/generated/informers/externalversions/factory.go +++ b/pkg/generated/informers/externalversions/factory.go @@ -7,9 +7,9 @@ import ( sync "sync" time "time" - versioned "cnp.io/clusterlink/pkg/generated/clientset/versioned" - clusterlink "cnp.io/clusterlink/pkg/generated/informers/externalversions/clusterlink" - internalinterfaces "cnp.io/clusterlink/pkg/generated/informers/externalversions/internalinterfaces" + versioned "github.com/kosmos.io/clusterlink/pkg/generated/clientset/versioned" + clusterlink "github.com/kosmos.io/clusterlink/pkg/generated/informers/externalversions/clusterlink" + internalinterfaces "github.com/kosmos.io/clusterlink/pkg/generated/informers/externalversions/internalinterfaces" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/pkg/generated/informers/externalversions/generic.go b/pkg/generated/informers/externalversions/generic.go index e61268dcb..a24e67e29 100644 --- a/pkg/generated/informers/externalversions/generic.go +++ b/pkg/generated/informers/externalversions/generic.go @@ -5,7 +5,7 @@ package externalversions import ( "fmt" - v1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + v1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" ) diff --git a/pkg/generated/informers/externalversions/internalinterfaces/factory_interfaces.go b/pkg/generated/informers/externalversions/internalinterfaces/factory_interfaces.go index 74f7b4969..fc8d28cea 100644 --- a/pkg/generated/informers/externalversions/internalinterfaces/factory_interfaces.go +++ b/pkg/generated/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -5,7 +5,7 @@ package internalinterfaces import ( time "time" - versioned "cnp.io/clusterlink/pkg/generated/clientset/versioned" + versioned "github.com/kosmos.io/clusterlink/pkg/generated/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/pkg/generated/listers/clusterlink/v1alpha1/cluster.go b/pkg/generated/listers/clusterlink/v1alpha1/cluster.go index 9a81ce44c..845248a0c 100644 --- a/pkg/generated/listers/clusterlink/v1alpha1/cluster.go +++ b/pkg/generated/listers/clusterlink/v1alpha1/cluster.go @@ -3,7 +3,7 @@ package v1alpha1 import ( - v1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + v1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" diff --git a/pkg/generated/listers/clusterlink/v1alpha1/clusternode.go b/pkg/generated/listers/clusterlink/v1alpha1/clusternode.go index 87c6a75a7..53862b5eb 100644 --- a/pkg/generated/listers/clusterlink/v1alpha1/clusternode.go +++ b/pkg/generated/listers/clusterlink/v1alpha1/clusternode.go @@ -3,7 +3,7 @@ package v1alpha1 import ( - v1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + v1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" diff --git a/pkg/generated/listers/clusterlink/v1alpha1/nodeconfig.go b/pkg/generated/listers/clusterlink/v1alpha1/nodeconfig.go index 2d955bcaf..73dfc5714 100644 --- a/pkg/generated/listers/clusterlink/v1alpha1/nodeconfig.go +++ b/pkg/generated/listers/clusterlink/v1alpha1/nodeconfig.go @@ -3,7 +3,7 @@ package v1alpha1 import ( - v1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + v1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" diff --git a/pkg/generated/openapi/zz_generated.openapi.go b/pkg/generated/openapi/zz_generated.openapi.go index 6b34334dd..8e9c7e03f 100644 --- a/pkg/generated/openapi/zz_generated.openapi.go +++ b/pkg/generated/openapi/zz_generated.openapi.go @@ -15,77 +15,78 @@ import ( func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition { return map[string]common.OpenAPIDefinition{ - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Arp": schema_pkg_apis_clusterlink_v1alpha1_Arp(ref), - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Cluster": schema_pkg_apis_clusterlink_v1alpha1_Cluster(ref), - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterList": schema_pkg_apis_clusterlink_v1alpha1_ClusterList(ref), - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterNode": schema_pkg_apis_clusterlink_v1alpha1_ClusterNode(ref), - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterNodeList": schema_pkg_apis_clusterlink_v1alpha1_ClusterNodeList(ref), - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterNodeSpec": schema_pkg_apis_clusterlink_v1alpha1_ClusterNodeSpec(ref), - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterNodeStatus": schema_pkg_apis_clusterlink_v1alpha1_ClusterNodeStatus(ref), - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterSpec": schema_pkg_apis_clusterlink_v1alpha1_ClusterSpec(ref), - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterStatus": schema_pkg_apis_clusterlink_v1alpha1_ClusterStatus(ref), - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Device": schema_pkg_apis_clusterlink_v1alpha1_Device(ref), - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Fdb": schema_pkg_apis_clusterlink_v1alpha1_Fdb(ref), - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Iptables": schema_pkg_apis_clusterlink_v1alpha1_Iptables(ref), - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.NICNodeNames": schema_pkg_apis_clusterlink_v1alpha1_NICNodeNames(ref), - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.NodeConfig": schema_pkg_apis_clusterlink_v1alpha1_NodeConfig(ref), - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.NodeConfigList": schema_pkg_apis_clusterlink_v1alpha1_NodeConfigList(ref), - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.NodeConfigSpec": schema_pkg_apis_clusterlink_v1alpha1_NodeConfigSpec(ref), - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.NodeConfigStatus": schema_pkg_apis_clusterlink_v1alpha1_NodeConfigStatus(ref), - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Route": schema_pkg_apis_clusterlink_v1alpha1_Route(ref), - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.VxlanCIDRs": schema_pkg_apis_clusterlink_v1alpha1_VxlanCIDRs(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.APIGroup": schema_pkg_apis_meta_v1_APIGroup(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.APIGroupList": schema_pkg_apis_meta_v1_APIGroupList(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.APIResource": schema_pkg_apis_meta_v1_APIResource(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.APIResourceList": schema_pkg_apis_meta_v1_APIResourceList(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.APIVersions": schema_pkg_apis_meta_v1_APIVersions(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.ApplyOptions": schema_pkg_apis_meta_v1_ApplyOptions(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.Condition": schema_pkg_apis_meta_v1_Condition(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.CreateOptions": schema_pkg_apis_meta_v1_CreateOptions(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.DeleteOptions": schema_pkg_apis_meta_v1_DeleteOptions(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.Duration": schema_pkg_apis_meta_v1_Duration(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.FieldsV1": schema_pkg_apis_meta_v1_FieldsV1(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.GetOptions": schema_pkg_apis_meta_v1_GetOptions(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.GroupKind": schema_pkg_apis_meta_v1_GroupKind(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.GroupResource": schema_pkg_apis_meta_v1_GroupResource(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.GroupVersion": schema_pkg_apis_meta_v1_GroupVersion(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.GroupVersionForDiscovery": schema_pkg_apis_meta_v1_GroupVersionForDiscovery(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.GroupVersionKind": schema_pkg_apis_meta_v1_GroupVersionKind(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.GroupVersionResource": schema_pkg_apis_meta_v1_GroupVersionResource(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.InternalEvent": schema_pkg_apis_meta_v1_InternalEvent(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector": schema_pkg_apis_meta_v1_LabelSelector(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelectorRequirement": schema_pkg_apis_meta_v1_LabelSelectorRequirement(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.List": schema_pkg_apis_meta_v1_List(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta": schema_pkg_apis_meta_v1_ListMeta(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.ListOptions": schema_pkg_apis_meta_v1_ListOptions(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.ManagedFieldsEntry": schema_pkg_apis_meta_v1_ManagedFieldsEntry(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.MicroTime": schema_pkg_apis_meta_v1_MicroTime(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta": schema_pkg_apis_meta_v1_ObjectMeta(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.OwnerReference": schema_pkg_apis_meta_v1_OwnerReference(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.PartialObjectMetadata": schema_pkg_apis_meta_v1_PartialObjectMetadata(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.PartialObjectMetadataList": schema_pkg_apis_meta_v1_PartialObjectMetadataList(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.Patch": schema_pkg_apis_meta_v1_Patch(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.PatchOptions": schema_pkg_apis_meta_v1_PatchOptions(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.Preconditions": schema_pkg_apis_meta_v1_Preconditions(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.RootPaths": schema_pkg_apis_meta_v1_RootPaths(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.ServerAddressByClientCIDR": schema_pkg_apis_meta_v1_ServerAddressByClientCIDR(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.Status": schema_pkg_apis_meta_v1_Status(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.StatusCause": schema_pkg_apis_meta_v1_StatusCause(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.StatusDetails": schema_pkg_apis_meta_v1_StatusDetails(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.Table": schema_pkg_apis_meta_v1_Table(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.TableColumnDefinition": schema_pkg_apis_meta_v1_TableColumnDefinition(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.TableOptions": schema_pkg_apis_meta_v1_TableOptions(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.TableRow": schema_pkg_apis_meta_v1_TableRow(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.TableRowCondition": schema_pkg_apis_meta_v1_TableRowCondition(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.Time": schema_pkg_apis_meta_v1_Time(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.Timestamp": schema_pkg_apis_meta_v1_Timestamp(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.TypeMeta": schema_pkg_apis_meta_v1_TypeMeta(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.UpdateOptions": schema_pkg_apis_meta_v1_UpdateOptions(ref), - "k8s.io/apimachinery/pkg/apis/meta/v1.WatchEvent": schema_pkg_apis_meta_v1_WatchEvent(ref), - "k8s.io/apimachinery/pkg/runtime.RawExtension": schema_k8sio_apimachinery_pkg_runtime_RawExtension(ref), - "k8s.io/apimachinery/pkg/runtime.TypeMeta": schema_k8sio_apimachinery_pkg_runtime_TypeMeta(ref), - "k8s.io/apimachinery/pkg/runtime.Unknown": schema_k8sio_apimachinery_pkg_runtime_Unknown(ref), - "k8s.io/apimachinery/pkg/version.Info": schema_k8sio_apimachinery_pkg_version_Info(ref), + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Arp": schema_pkg_apis_clusterlink_v1alpha1_Arp(ref), + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Cluster": schema_pkg_apis_clusterlink_v1alpha1_Cluster(ref), + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterList": schema_pkg_apis_clusterlink_v1alpha1_ClusterList(ref), + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterNode": schema_pkg_apis_clusterlink_v1alpha1_ClusterNode(ref), + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterNodeList": schema_pkg_apis_clusterlink_v1alpha1_ClusterNodeList(ref), + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterNodeSpec": schema_pkg_apis_clusterlink_v1alpha1_ClusterNodeSpec(ref), + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterNodeStatus": schema_pkg_apis_clusterlink_v1alpha1_ClusterNodeStatus(ref), + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterSpec": schema_pkg_apis_clusterlink_v1alpha1_ClusterSpec(ref), + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterStatus": schema_pkg_apis_clusterlink_v1alpha1_ClusterStatus(ref), + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Device": schema_pkg_apis_clusterlink_v1alpha1_Device(ref), + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Fdb": schema_pkg_apis_clusterlink_v1alpha1_Fdb(ref), + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Iptables": schema_pkg_apis_clusterlink_v1alpha1_Iptables(ref), + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.NICNodeNames": schema_pkg_apis_clusterlink_v1alpha1_NICNodeNames(ref), + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.NodeConfig": schema_pkg_apis_clusterlink_v1alpha1_NodeConfig(ref), + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.NodeConfigList": schema_pkg_apis_clusterlink_v1alpha1_NodeConfigList(ref), + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.NodeConfigSpec": schema_pkg_apis_clusterlink_v1alpha1_NodeConfigSpec(ref), + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.NodeConfigStatus": schema_pkg_apis_clusterlink_v1alpha1_NodeConfigStatus(ref), + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Proxy": schema_pkg_apis_clusterlink_v1alpha1_Proxy(ref), + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Route": schema_pkg_apis_clusterlink_v1alpha1_Route(ref), + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.VxlanCIDRs": schema_pkg_apis_clusterlink_v1alpha1_VxlanCIDRs(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.APIGroup": schema_pkg_apis_meta_v1_APIGroup(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.APIGroupList": schema_pkg_apis_meta_v1_APIGroupList(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.APIResource": schema_pkg_apis_meta_v1_APIResource(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.APIResourceList": schema_pkg_apis_meta_v1_APIResourceList(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.APIVersions": schema_pkg_apis_meta_v1_APIVersions(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.ApplyOptions": schema_pkg_apis_meta_v1_ApplyOptions(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.Condition": schema_pkg_apis_meta_v1_Condition(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.CreateOptions": schema_pkg_apis_meta_v1_CreateOptions(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.DeleteOptions": schema_pkg_apis_meta_v1_DeleteOptions(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.Duration": schema_pkg_apis_meta_v1_Duration(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.FieldsV1": schema_pkg_apis_meta_v1_FieldsV1(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.GetOptions": schema_pkg_apis_meta_v1_GetOptions(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.GroupKind": schema_pkg_apis_meta_v1_GroupKind(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.GroupResource": schema_pkg_apis_meta_v1_GroupResource(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.GroupVersion": schema_pkg_apis_meta_v1_GroupVersion(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.GroupVersionForDiscovery": schema_pkg_apis_meta_v1_GroupVersionForDiscovery(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.GroupVersionKind": schema_pkg_apis_meta_v1_GroupVersionKind(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.GroupVersionResource": schema_pkg_apis_meta_v1_GroupVersionResource(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.InternalEvent": schema_pkg_apis_meta_v1_InternalEvent(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector": schema_pkg_apis_meta_v1_LabelSelector(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelectorRequirement": schema_pkg_apis_meta_v1_LabelSelectorRequirement(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.List": schema_pkg_apis_meta_v1_List(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta": schema_pkg_apis_meta_v1_ListMeta(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.ListOptions": schema_pkg_apis_meta_v1_ListOptions(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.ManagedFieldsEntry": schema_pkg_apis_meta_v1_ManagedFieldsEntry(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.MicroTime": schema_pkg_apis_meta_v1_MicroTime(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta": schema_pkg_apis_meta_v1_ObjectMeta(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.OwnerReference": schema_pkg_apis_meta_v1_OwnerReference(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.PartialObjectMetadata": schema_pkg_apis_meta_v1_PartialObjectMetadata(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.PartialObjectMetadataList": schema_pkg_apis_meta_v1_PartialObjectMetadataList(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.Patch": schema_pkg_apis_meta_v1_Patch(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.PatchOptions": schema_pkg_apis_meta_v1_PatchOptions(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.Preconditions": schema_pkg_apis_meta_v1_Preconditions(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.RootPaths": schema_pkg_apis_meta_v1_RootPaths(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.ServerAddressByClientCIDR": schema_pkg_apis_meta_v1_ServerAddressByClientCIDR(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.Status": schema_pkg_apis_meta_v1_Status(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.StatusCause": schema_pkg_apis_meta_v1_StatusCause(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.StatusDetails": schema_pkg_apis_meta_v1_StatusDetails(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.Table": schema_pkg_apis_meta_v1_Table(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.TableColumnDefinition": schema_pkg_apis_meta_v1_TableColumnDefinition(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.TableOptions": schema_pkg_apis_meta_v1_TableOptions(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.TableRow": schema_pkg_apis_meta_v1_TableRow(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.TableRowCondition": schema_pkg_apis_meta_v1_TableRowCondition(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.Time": schema_pkg_apis_meta_v1_Time(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.Timestamp": schema_pkg_apis_meta_v1_Timestamp(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.TypeMeta": schema_pkg_apis_meta_v1_TypeMeta(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.UpdateOptions": schema_pkg_apis_meta_v1_UpdateOptions(ref), + "k8s.io/apimachinery/pkg/apis/meta/v1.WatchEvent": schema_pkg_apis_meta_v1_WatchEvent(ref), + "k8s.io/apimachinery/pkg/runtime.RawExtension": schema_k8sio_apimachinery_pkg_runtime_RawExtension(ref), + "k8s.io/apimachinery/pkg/runtime.TypeMeta": schema_k8sio_apimachinery_pkg_runtime_TypeMeta(ref), + "k8s.io/apimachinery/pkg/runtime.Unknown": schema_k8sio_apimachinery_pkg_runtime_Unknown(ref), + "k8s.io/apimachinery/pkg/version.Info": schema_k8sio_apimachinery_pkg_version_Info(ref), } } @@ -153,14 +154,14 @@ func schema_pkg_apis_clusterlink_v1alpha1_Cluster(ref common.ReferenceCallback) SchemaProps: spec.SchemaProps{ Description: "Spec is the specification for the behaviour of the cluster.", Default: map[string]interface{}{}, - Ref: ref("cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterSpec"), + Ref: ref("github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterSpec"), }, }, "status": { SchemaProps: spec.SchemaProps{ Description: "Status describes the current status of a cluster.", Default: map[string]interface{}{}, - Ref: ref("cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterStatus"), + Ref: ref("github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterStatus"), }, }, }, @@ -168,7 +169,7 @@ func schema_pkg_apis_clusterlink_v1alpha1_Cluster(ref common.ReferenceCallback) }, }, Dependencies: []string{ - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterSpec", "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterSpec", "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, } } @@ -205,7 +206,7 @@ func schema_pkg_apis_clusterlink_v1alpha1_ClusterList(ref common.ReferenceCallba Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Cluster"), + Ref: ref("github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Cluster"), }, }, }, @@ -216,7 +217,7 @@ func schema_pkg_apis_clusterlink_v1alpha1_ClusterList(ref common.ReferenceCallba }, }, Dependencies: []string{ - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Cluster", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Cluster", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, } } @@ -249,13 +250,13 @@ func schema_pkg_apis_clusterlink_v1alpha1_ClusterNode(ref common.ReferenceCallba "spec": { SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterNodeSpec"), + Ref: ref("github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterNodeSpec"), }, }, "status": { SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterNodeStatus"), + Ref: ref("github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterNodeStatus"), }, }, }, @@ -263,7 +264,7 @@ func schema_pkg_apis_clusterlink_v1alpha1_ClusterNode(ref common.ReferenceCallba }, }, Dependencies: []string{ - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterNodeSpec", "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterNodeStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterNodeSpec", "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterNodeStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, } } @@ -300,7 +301,7 @@ func schema_pkg_apis_clusterlink_v1alpha1_ClusterNodeList(ref common.ReferenceCa Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterNode"), + Ref: ref("github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterNode"), }, }, }, @@ -311,7 +312,7 @@ func schema_pkg_apis_clusterlink_v1alpha1_ClusterNodeList(ref common.ReferenceCa }, }, Dependencies: []string{ - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterNode", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.ClusterNode", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, } } @@ -445,13 +446,13 @@ func schema_pkg_apis_clusterlink_v1alpha1_ClusterSpec(ref common.ReferenceCallba "localCIDRs": { SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.VxlanCIDRs"), + Ref: ref("github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.VxlanCIDRs"), }, }, "bridgeCIDRs": { SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.VxlanCIDRs"), + Ref: ref("github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.VxlanCIDRs"), }, }, "nicNodeNames": { @@ -461,7 +462,7 @@ func schema_pkg_apis_clusterlink_v1alpha1_ClusterSpec(ref common.ReferenceCallba Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.NICNodeNames"), + Ref: ref("github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.NICNodeNames"), }, }, }, @@ -492,7 +493,7 @@ func schema_pkg_apis_clusterlink_v1alpha1_ClusterSpec(ref common.ReferenceCallba }, }, Dependencies: []string{ - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.NICNodeNames", "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.VxlanCIDRs"}, + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.NICNodeNames", "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.VxlanCIDRs"}, } } @@ -729,13 +730,13 @@ func schema_pkg_apis_clusterlink_v1alpha1_NodeConfig(ref common.ReferenceCallbac "spec": { SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.NodeConfigSpec"), + Ref: ref("github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.NodeConfigSpec"), }, }, "status": { SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.NodeConfigStatus"), + Ref: ref("github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.NodeConfigStatus"), }, }, }, @@ -743,7 +744,7 @@ func schema_pkg_apis_clusterlink_v1alpha1_NodeConfig(ref common.ReferenceCallbac }, }, Dependencies: []string{ - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.NodeConfigSpec", "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.NodeConfigStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.NodeConfigSpec", "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.NodeConfigStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, } } @@ -780,7 +781,7 @@ func schema_pkg_apis_clusterlink_v1alpha1_NodeConfigList(ref common.ReferenceCal Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.NodeConfig"), + Ref: ref("github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.NodeConfig"), }, }, }, @@ -791,7 +792,7 @@ func schema_pkg_apis_clusterlink_v1alpha1_NodeConfigList(ref common.ReferenceCal }, }, Dependencies: []string{ - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.NodeConfig", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.NodeConfig", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, } } @@ -808,7 +809,7 @@ func schema_pkg_apis_clusterlink_v1alpha1_NodeConfigSpec(ref common.ReferenceCal Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Device"), + Ref: ref("github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Device"), }, }, }, @@ -821,7 +822,7 @@ func schema_pkg_apis_clusterlink_v1alpha1_NodeConfigSpec(ref common.ReferenceCal Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Route"), + Ref: ref("github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Route"), }, }, }, @@ -834,7 +835,7 @@ func schema_pkg_apis_clusterlink_v1alpha1_NodeConfigSpec(ref common.ReferenceCal Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Iptables"), + Ref: ref("github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Iptables"), }, }, }, @@ -847,7 +848,7 @@ func schema_pkg_apis_clusterlink_v1alpha1_NodeConfigSpec(ref common.ReferenceCal Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Fdb"), + Ref: ref("github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Fdb"), }, }, }, @@ -860,7 +861,7 @@ func schema_pkg_apis_clusterlink_v1alpha1_NodeConfigSpec(ref common.ReferenceCal Schema: &spec.Schema{ SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Arp"), + Ref: ref("github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Arp"), }, }, }, @@ -870,7 +871,7 @@ func schema_pkg_apis_clusterlink_v1alpha1_NodeConfigSpec(ref common.ReferenceCal }, }, Dependencies: []string{ - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Arp", "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Device", "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Fdb", "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Iptables", "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Route"}, + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Arp", "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Device", "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Fdb", "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Iptables", "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1.Route"}, } } @@ -900,6 +901,27 @@ func schema_pkg_apis_clusterlink_v1alpha1_NodeConfigStatus(ref common.ReferenceC } } +func schema_pkg_apis_clusterlink_v1alpha1_Proxy(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "TypeMeta": { + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.TypeMeta"), + }, + }, + }, + Required: []string{"TypeMeta"}, + }, + }, + Dependencies: []string{ + "k8s.io/apimachinery/pkg/apis/meta/v1.TypeMeta"}, + } +} + func schema_pkg_apis_clusterlink_v1alpha1_Route(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ diff --git a/pkg/network-manager/controller.go b/pkg/network-manager/controller.go index 0060659d6..5aac43dbc 100644 --- a/pkg/network-manager/controller.go +++ b/pkg/network-manager/controller.go @@ -22,8 +22,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - "cnp.io/clusterlink/pkg/network-manager/handlers" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/network-manager/handlers" ) const ( diff --git a/pkg/network-manager/handlers/context.go b/pkg/network-manager/handlers/context.go index b22e469b6..7a6a08fc3 100644 --- a/pkg/network-manager/handlers/context.go +++ b/pkg/network-manager/handlers/context.go @@ -1,8 +1,8 @@ package handlers import ( - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - "cnp.io/clusterlink/pkg/network-manager/helpers" + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/network-manager/helpers" ) // Context Context diff --git a/pkg/network-manager/handlers/host_network.go b/pkg/network-manager/handlers/host_network.go index 701ad1d07..0374dff25 100644 --- a/pkg/network-manager/handlers/host_network.go +++ b/pkg/network-manager/handlers/host_network.go @@ -3,8 +3,8 @@ package handlers import ( "fmt" - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - constants "cnp.io/clusterlink/pkg/network" + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + constants "github.com/kosmos.io/clusterlink/pkg/network" ) type HostNetwork struct { @@ -24,13 +24,13 @@ func (h *HostNetwork) Do(c *Context) (err error) { if c.Filter.SupportIPv4(n) { c.Results[n.Name].Iptables = append(c.Results[n.Name].Iptables, v1alpha1.Iptables{ Table: "nat", - Chain: constants.ClusterLinkPostRoutingChain, + Chain: constants.IPTablesPostRoutingChain, Rule: fmt.Sprintf("-s %s -o %s -j MASQUERADE", cluster.Spec.LocalCIDRs.IP, constants.VXLAN_BRIDGE_NAME), }) c.Results[n.Name].Iptables = append(c.Results[n.Name].Iptables, v1alpha1.Iptables{ Table: "nat", - Chain: constants.ClusterLinkPostRoutingChain, + Chain: constants.IPTablesPostRoutingChain, Rule: fmt.Sprintf("-s %s -j MASQUERADE", cluster.Spec.BridgeCIDRs.IP), }) } @@ -38,13 +38,13 @@ func (h *HostNetwork) Do(c *Context) (err error) { if c.Filter.SupportIPv6(n) { c.Results[n.Name].Iptables = append(c.Results[n.Name].Iptables, v1alpha1.Iptables{ Table: "nat", - Chain: constants.ClusterLinkPostRoutingChain, + Chain: constants.IPTablesPostRoutingChain, Rule: fmt.Sprintf("-s %s -o %s -j MASQUERADE", cluster.Spec.LocalCIDRs.IP6, constants.VXLAN_BRIDGE_NAME_6), }) c.Results[n.Name].Iptables = append(c.Results[n.Name].Iptables, v1alpha1.Iptables{ Table: "nat", - Chain: constants.ClusterLinkPostRoutingChain, + Chain: constants.IPTablesPostRoutingChain, Rule: fmt.Sprintf("-s %s -j MASQUERADE", cluster.Spec.BridgeCIDRs.IP6), }) } diff --git a/pkg/network-manager/handlers/nodeconfig.go b/pkg/network-manager/handlers/nodeconfig.go index 4071d65a6..25e911834 100644 --- a/pkg/network-manager/handlers/nodeconfig.go +++ b/pkg/network-manager/handlers/nodeconfig.go @@ -6,8 +6,8 @@ import ( "encoding/json" "k8s.io/klog/v2" - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - "cnp.io/clusterlink/pkg/network-manager/helpers" + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/network-manager/helpers" ) // NodeConfig network configuration of the node diff --git a/pkg/network-manager/handlers/pod_routes.go b/pkg/network-manager/handlers/pod_routes.go index 35edfa415..636db07da 100644 --- a/pkg/network-manager/handlers/pod_routes.go +++ b/pkg/network-manager/handlers/pod_routes.go @@ -5,9 +5,9 @@ import ( "k8s.io/klog/v2" - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - constants "cnp.io/clusterlink/pkg/network" - "cnp.io/clusterlink/pkg/network-manager/helpers" + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + constants "github.com/kosmos.io/clusterlink/pkg/network" + "github.com/kosmos.io/clusterlink/pkg/network-manager/helpers" ) type PodRoutes struct { diff --git a/pkg/network-manager/handlers/svc_routes.go b/pkg/network-manager/handlers/svc_routes.go index 8a4677ed2..5bfe71658 100644 --- a/pkg/network-manager/handlers/svc_routes.go +++ b/pkg/network-manager/handlers/svc_routes.go @@ -5,9 +5,9 @@ import ( "k8s.io/klog/v2" - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - constants "cnp.io/clusterlink/pkg/network" - "cnp.io/clusterlink/pkg/network-manager/helpers" + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + constants "github.com/kosmos.io/clusterlink/pkg/network" + "github.com/kosmos.io/clusterlink/pkg/network-manager/helpers" ) type ServiceRoutes struct { diff --git a/pkg/network-manager/handlers/vxbridge_mac_cache.go b/pkg/network-manager/handlers/vxbridge_mac_cache.go index e869b4f77..3c7c2ff7b 100644 --- a/pkg/network-manager/handlers/vxbridge_mac_cache.go +++ b/pkg/network-manager/handlers/vxbridge_mac_cache.go @@ -5,8 +5,8 @@ import ( "k8s.io/klog/v2" - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - constants "cnp.io/clusterlink/pkg/network" + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + constants "github.com/kosmos.io/clusterlink/pkg/network" ) type VxBridgeMacCache struct { diff --git a/pkg/network-manager/handlers/vxbridge_network.go b/pkg/network-manager/handlers/vxbridge_network.go index 5a6e99c84..5cea2a52f 100644 --- a/pkg/network-manager/handlers/vxbridge_network.go +++ b/pkg/network-manager/handlers/vxbridge_network.go @@ -1,9 +1,9 @@ package handlers import ( - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - constants "cnp.io/clusterlink/pkg/network" - "cnp.io/clusterlink/pkg/network-manager/helpers" + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + constants "github.com/kosmos.io/clusterlink/pkg/network" + "github.com/kosmos.io/clusterlink/pkg/network-manager/helpers" ) type VxBridgeNetwork struct { @@ -53,7 +53,7 @@ func (h *VxBridgeNetwork) needToCreateVxBridge6(c *Context, clusterNode *v1alpha func (h *VxBridgeNetwork) createVxBridge(c *Context, clusterNode *v1alpha1.ClusterNode, cluster *v1alpha1.Cluster) *v1alpha1.Device { devOld := c.Filter.GetDeviceFromNodeConfig(clusterNode.Name, constants.VXLAN_BRIDGE_NAME) dev := helpers.BuildVxlanDevice(constants.VXLAN_BRIDGE_NAME, clusterNode.Spec.IP, cluster.Spec.BridgeCIDRs.IP, clusterNode.Spec.InterfaceName) - if devOld.Mac != "" { + if devOld != nil && devOld.Mac != "" { dev.Mac = devOld.Mac } return dev @@ -62,7 +62,7 @@ func (h *VxBridgeNetwork) createVxBridge(c *Context, clusterNode *v1alpha1.Clust func (h *VxBridgeNetwork) createVxBridge6(c *Context, clusterNode *v1alpha1.ClusterNode, cluster *v1alpha1.Cluster) *v1alpha1.Device { devOld := c.Filter.GetDeviceFromNodeConfig(clusterNode.Name, constants.VXLAN_BRIDGE_NAME_6) dev := helpers.BuildVxlanDevice(constants.VXLAN_BRIDGE_NAME_6, clusterNode.Spec.IP6, cluster.Spec.BridgeCIDRs.IP6, clusterNode.Spec.InterfaceName) - if devOld.Mac != "" { + if devOld != nil && devOld.Mac != "" { dev.Mac = devOld.Mac } return dev diff --git a/pkg/network-manager/handlers/vxlocal_mac_cache.go b/pkg/network-manager/handlers/vxlocal_mac_cache.go index 389e93d5a..b6a737125 100644 --- a/pkg/network-manager/handlers/vxlocal_mac_cache.go +++ b/pkg/network-manager/handlers/vxlocal_mac_cache.go @@ -5,8 +5,8 @@ import ( "k8s.io/klog/v2" - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - constants "cnp.io/clusterlink/pkg/network" + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + constants "github.com/kosmos.io/clusterlink/pkg/network" ) type VxLocalMacCache struct { diff --git a/pkg/network-manager/handlers/vxlocal_network.go b/pkg/network-manager/handlers/vxlocal_network.go index 5cbfe82db..1612f510b 100644 --- a/pkg/network-manager/handlers/vxlocal_network.go +++ b/pkg/network-manager/handlers/vxlocal_network.go @@ -1,9 +1,9 @@ package handlers import ( - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - constants "cnp.io/clusterlink/pkg/network" - "cnp.io/clusterlink/pkg/network-manager/helpers" + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + constants "github.com/kosmos.io/clusterlink/pkg/network" + "github.com/kosmos.io/clusterlink/pkg/network-manager/helpers" ) type VxLocalNetwork struct { @@ -50,7 +50,7 @@ func (h *VxLocalNetwork) needToCreateVxLocal6(c *Context, clusterNode *v1alpha1. func (h *VxLocalNetwork) createVxLocal(c *Context, clusterNode *v1alpha1.ClusterNode, cluster *v1alpha1.Cluster) *v1alpha1.Device { devOld := c.Filter.GetDeviceFromNodeConfig(clusterNode.Name, constants.VXLAN_LOCAL_NAME) dev := helpers.BuildVxlanDevice(constants.VXLAN_LOCAL_NAME, clusterNode.Spec.IP, cluster.Spec.LocalCIDRs.IP, clusterNode.Spec.InterfaceName) - if devOld.Mac != "" { + if devOld != nil && devOld.Mac != "" { dev.Mac = devOld.Mac } return dev @@ -59,7 +59,7 @@ func (h *VxLocalNetwork) createVxLocal(c *Context, clusterNode *v1alpha1.Cluster func (h *VxLocalNetwork) createVxLocal6(c *Context, clusterNode *v1alpha1.ClusterNode, cluster *v1alpha1.Cluster) *v1alpha1.Device { devOld := c.Filter.GetDeviceFromNodeConfig(clusterNode.Name, constants.VXLAN_LOCAL_NAME_6) dev := helpers.BuildVxlanDevice(constants.VXLAN_LOCAL_NAME_6, clusterNode.Spec.IP6, cluster.Spec.LocalCIDRs.IP6, clusterNode.Spec.InterfaceName) - if devOld.Mac != "" { + if devOld != nil && devOld.Mac != "" { dev.Mac = devOld.Mac } return dev diff --git a/pkg/network-manager/helpers/filter.go b/pkg/network-manager/helpers/filter.go index 7d766cbe1..d5103c630 100644 --- a/pkg/network-manager/helpers/filter.go +++ b/pkg/network-manager/helpers/filter.go @@ -3,7 +3,7 @@ package helpers import ( "reflect" - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" ) type Filter struct { diff --git a/pkg/network-manager/helpers/network.go b/pkg/network-manager/helpers/network.go index 422194540..3ac6939f1 100644 --- a/pkg/network-manager/helpers/network.go +++ b/pkg/network-manager/helpers/network.go @@ -8,8 +8,8 @@ import ( "k8s.io/klog/v2" - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - constants "cnp.io/clusterlink/pkg/network" + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + constants "github.com/kosmos.io/clusterlink/pkg/network" ) type IPType int @@ -40,7 +40,7 @@ func GenerateMac() net.HardwareAddr { } // Set the local bit - buf[0] |= 2 + buf[0] = (buf[0] | 2) & 0xfe mac = append(mac, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]) return mac diff --git a/pkg/network-manager/helpers/sort.go b/pkg/network-manager/helpers/sort.go index 65c774f7e..646c50d5c 100644 --- a/pkg/network-manager/helpers/sort.go +++ b/pkg/network-manager/helpers/sort.go @@ -3,7 +3,7 @@ package helpers import ( "encoding/json" - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" ) // RouteSorter sorts routes. diff --git a/pkg/network-manager/network_manager.go b/pkg/network-manager/network_manager.go index c9c2a64e0..329fb0353 100644 --- a/pkg/network-manager/network_manager.go +++ b/pkg/network-manager/network_manager.go @@ -6,9 +6,9 @@ import ( "k8s.io/klog/v2" - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - "cnp.io/clusterlink/pkg/network-manager/handlers" - "cnp.io/clusterlink/pkg/network-manager/helpers" + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/network-manager/handlers" + "github.com/kosmos.io/clusterlink/pkg/network-manager/helpers" ) type Manager struct { diff --git a/pkg/network/adapter.go b/pkg/network/adapter.go index 165e42d8a..a714d2117 100644 --- a/pkg/network/adapter.go +++ b/pkg/network/adapter.go @@ -3,7 +3,7 @@ package network import ( "fmt" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" "github.com/pkg/errors" ) diff --git a/pkg/network/arp.go b/pkg/network/arp.go index 4c9229c25..2b1e264f8 100644 --- a/pkg/network/arp.go +++ b/pkg/network/arp.go @@ -1,7 +1,7 @@ package network import ( - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" ) func AddARP(ip string, mac string, devName string) error { diff --git a/pkg/network/arp_test.go b/pkg/network/arp_test.go index 6a7712cb4..25b896e1b 100644 --- a/pkg/network/arp_test.go +++ b/pkg/network/arp_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" ) func TestArps(t *testing.T) { diff --git a/pkg/network/constant.go b/pkg/network/constant.go index 2b678c907..bc2d2e3e3 100644 --- a/pkg/network/constant.go +++ b/pkg/network/constant.go @@ -69,6 +69,9 @@ const ( ClusterLinkPreRoutingChain = "CLUSTERLINK-PREROUTING" ClusterLinkPostRoutingChain = "CLUSTERLINK-POSTROUTING" + + IPTablesPreRoutingChain = "PREROUTING" + IPTablesPostRoutingChain = "POSTROUTING" ) type vxlanAttributes struct { diff --git a/pkg/network/device.go b/pkg/network/device.go index 3e5372438..352a68c33 100644 --- a/pkg/network/device.go +++ b/pkg/network/device.go @@ -5,8 +5,8 @@ import ( "net" "syscall" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - "cnp.io/clusterlink/pkg/utils" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/utils" "github.com/pkg/errors" "github.com/vishvananda/netlink" "golang.org/x/sys/unix" @@ -17,7 +17,8 @@ type IfaceInfo struct { MTU int name string // index int - ip string + ip string + ip6 string } func getIfaceIPByName(name string) (*IfaceInfo, error) { @@ -37,21 +38,21 @@ func getIfaceIPByName(name string) (*IfaceInfo, error) { devIface.ip = addrListV4 } else { klog.Infof("Try to retrieve addr v4 list of device %s, get error: %v", name, err) - addrListV6, err := getFristScopeIPInLink(iface, name, netlink.FAMILY_V6) - if err != nil { - klog.Errorf("Try to retrieve addr v6 list of device %s, get error: %v", name, err) - return nil, fmt.Errorf("cannot get device ip, device name is : %s", name) - } else { - devIface.ip = addrListV6 - } + } + + addrListV6, err := getFristScopeIPInLink(iface, name, netlink.FAMILY_V6) + if err == nil { + devIface.ip6 = addrListV6 + } else { + klog.Infof("Try to retrieve addr v6 list of device %s, get error: %v", name, err) } return devIface, nil } -func createNewVxlanIface(name string, addrIPWithMask *netlink.Addr, vxlanId int, vxlanPort int, hardwareAddr net.HardwareAddr, rIface *IfaceInfo) error { - srcAddr := rIface.ip +func createNewVxlanIface(name string, addrIPWithMask *netlink.Addr, vxlanId int, vxlanPort int, hardwareAddr net.HardwareAddr, rIface *IfaceInfo, deviceIP string) error { + // srcAddr := rIface.ip - klog.Infof("name %v ------------------------- %v", name, srcAddr) + klog.Infof("name %v ------------------------- %v", name, deviceIP) iface := &netlink.Vxlan{ LinkAttrs: netlink.LinkAttrs{ Name: name, @@ -59,7 +60,7 @@ func createNewVxlanIface(name string, addrIPWithMask *netlink.Addr, vxlanId int, Flags: net.FlagUp, HardwareAddr: hardwareAddr, }, - SrcAddr: net.ParseIP(srcAddr), + SrcAddr: net.ParseIP(deviceIP), VxlanId: vxlanId, Port: vxlanPort, Learning: false, @@ -77,7 +78,7 @@ func createNewVxlanIface(name string, addrIPWithMask *netlink.Addr, vxlanId int, } // create rule table family := netlink.FAMILY_V4 - if utils.IsIPv6(srcAddr) { + if utils.IsIPv6(deviceIP) { family = netlink.FAMILY_V6 } err = ruleAddIfNotPresent(newTableRule(TABLE_ID, family)) @@ -175,7 +176,8 @@ func loadDevices() ([]clusterlinkv1alpha1.Device, error) { } if interfaceIndex == -1 { - return nil, fmt.Errorf("can not find the dev for vxlan, name: %s", d.name) + klog.Warning("can not find the dev for vxlan, name: %s", d.name) + continue } defaultIface, err := netlink.LinkByIndex(interfaceIndex) @@ -226,17 +228,19 @@ func addDevice(d clusterlinkv1alpha1.Device) error { return errors.Wrap(err, "add device failed when translate mac") } - if err = createNewVxlanIface(d.Name, addrIPvWithMask, id, port, hardwareAddr, currentIfaceInfo); err != nil { - klog.Errorf("ipv4 err: %v", err) - return err - } - klog.Infof("add vxlan %v %v", d.Name, currentIfaceInfo.ip) - + deviceIP := currentIfaceInfo.ip family := netlink.FAMILY_V4 - if utils.IsIPv6(currentIfaceInfo.ip) { + if utils.IsIPv6(cidrip.String()) { + deviceIP = currentIfaceInfo.ip6 family = netlink.FAMILY_V6 } + if err = createNewVxlanIface(d.Name, addrIPvWithMask, id, port, hardwareAddr, currentIfaceInfo, deviceIP); err != nil { + klog.Errorf("ipv4 err: %v", err) + return err + } + klog.Infof("add vxlan %v %v", d.Name, deviceIP) + if err := UpdateDefaultIptablesAndKernalConfig(d.BindDev, family); err != nil { return err } diff --git a/pkg/network/device_test.go b/pkg/network/device_test.go index 708c31052..ccd32e213 100644 --- a/pkg/network/device_test.go +++ b/pkg/network/device_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" ) func TestDevice(t *testing.T) { diff --git a/pkg/network/env.go b/pkg/network/env.go index a6e0bec72..60574a5b4 100644 --- a/pkg/network/env.go +++ b/pkg/network/env.go @@ -4,8 +4,8 @@ import ( "bytes" "os" - "cnp.io/clusterlink/pkg/network/iptables" ipt "github.com/coreos/go-iptables/iptables" + "github.com/kosmos.io/clusterlink/pkg/network/iptables" "github.com/pkg/errors" ) diff --git a/pkg/network/fdb.go b/pkg/network/fdb.go index f761bc20f..c90b9a9da 100644 --- a/pkg/network/fdb.go +++ b/pkg/network/fdb.go @@ -1,6 +1,6 @@ package network -import clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" +import clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" type FDBRecord struct { IP string diff --git a/pkg/network/fdb_test.go b/pkg/network/fdb_test.go index 3d07e4466..a326f0343 100644 --- a/pkg/network/fdb_test.go +++ b/pkg/network/fdb_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" ) func TestFdbs(t *testing.T) { diff --git a/pkg/network/interface.go b/pkg/network/interface.go index 3da78f5da..74e069cc5 100644 --- a/pkg/network/interface.go +++ b/pkg/network/interface.go @@ -3,7 +3,7 @@ package network import ( "errors" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" ) var ( diff --git a/pkg/network/iptables.go b/pkg/network/iptables.go index e2071bdd5..bcc38589d 100644 --- a/pkg/network/iptables.go +++ b/pkg/network/iptables.go @@ -8,8 +8,8 @@ import ( "github.com/pkg/errors" "k8s.io/klog/v2" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - "cnp.io/clusterlink/pkg/network/iptables" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/network/iptables" ) type IptablesRecord struct { diff --git a/pkg/network/iptables_test.go b/pkg/network/iptables_test.go index aee18e69e..f044979d7 100644 --- a/pkg/network/iptables_test.go +++ b/pkg/network/iptables_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" ) func TestIptables(t *testing.T) { diff --git a/pkg/network/route.go b/pkg/network/route.go index 68165f76f..3b8ee8ec2 100644 --- a/pkg/network/route.go +++ b/pkg/network/route.go @@ -4,7 +4,7 @@ import ( "net" "os" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" "github.com/pkg/errors" "github.com/vishvananda/netlink" "k8s.io/klog/v2" diff --git a/pkg/network/route_test.go b/pkg/network/route_test.go index aa126e86c..044fd64fe 100644 --- a/pkg/network/route_test.go +++ b/pkg/network/route_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" ) // go test . -run TestRoute diff --git a/pkg/operator/addons/agent/agent.go b/pkg/operator/addons/agent/agent.go index 0ec71d3f8..404b11a83 100644 --- a/pkg/operator/addons/agent/agent.go +++ b/pkg/operator/addons/agent/agent.go @@ -15,14 +15,14 @@ import ( bootstrapapi "k8s.io/cluster-bootstrap/token/api" "k8s.io/klog/v2" - "cnp.io/clusterlink/pkg/operator/addons/option" - "cnp.io/clusterlink/pkg/operator/addons/utils" - cmdutil "cnp.io/clusterlink/pkg/operator/util" + "github.com/kosmos.io/clusterlink/pkg/operator/addons/option" + "github.com/kosmos.io/clusterlink/pkg/operator/addons/utils" + cmdutil "github.com/kosmos.io/clusterlink/pkg/operator/util" + utils2 "github.com/kosmos.io/clusterlink/pkg/utils" ) const ( - ResourceName = "clusterlink-agent" - ProxyConfigMapName = "clusterlink-agent-proxy" + ResourceName = "clusterlink-agent" ) type AgentInstaller struct { @@ -38,7 +38,7 @@ func applyDaemonSet(opt *option.AddonOption) error { Namespace: opt.GetSpecNamespace(), Name: ResourceName, ImageRepository: opt.GetImageRepository(), - ProxyConfigMapName: ProxyConfigMapName, + ProxyConfigMapName: utils2.ProxySecretName, Version: opt.Version, ClusterName: opt.GetName(), }) @@ -66,7 +66,10 @@ func applyDaemonSet(opt *option.AddonOption) error { return nil } -func applyConfigMap(opt *option.AddonOption) error { +func applySecret(opt *option.AddonOption) error { + if opt.UseProxy { + return nil + } if err := clientcmdapi.FlattenConfig(opt.ControlPanelKubeConfig); err != nil { return err } @@ -86,15 +89,15 @@ func applyConfigMap(opt *option.AddonOption) error { return err } - // Create or update the ConfigMap in the kube-public namespace - klog.Infof("[bootstrap-token] creating/updating ConfigMap in kube-public namespace") + // Create or update the Secret in the kube-public namespace + klog.Infof("[bootstrap-token] creating/updating Secret in kube-public namespace") - return cmdutil.CreateOrUpdateConfigMap(opt.KubeClientSet, &corev1.ConfigMap{ + return cmdutil.CreateOrUpdateSecret(opt.KubeClientSet, &corev1.Secret{ ObjectMeta: metav1.ObjectMeta{ - Name: ProxyConfigMapName, + Name: utils2.ProxySecretName, Namespace: opt.GetSpecNamespace(), }, - Data: map[string]string{ + StringData: map[string]string{ bootstrapapi.KubeConfigKey: string(bootstrapBytes), }, }) @@ -102,7 +105,7 @@ func applyConfigMap(opt *option.AddonOption) error { // Install resources related to CR:cluster func (i *AgentInstaller) Install(opt *option.AddonOption) error { - if err := applyConfigMap(opt); err != nil { + if err := applySecret(opt); err != nil { return err } if err := applyDaemonSet(opt); err != nil { @@ -121,7 +124,7 @@ func (i *AgentInstaller) Uninstall(opt *option.AddonOption) error { } configMapClient := opt.KubeClientSet.CoreV1().ConfigMaps(opt.GetSpecNamespace()) - if err := configMapClient.Delete(context.TODO(), ProxyConfigMapName, metav1.DeleteOptions{}); err != nil && !apierrors.IsNotFound(err) { + if err := configMapClient.Delete(context.TODO(), utils2.ProxySecretName, metav1.DeleteOptions{}); err != nil && !apierrors.IsNotFound(err) { return err } diff --git a/pkg/operator/addons/agent/manifests.go b/pkg/operator/addons/agent/manifests.go index 9c188c7c3..cbece3802 100644 --- a/pkg/operator/addons/agent/manifests.go +++ b/pkg/operator/addons/agent/manifests.go @@ -60,9 +60,8 @@ spec: hostNetwork: true volumes: - name: proxy-config - configMap: - defaultMode: 420 - name: {{ .ProxyConfigMapName }} + secret: + secretName: {{ .ProxyConfigMapName }} ` diff --git a/pkg/operator/addons/elector/elector.go b/pkg/operator/addons/elector/elector.go index ae0336b96..8cca87909 100644 --- a/pkg/operator/addons/elector/elector.go +++ b/pkg/operator/addons/elector/elector.go @@ -3,6 +3,7 @@ package elector import ( "context" "fmt" + utils2 "github.com/kosmos.io/clusterlink/pkg/utils" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -13,14 +14,13 @@ import ( clientsetscheme "k8s.io/client-go/kubernetes/scheme" "k8s.io/klog/v2" - "cnp.io/clusterlink/pkg/operator/addons/option" - "cnp.io/clusterlink/pkg/operator/addons/utils" - cmdutil "cnp.io/clusterlink/pkg/operator/util" + "github.com/kosmos.io/clusterlink/pkg/operator/addons/option" + "github.com/kosmos.io/clusterlink/pkg/operator/addons/utils" + cmdutil "github.com/kosmos.io/clusterlink/pkg/operator/util" ) const ( - ResourceName = "clusterlink-elector" - ProxyConfigMapName = "clusterlink-agent-proxy" + ResourceName = "clusterlink-elector" ) type ElectorInstaller struct { @@ -64,7 +64,7 @@ func applyDeployment(opt *option.AddonOption) error { Name: ResourceName, ClusterName: opt.GetName(), ImageRepository: opt.GetImageRepository(), - ProxyConfigMapName: ProxyConfigMapName, + ProxyConfigMapName: utils2.ProxySecretName, Version: opt.Version, }) diff --git a/pkg/operator/addons/elector/manifests.go b/pkg/operator/addons/elector/manifests.go index 91f57abee..325503d5e 100644 --- a/pkg/operator/addons/elector/manifests.go +++ b/pkg/operator/addons/elector/manifests.go @@ -58,9 +58,8 @@ spec: effect: "NoSchedule" volumes: - name: proxy-config - configMap: - defaultMode: 420 - name: {{ .ProxyConfigMapName }} + secret: + secretName: {{ .ProxyConfigMapName }} ` type DeploymentReplace struct { diff --git a/pkg/operator/addons/global/global.go b/pkg/operator/addons/global/global.go index 93d55b084..5538cc2a1 100644 --- a/pkg/operator/addons/global/global.go +++ b/pkg/operator/addons/global/global.go @@ -8,9 +8,9 @@ import ( clientsetscheme "k8s.io/client-go/kubernetes/scheme" "k8s.io/klog/v2" - "cnp.io/clusterlink/pkg/operator/addons/option" - "cnp.io/clusterlink/pkg/operator/addons/utils" - cmdutil "cnp.io/clusterlink/pkg/operator/util" + "github.com/kosmos.io/clusterlink/pkg/operator/addons/option" + "github.com/kosmos.io/clusterlink/pkg/operator/addons/utils" + cmdutil "github.com/kosmos.io/clusterlink/pkg/operator/util" ) type Installer struct { diff --git a/pkg/operator/addons/install.go b/pkg/operator/addons/install.go index c904c4f24..77932e098 100644 --- a/pkg/operator/addons/install.go +++ b/pkg/operator/addons/install.go @@ -1,13 +1,14 @@ package addons import ( + "github.com/kosmos.io/clusterlink/pkg/operator/addons/global" + "github.com/kosmos.io/clusterlink/pkg/operator/addons/proxy" "k8s.io/klog/v2" - "cnp.io/clusterlink/pkg/operator/addons/agent" - "cnp.io/clusterlink/pkg/operator/addons/elector" - "cnp.io/clusterlink/pkg/operator/addons/global" - "cnp.io/clusterlink/pkg/operator/addons/manager" - "cnp.io/clusterlink/pkg/operator/addons/option" + "github.com/kosmos.io/clusterlink/pkg/operator/addons/agent" + "github.com/kosmos.io/clusterlink/pkg/operator/addons/elector" + "github.com/kosmos.io/clusterlink/pkg/operator/addons/manager" + "github.com/kosmos.io/clusterlink/pkg/operator/addons/option" ) type AddonInstaller interface { @@ -16,7 +17,7 @@ type AddonInstaller interface { } var ( - installers = []AddonInstaller{global.New(), agent.New(), elector.New(), manager.New()} // proxy.New() + installers = []AddonInstaller{global.New(), proxy.New(), agent.New(), elector.New(), manager.New()} ) func Install(opt *option.AddonOption) error { diff --git a/pkg/operator/addons/manager/manager.go b/pkg/operator/addons/manager/manager.go index 5c8249691..3a9081df5 100644 --- a/pkg/operator/addons/manager/manager.go +++ b/pkg/operator/addons/manager/manager.go @@ -3,6 +3,7 @@ package manager import ( "context" "fmt" + utils2 "github.com/kosmos.io/clusterlink/pkg/utils" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -14,9 +15,9 @@ import ( clientsetscheme "k8s.io/client-go/kubernetes/scheme" "k8s.io/klog/v2" - "cnp.io/clusterlink/pkg/operator/addons/option" - "cnp.io/clusterlink/pkg/operator/addons/utils" - cmdutil "cnp.io/clusterlink/pkg/operator/util" + "github.com/kosmos.io/clusterlink/pkg/operator/addons/option" + "github.com/kosmos.io/clusterlink/pkg/operator/addons/utils" + cmdutil "github.com/kosmos.io/clusterlink/pkg/operator/util" ) type ManagerInstaller struct { @@ -27,44 +28,13 @@ func New() *ManagerInstaller { } const ( - ResourceName = "clusterlink-controller-manager" - ProxyConfigMapName = "clusterlink-agent-proxy" + ResourceName = "clusterlink-controller-manager" ) var ( clusterClientSet *kubernetes.Clientset ) -/* -func getHostClient(opt *option.AddonOption) (*kubernetes.Clientset, error) { - // opt.ControlPanelKubeConfig - if clusterClientSet == nil { - bootstrapBytes, err := clientcmd.Write(*opt.ControlPanelKubeConfig) - if err != nil { - return nil, err - } - - clientconfig, err := clientcmd.NewClientConfigFromBytes(bootstrapBytes) - if err != nil { - return nil, err - } - - config, err := clientconfig.ClientConfig() - if err != nil { - return nil, err - } - - // clientcmd.(*opt.ControlPanelKubeConfig) - clusterClientSet, err = kubernetes.NewForConfig(config) - if err != nil { - return nil, err - } - } - - return clusterClientSet, nil -} -*/ - func applyServiceAccount(opt *option.AddonOption) error { clCtrManagerServiceAccountBytes, err := utils.ParseTemplate(clusterlinkManagerServiceAccount, ServiceAccountReplace{ Namespace: opt.GetSpecNamespace(), @@ -93,7 +63,7 @@ func applyDeployment(opt *option.AddonOption) error { clCtrManagerDeploymentBytes, err := utils.ParseTemplate(clusterlinkManagerDeployment, DeploymentReplace{ Namespace: opt.GetSpecNamespace(), Name: ResourceName, - ProxyConfigMapName: ProxyConfigMapName, + ProxyConfigMapName: utils2.ProxySecretName, ClusterName: opt.GetName(), ImageRepository: opt.GetImageRepository(), Version: opt.Version, diff --git a/pkg/operator/addons/manager/manifests.go b/pkg/operator/addons/manager/manifests.go index d73bc2224..b8871614e 100644 --- a/pkg/operator/addons/manager/manifests.go +++ b/pkg/operator/addons/manager/manifests.go @@ -14,7 +14,7 @@ type ServiceAccountReplace struct { } const clusterlinkManagerDeployment = ` -aapiVersion: apps/v1 +apiVersion: apps/v1 kind: Deployment metadata: name: {{ .Name }} @@ -55,10 +55,8 @@ spec: readOnly: true volumes: - name: proxy-config - configMap: - defaultMode: 420 - name: {{ .ProxyConfigMapName }} - + secret: + secretName: {{ .ProxyConfigMapName }} ` type DeploymentReplace struct { diff --git a/pkg/operator/addons/option/option.go b/pkg/operator/addons/option/option.go index 70a3013a0..e263b51f8 100644 --- a/pkg/operator/addons/option/option.go +++ b/pkg/operator/addons/option/option.go @@ -9,9 +9,9 @@ import ( "k8s.io/client-go/kubernetes" "k8s.io/client-go/tools/clientcmd" - cmdOptions "cnp.io/clusterlink/cmd/operator/app/options" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - "cnp.io/clusterlink/pkg/version" + cmdOptions "github.com/kosmos.io/clusterlink/cmd/operator/app/options" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/version" ) // AddonOption for cluster @@ -20,6 +20,7 @@ type AddonOption struct { KubeClientSet *kubernetes.Clientset ControlPanelKubeConfig *clientcmdapi.Config Version string + UseProxy bool } func (o *AddonOption) buildClusterConfig(opts *cmdOptions.Options) error { diff --git a/pkg/operator/addons/proxy/manifests.go b/pkg/operator/addons/proxy/manifests.go new file mode 100644 index 000000000..08da01a35 --- /dev/null +++ b/pkg/operator/addons/proxy/manifests.go @@ -0,0 +1,75 @@ +package proxy + +const clusterlinkProxyService = ` +apiVersion: v1 +kind: Service +metadata: + name: {{ .Name }} + namespace: {{ .Namespace }} +spec: + selector: + app: clusterlink-proxy + ports: + - protocol: TCP + port: 443 + targetPort: 443 + type: ClusterIP +` + +type ServiceReplace struct { + Namespace string + Name string +} + +const clusterlinkProxyDeployment = ` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Name }} + namespace: {{ .Namespace }} + labels: + app: clusterlink-proxy +spec: + replicas: 1 + selector: + matchLabels: + app: clusterlink-proxy + template: + metadata: + labels: + app: clusterlink-proxy + spec: + containers: + - name: manager + image: {{ .ImageRepository }}/clusterlink-proxy:{{ .Version }} + imagePullPolicy: IfNotPresent + command: + - clusterlink-proxy + - --kubeconfig=/etc/clusterlink/kubeconfig + - --authentication-kubeconfig=/etc/clusterlink/kubeconfig + - --authorization-kubeconfig=/etc/clusterlink/kubeconfig + resources: + limits: + memory: 500Mi + cpu: 500m + requests: + cpu: 500m + memory: 500Mi + volumeMounts: + - mountPath: /etc/clusterlink + name: proxy-config + readOnly: true + volumes: + - name: proxy-config + secret: + secretName: {{ .ControlPanelSecretName }} + +` + +type DeploymentReplace struct { + Namespace string + Name string + ControlPanelSecretName string + ImageRepository string + Version string +} diff --git a/pkg/operator/addons/proxy/proxy.go b/pkg/operator/addons/proxy/proxy.go new file mode 100644 index 000000000..a73892dbd --- /dev/null +++ b/pkg/operator/addons/proxy/proxy.go @@ -0,0 +1,161 @@ +package proxy + +import ( + "context" + "errors" + "fmt" + utils2 "github.com/kosmos.io/clusterlink/pkg/utils" + "k8s.io/client-go/tools/clientcmd" + + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + kuberuntime "k8s.io/apimachinery/pkg/runtime" + "k8s.io/client-go/kubernetes" + clientsetscheme "k8s.io/client-go/kubernetes/scheme" + "k8s.io/klog/v2" + + "github.com/kosmos.io/clusterlink/pkg/operator/addons/option" + "github.com/kosmos.io/clusterlink/pkg/operator/addons/utils" + cmdutil "github.com/kosmos.io/clusterlink/pkg/operator/util" +) + +type ProxyInstaller struct { +} + +func New() *ProxyInstaller { + return &ProxyInstaller{} +} + +const ( + ResourceName = "clusterlink-proxy" +) + +var ( + clusterClientSet *kubernetes.Clientset +) + +func applySecret(opt *option.AddonOption) error { + if opt.ControlPanelKubeConfig == nil { + return errors.New("ControlPanelKubeConfig must not nil") + } + + c := opt.ControlPanelKubeConfig.DeepCopy() + url := fmt.Sprintf("https://%s:443/apis/clusterlink.io/v1alpha1/proxying", ResourceName) + klog.Infof("proxy access url is %s", url) + for i := range c.Clusters { + c.Clusters[i].Server = url + } + b, err := clientcmd.Write(*c) + if err != nil { + klog.Errorf("write ControlPanelKubeConfig to byte err: %v") + return err + } + secret := &corev1.Secret{ + ObjectMeta: metav1.ObjectMeta{ + Name: utils2.ProxySecretName, + Namespace: opt.GetSpecNamespace(), + }, + Data: map[string][]byte{ + "kubeconfig": b, + }, + } + + if err := cmdutil.CreateOrUpdateSecret(opt.KubeClientSet, secret); err != nil { + return fmt.Errorf("create clusterlink agent secret error: %v", err) + } + + return nil + +} + +func applyService(opt *option.AddonOption) error { + proxyServiceBytes, err := utils.ParseTemplate(clusterlinkProxyService, ServiceReplace{ + Namespace: opt.GetSpecNamespace(), + Name: ResourceName, + }) + + if err != nil { + return fmt.Errorf("error when parsing clusterlink controller-manager serviceaccount template :%v", err) + } + + proxyService := &corev1.Service{} + if err := kuberuntime.DecodeInto(clientsetscheme.Codecs.UniversalDecoder(), proxyServiceBytes, proxyService); err != nil { + return fmt.Errorf("decode controller-proxy service error: %v", err) + } + + if err := cmdutil.CreateOrUpdateService(opt.KubeClientSet, proxyService); err != nil { + return fmt.Errorf("create clusterlink-proxy service error: %v", err) + } + + // TODO: wati + + return nil +} + +func applyDeployment(opt *option.AddonOption) error { + proxyDeploymentBytes, err := utils.ParseTemplate(clusterlinkProxyDeployment, DeploymentReplace{ + Namespace: opt.GetSpecNamespace(), + Name: ResourceName, + ControlPanelSecretName: utils2.ControlPanelSecretName, + ImageRepository: opt.GetImageRepository(), + Version: opt.Version, + }) + + if err != nil { + return fmt.Errorf("error when parsing clusterlink-proxy deployment template :%v", err) + } + + proxyDeployment := &appsv1.Deployment{} + + if err := kuberuntime.DecodeInto(clientsetscheme.Codecs.UniversalDecoder(), proxyDeploymentBytes, proxyDeployment); err != nil { + return fmt.Errorf("decode clusterlink-proxy deployment error: %v", err) + } + + if err := cmdutil.CreateOrUpdateDeployment(opt.KubeClientSet, proxyDeployment); err != nil { + return fmt.Errorf("create controller-proxy deployment error: %v", err) + } + + // TODO: wati + + return nil +} + +// Install resources related to CR:cluster +func (i *ProxyInstaller) Install(opt *option.AddonOption) error { + if !opt.UseProxy { + return nil + } + klog.Infof("deploying proxy...") + + if err := applySecret(opt); err != nil { + return err + } + + if err := applyDeployment(opt); err != nil { + return err + } + + if err := applyService(opt); err != nil { + return err + } + + return nil +} + +// Uninstall resources related to CR:cluster +func (i *ProxyInstaller) Uninstall(opt *option.AddonOption) error { + deploymentClient := opt.KubeClientSet.AppsV1().Deployments(opt.GetSpecNamespace()) + if err := deploymentClient.Delete(context.TODO(), ResourceName, metav1.DeleteOptions{}); err != nil && !apierrors.IsNotFound(err) { + return err + } + + serviceClient := opt.KubeClientSet.CoreV1().Services(opt.GetSpecNamespace()) + if err := serviceClient.Delete(context.TODO(), ResourceName, metav1.DeleteOptions{}); err != nil && !apierrors.IsNotFound(err) { + return err + } + + klog.Infof("Uninstall clusterlink service on cluster successfully") + return nil +} diff --git a/pkg/operator/operator_controller.go b/pkg/operator/operator_controller.go index 7a3864ba5..615951374 100644 --- a/pkg/operator/operator_controller.go +++ b/pkg/operator/operator_controller.go @@ -2,11 +2,12 @@ package operator import ( "context" - - clientcmdapi "k8s.io/client-go/tools/clientcmd/api" + "os" + "strconv" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" + clientcmdapi "k8s.io/client-go/tools/clientcmd/api" "k8s.io/klog/v2" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" @@ -15,11 +16,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" - cmdOptions "cnp.io/clusterlink/cmd/operator/app/options" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - clusterlinkv1alpha1lister "cnp.io/clusterlink/pkg/generated/listers/clusterlink/v1alpha1" - "cnp.io/clusterlink/pkg/operator/addons" - "cnp.io/clusterlink/pkg/operator/addons/option" + cmdOptions "github.com/kosmos.io/clusterlink/cmd/operator/app/options" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + clusterlinkv1alpha1lister "github.com/kosmos.io/clusterlink/pkg/generated/listers/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/operator/addons" + "github.com/kosmos.io/clusterlink/pkg/operator/addons/option" + "github.com/kosmos.io/clusterlink/pkg/utils" ) const ( @@ -52,9 +54,18 @@ func (r *Reconciler) SetupWithManager(mgr manager.Manager) error { func (r *Reconciler) syncCluster(cluster *clusterlinkv1alpha1.Cluster) (reconcile.Result, error) { klog.Infof("install agent") + useProxy := r.Options.UseProxy + if value, exist := os.LookupEnv(utils.EnvUseProxy); exist { + boo, err := strconv.ParseBool(value) + if err != nil { + klog.Warningf("parse env %s to bool err: %v", utils.EnvUseProxy, err) + } + useProxy = boo + } opt := &option.AddonOption{ Cluster: *cluster, ControlPanelKubeConfig: r.ControlPanelKubeConfig, + UseProxy: useProxy, } if err := opt.Complete(r.Options); err != nil { @@ -136,7 +147,9 @@ func (r *Reconciler) Reconcile(ctx context.Context, request reconcile.Request) ( } if !cluster.DeletionTimestamp.IsZero() { - return r.removeCluster(cluster) + if len(cluster.GetFinalizers()) == 1 { + return r.removeCluster(cluster) + } } return r.syncCluster(cluster) diff --git a/pkg/proxy/apiserver.go b/pkg/proxy/apiserver.go index cb96f1bf2..42730c7b7 100644 --- a/pkg/proxy/apiserver.go +++ b/pkg/proxy/apiserver.go @@ -9,8 +9,8 @@ import ( "k8s.io/client-go/dynamic" clientrest "k8s.io/client-go/rest" - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - "cnp.io/clusterlink/pkg/scheme" + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/scheme" ) var ( diff --git a/pkg/proxy/storage.go b/pkg/proxy/storage.go index e3fc5bcea..2273f5123 100644 --- a/pkg/proxy/storage.go +++ b/pkg/proxy/storage.go @@ -28,12 +28,12 @@ import ( clientrest "k8s.io/client-go/rest" "sigs.k8s.io/controller-runtime/pkg/client/apiutil" - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - "cnp.io/clusterlink/pkg/proxy/store" - "cnp.io/clusterlink/pkg/utils/lifted" + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/proxy/store" + "github.com/kosmos.io/clusterlink/pkg/utils/lifted" ) -var supportMethods = []string{"GET", "POST", "PUT", "PATCH", "HEAD", "OPTIONS"} +var supportMethods = []string{"GET", "DELETE", "POST", "PUT", "PATCH", "HEAD", "OPTIONS"} type REST struct { store store.Store @@ -104,6 +104,12 @@ func (rest *REST) createHandler(ctx context.Context, minRequestTimeout time.Dura Version: requestInfo.APIVersion, Resource: requestInfo.Resource, } + + if gvr.Group == "" && gvr.Resource == "" { + proxyHandler.ServeHTTP(w, req) + return + } + r := &rester{ store: rest.store, gvr: gvr, diff --git a/pkg/proxy/store/cluster_cache.go b/pkg/proxy/store/cluster_cache.go index cbc10afc8..fe0c41650 100644 --- a/pkg/proxy/store/cluster_cache.go +++ b/pkg/proxy/store/cluster_cache.go @@ -17,9 +17,9 @@ import ( "k8s.io/klog/v2" ) -// Store is the cache for resources from multiple member clusters +// Store is the cache for resources from controlpanel type Store interface { - UpdateCache(resourcesByCluster map[schema.GroupVersionResource]struct{}) error + UpdateCache(resources map[schema.GroupVersionResource]struct{}) error GetResourceFromCache(ctx context.Context, gvr schema.GroupVersionResource, namespace, name string) (runtime.Object, string, error) Stop() @@ -28,19 +28,19 @@ type Store interface { Watch(ctx context.Context, gvr schema.GroupVersionResource, options *metainternalversion.ListOptions) (watch.Interface, error) } -var _ Store = &ClusterCache{} +var _ Store = &Cache{} -// ClusterCache caches resources for single member cluster -type ClusterCache struct { +// Cache caches resources +type Cache struct { lock sync.RWMutex cache map[schema.GroupVersionResource]*resourceCache restMapper meta.RESTMapper client dynamic.Interface } -func NewClusterCache(client dynamic.Interface, restMapper meta.RESTMapper) *ClusterCache { +func NewClusterCache(client dynamic.Interface, restMapper meta.RESTMapper) *Cache { // TODO add controller dynamic add clusterlink crd - cache := &ClusterCache{ + cache := &Cache{ client: client, restMapper: restMapper, cache: map[schema.GroupVersionResource]*resourceCache{}, @@ -48,6 +48,7 @@ func NewClusterCache(client dynamic.Interface, restMapper meta.RESTMapper) *Clus resources := map[schema.GroupVersionResource]struct{}{ schema.GroupVersionResource{Group: "clusterlink.io", Version: "v1alpha1", Resource: "clusters"}: {}, schema.GroupVersionResource{Group: "clusterlink.io", Version: "v1alpha1", Resource: "clusternodes"}: {}, + schema.GroupVersionResource{Group: "clusterlink.io", Version: "v1alpha1", Resource: "nodeconfigs"}: {}, } err := cache.UpdateCache(resources) if err != nil { @@ -56,7 +57,7 @@ func NewClusterCache(client dynamic.Interface, restMapper meta.RESTMapper) *Clus return cache } -func (c *ClusterCache) UpdateCache(resources map[schema.GroupVersionResource]struct{}) error { +func (c *Cache) UpdateCache(resources map[schema.GroupVersionResource]struct{}) error { c.lock.Lock() defer c.lock.Unlock() @@ -94,7 +95,7 @@ func (c *ClusterCache) UpdateCache(resources map[schema.GroupVersionResource]str return nil } -func (c *ClusterCache) Stop() { +func (c *Cache) Stop() { c.lock.RLock() defer c.lock.RUnlock() @@ -103,11 +104,11 @@ func (c *ClusterCache) Stop() { } } -func (c *ClusterCache) GetResourceFromCache(ctx context.Context, gvr schema.GroupVersionResource, namespace, name string) (runtime.Object, string, error) { +func (c *Cache) GetResourceFromCache(ctx context.Context, gvr schema.GroupVersionResource, namespace, name string) (runtime.Object, string, error) { return nil, "", nil } -func (c *ClusterCache) Get(ctx context.Context, gvr schema.GroupVersionResource, name string, options *metav1.GetOptions) (runtime.Object, error) { +func (c *Cache) Get(ctx context.Context, gvr schema.GroupVersionResource, name string, options *metav1.GetOptions) (runtime.Object, error) { rc := c.cacheForResource(gvr) if rc == nil { return nil, errors.New(fmt.Sprintf("can not find gvr %v", gvr)) @@ -121,7 +122,7 @@ func (c *ClusterCache) Get(ctx context.Context, gvr schema.GroupVersionResource, return cloneObj, err } -func (c *ClusterCache) Update(ctx context.Context, gvr schema.GroupVersionResource, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) { +func (c *Cache) Update(ctx context.Context, gvr schema.GroupVersionResource, name string, objInfo rest.UpdatedObjectInfo, createValidation rest.ValidateObjectFunc, updateValidation rest.ValidateObjectUpdateFunc, forceAllowCreate bool, options *metav1.UpdateOptions) (runtime.Object, bool, error) { rc := c.cacheForResource(gvr) if rc == nil { // TODO @@ -131,7 +132,7 @@ func (c *ClusterCache) Update(ctx context.Context, gvr schema.GroupVersionResour } -func (c *ClusterCache) List(ctx context.Context, gvr schema.GroupVersionResource, options *metainternalversion.ListOptions) (runtime.Object, error) { +func (c *Cache) List(ctx context.Context, gvr schema.GroupVersionResource, options *metainternalversion.ListOptions) (runtime.Object, error) { rc := c.cacheForResource(gvr) if rc == nil { // TODO @@ -144,7 +145,7 @@ func (c *ClusterCache) List(ctx context.Context, gvr schema.GroupVersionResource return list, nil } -func (c *ClusterCache) Watch(ctx context.Context, gvr schema.GroupVersionResource, options *metainternalversion.ListOptions) (watch.Interface, error) { +func (c *Cache) Watch(ctx context.Context, gvr schema.GroupVersionResource, options *metainternalversion.ListOptions) (watch.Interface, error) { rc := c.cacheForResource(gvr) if rc == nil { return nil, errors.New(fmt.Sprintf("can not find target gvr %v", gvr)) @@ -156,13 +157,13 @@ func (c *ClusterCache) Watch(ctx context.Context, gvr schema.GroupVersionResourc return w, nil } -func (c *ClusterCache) clientForResourceFunc(resource schema.GroupVersionResource) func() (dynamic.NamespaceableResourceInterface, error) { +func (c *Cache) clientForResourceFunc(resource schema.GroupVersionResource) func() (dynamic.NamespaceableResourceInterface, error) { return func() (dynamic.NamespaceableResourceInterface, error) { return c.client.Resource(resource), nil } } -func (c *ClusterCache) cacheForResource(gvr schema.GroupVersionResource) *resourceCache { +func (c *Cache) cacheForResource(gvr schema.GroupVersionResource) *resourceCache { c.lock.RLock() defer c.lock.RUnlock() return c.cache[gvr] diff --git a/pkg/proxy/store/resource_cache.go b/pkg/proxy/store/resource_cache.go index 0dc4d2454..b882dc61e 100644 --- a/pkg/proxy/store/resource_cache.go +++ b/pkg/proxy/store/resource_cache.go @@ -27,12 +27,11 @@ import ( // resourceCache cache one kind resource from single member cluster type resourceCache struct { *genericregistry.Store - clusterName string - resource schema.GroupVersionResource + resource schema.GroupVersionResource } func (c *resourceCache) stop() { - klog.Infof("Stop store for %s %s", c.clusterName, c.resource) + klog.Infof("Stop store for %s", c.resource) go c.Store.DestroyFunc() } diff --git a/pkg/scheme/scheme.go b/pkg/scheme/scheme.go index 57ce410c1..e8ad99b5c 100644 --- a/pkg/scheme/scheme.go +++ b/pkg/scheme/scheme.go @@ -6,7 +6,7 @@ import ( "k8s.io/client-go/rest" "sigs.k8s.io/controller-runtime/pkg/client" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" ) // aggregatedScheme aggregates Kubernetes and extended schemes. diff --git a/pkg/utils/constants.go b/pkg/utils/constants.go index 4a789162c..b5f135523 100644 --- a/pkg/utils/constants.go +++ b/pkg/utils/constants.go @@ -8,3 +8,16 @@ const ( const ExternalIPPoolNamePrefix = "clusterlink" const CNITypeCalico = "calico" + +const ( + ProxySecretName = "clusterlink-agent-proxy" + ControlPanelSecretName = "controlpanel-config" +) + +const ( + EnvUseProxy = "USE_PROXY" + EnvClusterName = "CLUSTER_NAME" + EnvNodeName = "NODE_NAME" +) + +const ClusterStartControllerFinalizer = "kosmos.io/cluster-start-finazlizer" diff --git a/pkg/utils/interface-policy/interface-policy.go b/pkg/utils/interface-policy/interface-policy.go index 00ab33154..161be5a2e 100644 --- a/pkg/utils/interface-policy/interface-policy.go +++ b/pkg/utils/interface-policy/interface-policy.go @@ -1,8 +1,8 @@ package interfacepolicy import ( - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - "cnp.io/clusterlink/pkg/utils" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/utils" ) func GetInterfaceName(networkInterfacePolicies []clusterlinkv1alpha1.NICNodeNames, nodeName string, defaultInterfaceName string) string { diff --git a/pkg/utils/ipam/ippool_manager.go b/pkg/utils/ipam/ippool_manager.go index 8eef34f11..64fdd2068 100644 --- a/pkg/utils/ipam/ippool_manager.go +++ b/pkg/utils/ipam/ippool_manager.go @@ -7,13 +7,13 @@ import ( meta "k8s.io/apimachinery/pkg/apis/meta/v1" - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/dynamic" "k8s.io/client-go/rest" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" "k8s.io/klog/v2" ) diff --git a/pkg/utils/ipam/ippool_test.go b/pkg/utils/ipam/ippool_test.go index 8d120636d..79e16c54d 100644 --- a/pkg/utils/ipam/ippool_test.go +++ b/pkg/utils/ipam/ippool_test.go @@ -4,7 +4,7 @@ import ( "net" "testing" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" ) const iprange = "10.233.4.0/24" diff --git a/pkg/utils/role/role.go b/pkg/utils/role/role.go index 64418ce61..0504cd867 100644 --- a/pkg/utils/role/role.go +++ b/pkg/utils/role/role.go @@ -1,7 +1,7 @@ package role import ( - "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" "k8s.io/apimachinery/pkg/util/sets" ) diff --git a/pkg/utils/worker.go b/pkg/utils/worker.go index 4b53e3c24..cf64d67fb 100755 --- a/pkg/utils/worker.go +++ b/pkg/utils/worker.go @@ -9,7 +9,7 @@ import ( "k8s.io/client-go/util/workqueue" "k8s.io/klog/v2" - "cnp.io/clusterlink/pkg/utils/flags" + "github.com/kosmos.io/clusterlink/pkg/utils/flags" ) // This code is directly lifted from the karmada diff --git a/test/e2e/elector_test.go b/test/e2e/elector_test.go index 79c2d7234..11421b03d 100644 --- a/test/e2e/elector_test.go +++ b/test/e2e/elector_test.go @@ -7,8 +7,8 @@ import ( "github.com/onsi/ginkgo/v2" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - "cnp.io/clusterlink/pkg/utils/role" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/utils/role" ) var _ = ginkgo.Describe("elector testing", func() { diff --git a/test/e2e/framework/cluster.go b/test/e2e/framework/cluster.go index bffef6abc..2a0c29055 100644 --- a/test/e2e/framework/cluster.go +++ b/test/e2e/framework/cluster.go @@ -12,9 +12,9 @@ import ( "k8s.io/client-go/tools/clientcmd" "k8s.io/klog/v2" - clusterlinkv1alpha1 "cnp.io/clusterlink/pkg/apis/clusterlink/v1alpha1" - "cnp.io/clusterlink/pkg/generated/clientset/versioned" - "cnp.io/clusterlink/projectpath" + clusterlinkv1alpha1 "github.com/kosmos.io/clusterlink/pkg/apis/clusterlink/v1alpha1" + "github.com/kosmos.io/clusterlink/pkg/generated/clientset/versioned" + "github.com/kosmos.io/clusterlink/projectpath" ) func FetchClusters(client versioned.Interface) ([]clusterlinkv1alpha1.Cluster, error) { diff --git a/test/e2e/suit_test.go b/test/e2e/suit_test.go index bc2a2ea32..ce25bcaf7 100644 --- a/test/e2e/suit_test.go +++ b/test/e2e/suit_test.go @@ -13,8 +13,8 @@ import ( "k8s.io/client-go/rest" "sigs.k8s.io/controller-runtime/pkg/client" - "cnp.io/clusterlink/pkg/generated/clientset/versioned" - "cnp.io/clusterlink/test/e2e/framework" + "github.com/kosmos.io/clusterlink/pkg/generated/clientset/versioned" + "github.com/kosmos.io/clusterlink/test/e2e/framework" ) var (