diff options
| author | zhu733756 <zhu733756@kubesphere.io> | 2021-11-19 21:40:21 +0800 |
|---|---|---|
| committer | zhu733756 <zhu733756@kubesphere.io> | 2021-11-23 21:00:11 +0800 |
| commit | dee189af385a1938c827b264aa665dba50f9433d (patch) | |
| tree | 49f8387625b16570c4d5f984abe106880c0997a2 /cloud/cmd | |
| parent | make iptablesmgr node affinity to the master node (diff) | |
| download | kubeedge-dee189af385a1938c827b264aa665dba50f9433d.tar.gz | |
Optimize startup configuration
Signed-off-by: zhu733756 <zhu733756@kubesphere.io>
Diffstat (limited to 'cloud/cmd')
| -rw-r--r-- | cloud/cmd/cloudcore/app/server.go | 5 | ||||
| -rw-r--r-- | cloud/cmd/iptablesmanager/app/options/options.go (renamed from cloud/cmd/iptablesManager/app/options/options.go) | 9 | ||||
| -rw-r--r-- | cloud/cmd/iptablesmanager/app/server.go (renamed from cloud/cmd/iptablesManager/app/server.go) | 22 | ||||
| -rw-r--r-- | cloud/cmd/iptablesmanager/iptablesmanager.go (renamed from cloud/cmd/iptablesManager/iptablesManager.go) | 2 |
4 files changed, 26 insertions, 12 deletions
diff --git a/cloud/cmd/cloudcore/app/server.go b/cloud/cmd/cloudcore/app/server.go index 6c2f156aa..9ad186fff 100644 --- a/cloud/cmd/cloudcore/app/server.go +++ b/cloud/cmd/cloudcore/app/server.go @@ -91,10 +91,11 @@ kubernetes controller which manages devices so that the device metadata/status d registerModules(config) - if config.Modules.IptablesManager == nil || config.Modules.IptablesManager.Enable && config.Modules.IptablesManager.Mode == "internal" { + if config.Modules.IptablesManager == nil || config.Modules.IptablesManager.Enable && config.Modules.IptablesManager.Mode == v1alpha1.InternalMode { // By default, IptablesManager manages tunnel port related iptables rules // The internal mode will share the host network, forward to the stream port. - go iptables.NewIptablesManager().Run() + streamPort := int(config.Modules.CloudStream.StreamPort) + go iptables.NewIptablesManager(streamPort).Run() } // Start all modules diff --git a/cloud/cmd/iptablesManager/app/options/options.go b/cloud/cmd/iptablesmanager/app/options/options.go index 6394dc54e..f213f38dc 100644 --- a/cloud/cmd/iptablesManager/app/options/options.go +++ b/cloud/cmd/iptablesmanager/app/options/options.go @@ -22,17 +22,22 @@ import ( // IptablesManagerOptions config type IptablesManagerOptions struct { - KubeConfig string + KubeConfig string + ForwardPort int } // NewIptablesManagerOptions returns options object func NewIptablesManagerOptions() *IptablesManagerOptions { - return &IptablesManagerOptions{} + return &IptablesManagerOptions{ + KubeConfig: "", + ForwardPort: 10003, + } } // Flags return flag sets func (o *IptablesManagerOptions) Flags() (fss cliflag.NamedFlagSets) { fs := fss.FlagSet("IptablesManager") fs.StringVar(&o.KubeConfig, "kubeConfig", o.KubeConfig, "The KubeConfig path. Flags override values in this file.") + fs.IntVar(&o.ForwardPort, "ForwardPort", o.ForwardPort, "The forward port, default is the stream port, 10003.") return } diff --git a/cloud/cmd/iptablesManager/app/server.go b/cloud/cmd/iptablesmanager/app/server.go index 0f9751df9..d9bb46eb0 100644 --- a/cloud/cmd/iptablesManager/app/server.go +++ b/cloud/cmd/iptablesmanager/app/server.go @@ -29,10 +29,11 @@ import ( "k8s.io/klog/v2" beehiveContext "github.com/kubeedge/beehive/pkg/core/context" - "github.com/kubeedge/kubeedge/cloud/cmd/iptablesManager/app/options" + "github.com/kubeedge/kubeedge/cloud/cmd/iptablesmanager/app/options" "github.com/kubeedge/kubeedge/cloud/pkg/cloudstream/iptables" "github.com/kubeedge/kubeedge/cloud/pkg/common/client" "github.com/kubeedge/kubeedge/cloud/pkg/common/informers" + "github.com/kubeedge/kubeedge/common/constants" "github.com/kubeedge/kubeedge/pkg/apis/componentconfig/cloudcore/v1alpha1" "github.com/kubeedge/kubeedge/pkg/util/flag" "github.com/kubeedge/kubeedge/pkg/version/verflag" @@ -48,20 +49,27 @@ func NewIptablesManagerCommand() *cobra.Command { flag.PrintFlags(cmd.Flags()) // init kubeedge client - var kubeAPIConfig v1alpha1.KubeAPIConfig - kubeAPIConfig.KubeConfig = opts.KubeConfig - client.InitKubeEdgeClient(&kubeAPIConfig) + kubeAPIConfig := &v1alpha1.KubeAPIConfig{ + Master: "", + ContentType: constants.DefaultKubeContentType, + QPS: constants.DefaultKubeQPS, + Burst: constants.DefaultKubeBurst, + KubeConfig: opts.KubeConfig, + } + client.InitKubeEdgeClient(kubeAPIConfig) gis := informers.GetInformersManager() + ctx := beehiveContext.GetContext() + // The external mode will share the host network, forward to the inner stream port of the cloudcore. - go iptables.NewIptablesManager().Run() - gis.Start(beehiveContext.Done()) + go iptables.NewIptablesManager(opts.ForwardPort).Run() + gis.Start(ctx.Done()) c := make(chan os.Signal, 1) signal.Notify(c, syscall.SIGINT, syscall.SIGHUP, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGILL, syscall.SIGTRAP, syscall.SIGABRT) s := <-c - klog.Infof("Failed to run IptablesManager, os signal %v", s.String()) + klog.Infof("Get os signal %v", s.String()) }, } fs := cmd.Flags() diff --git a/cloud/cmd/iptablesManager/iptablesManager.go b/cloud/cmd/iptablesmanager/iptablesmanager.go index 607c97950..334e058bb 100644 --- a/cloud/cmd/iptablesManager/iptablesManager.go +++ b/cloud/cmd/iptablesmanager/iptablesmanager.go @@ -21,7 +21,7 @@ import ( "k8s.io/component-base/logs" - "github.com/kubeedge/kubeedge/cloud/cmd/iptablesManager/app" + "github.com/kubeedge/kubeedge/cloud/cmd/iptablesmanager/app" ) func main() { |
