func NewClusterControllerCommand() *cobra.Command {
	cmd := &cobra.Command{
		Use:   "clustercontroller",
		Short: "clustercontroller is a component of ote-stack which manager ote cluster",
		Long: `clustercontroller connects to the others to make a ote cluster,
		which can connect to other cluster like k8s`,
		Run: func(cmd *cobra.Command, args []string) {
			if err := Run(); err != nil {
				klog.Fatal(err)
			}
		},
	}
	versionCmd := &cobra.Command{
		Use:   "version",
		Short: "Show version",
		Long:  "",
		Run: func(cmd *cobra.Command, args []string) {
			klog.Info("OTE clustercontroller 1.0")
		},
	}
	cmd.AddCommand(versionCmd)
	cmd.PersistentFlags().StringVarP(&parentCluster, "parent-cluster", "p", "", "Cloud tunnel of parent cluster, e.g., 192.168.0.2:8287")
	cmd.PersistentFlags().StringVarP(&clusterName, "cluster-name", "n", config.RootClusterName, "Current cluster name, must be unique")
	cmd.PersistentFlags().StringVarP(&kubeConfig, "kube-config", "k", "/root/.kube/config", "KubeConfig file path")
	cmd.PersistentFlags().StringVarP(&tunnelListenAddr, "tunnel-listen", "l", ":8287", "Cloud tunnel listen address, e.g., 192.168.0.3:8287")
	cmd.PersistentFlags().StringVarP(&remoteShimAddr, "remote-shim-endpoint", "r", "", "remote cluster shim address, e.g., 192.168.0.4:8262")
	cmd.PersistentFlags().StringVarP(&helmTillerAddr, "helm-tiller-addr", "t", "", "helm tiller http proxy addr, e.g., 192.168.0.4:8288")
	cmd.PersistentFlags().BoolVarP(&leaderElection, "leader-election", "e", false, "leader elect if this is the root")
	fs := cmd.Flags()
	fs.AddGoFlagSet(flag.CommandLine)
	return cmd
}
NewClusterControllerCommand creates a *cobra.Command object with default parameters.
package app
import (
	"context"
	"flag"
	"fmt"
	"os"
	"strings"
	"sync"
	"time"
	"github.com/spf13/cobra"
	"k8s.io/client-go/tools/leaderelection"
	"k8s.io/client-go/tools/leaderelection/resourcelock"
	"k8s.io/klog"
	"github.com/baidu/ote-stack/pkg/clusterhandler"
	"github.com/baidu/ote-stack/pkg/clustermessage"
	"github.com/baidu/ote-stack/pkg/config"
	"github.com/baidu/ote-stack/pkg/edgehandler"
	"github.com/baidu/ote-stack/pkg/eventrecorder"
	oteclient "github.com/baidu/ote-stack/pkg/generated/clientset/versioned"
	"github.com/baidu/ote-stack/pkg/k8sclient"
)
const (
	leaseDuration = 15 * time.Second
	renewDeadline = 10 * time.Second
	retryPeriod   = 2 * time.Second
	oteRootClusterControllerName = "ote-root-cluster-controller"
	RootClusterToEdgeChanBuffer = 10000
	RootEdgeToClusterChanBuffer = 10000
)
var (
	parentCluster    string
	clusterName      string
	kubeConfig       string
	tunnelListenAddr string
	remoteShimAddr   string
	helmTillerAddr   string
	leaderElection   bool
)