func (action *Action) Connect(options *options.DaemonOptions) (err error) {
	if util.IsDaemonRunning(options.RuntimeOptions.PidFile) {
		return fmt.Errorf("Connect already running %s exit this", options.RuntimeOptions.PidFile)
	}

	ch := SetUpCloseHandler(options)

	pid, err := util.WritePidFile(options.RuntimeOptions.PidFile)
	if err != nil {
		return
	}
	log.Info().Msgf("Connect Start At %d", pid)
	factory := connect.Connect{Options: options}
	clientSet, err := cluster.GetKubernetesClient(options.KubeConfig)
	if err != nil {
		return
	}

	if options.ConnectOptions.Dump2Hosts {
		hosts := cluster.LocalHosts(clientSet, options.Namespace)
		util.DumpHosts(hosts)
		options.ConnectOptions.Hosts = hosts
	}

	workload := fmt.Sprintf("kt-connect-daemon-%s", strings.ToLower(util.RandomString(5)))
	options.RuntimeOptions.Shadow = workload

	labels := map[string]string{
		"kt":           workload,
		"kt-component": "connect",
		"control-by":   "kt",
	}

	for k, v := range util.String2Map(options.Labels) {
		labels[k] = v
	}

	endPointIP, podName, err := cluster.CreateShadow(
		clientSet,
		workload,
		labels,
		options.Namespace,
		options.Image,
	)

	if err != nil {
		return
	}

	cidrs, err := util.GetCirds(clientSet, options.ConnectOptions.CIDR)
	if err != nil {
		return
	}

	err = factory.StartConnect(podName, endPointIP, cidrs, options.Debug)
	if err != nil {
		return
	}

	s := <-ch
	log.Info().Msgf("Terminal Signal is %s", s)
	return
}
// Connect connect vpn to kubernetes cluster
Connect connect vpn to kubernetes cluster
// Connect connect vpn to kubernetes cluster
func (action *Action) Connect(options *options.DaemonOptions) (err error) {
	if util.IsDaemonRunning(options.RuntimeOptions.PidFile) {
		return fmt.Errorf("Connect already running %s exit this", options.RuntimeOptions.PidFile)
	}
	ch := SetUpCloseHandler(options)
	pid, err := util.WritePidFile(options.RuntimeOptions.PidFile)
	if err != nil {
		return
	}
	log.Info().Msgf("Connect Start At %d", pid)
	factory := connect.Connect{Options: options}
	clientSet, err := cluster.GetKubernetesClient(options.KubeConfig)
	if err != nil {
		return
	}
	if options.ConnectOptions.Dump2Hosts {
		hosts := cluster.LocalHosts(clientSet, options.Namespace)
		util.DumpHosts(hosts)
		options.ConnectOptions.Hosts = hosts
	}
	workload := fmt.Sprintf("kt-connect-daemon-%s", strings.ToLower(util.RandomString(5)))
	options.RuntimeOptions.Shadow = workload
	labels := map[string]string{
		"kt":           workload,
		"kt-component": "connect",
		"control-by":   "kt",
	}
	for k, v := range util.String2Map(options.Labels) {
		labels[k] = v
	}
	endPointIP, podName, err := cluster.CreateShadow(
		clientSet,
		workload,
		labels,
		options.Namespace,
		options.Image,
	)
	if err != nil {
		return
	}
	cidrs, err := util.GetCirds(clientSet, options.ConnectOptions.CIDR)
	if err != nil {
		return
	}
	err = factory.StartConnect(podName, endPointIP, cidrs, options.Debug)
	if err != nil {
		return
	}
	s := <-ch
	log.Info().Msgf("Terminal Signal is %s", s)
	return
}
func ( action * Action ) Connect ( options * options . DaemonOptions ) ( err error ) { if util . IsDaemonRunning ( options . RuntimeOptions . PidFile ) { return fmt . Errorf ( " " , options . RuntimeOptions . PidFile ) } ch := SetUpCloseHandler ( options ) pid , err := util . WritePidFile ( options . RuntimeOptions . PidFile ) if err != nil { return } log . Info ( ) . Msgf ( " " , pid ) factory := connect . Connect { Options : options } clientSet , err := cluster . GetKubernetesClient ( options . KubeConfig ) if err != nil { return } if options . ConnectOptions . Dump2Hosts { hosts := cluster . LocalHosts ( clientSet , options . Namespace ) util . DumpHosts ( hosts ) options . ConnectOptions . Hosts = hosts } workload := fmt . Sprintf ( " " , strings . ToLower ( util . RandomString ( 5 ) ) ) options . RuntimeOptions . Shadow = workload labels := map [ string ] string { " " : workload , " " : " " , " " : " " , } for k , v := range util . String2Map ( options . Labels ) { labels [ k ] = v } endPointIP , podName , err := cluster . CreateShadow ( clientSet , workload , labels , options . Namespace , options . Image , ) if err != nil { return } cidrs , err := util . GetCirds ( clientSet , options . ConnectOptions . CIDR ) if err != nil { return } err = factory . StartConnect ( podName , endPointIP , cidrs , options . Debug ) if err != nil { return } s := <- ch log . Info ( ) . Msgf ( " " , s ) return }
Connect connect vpn to kubernetes cluster
Connect connect vpn to kubernetes cluster