This is an automated email from the ASF dual-hosted git repository.
zhongxjian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-kubernetes.git
The following commit(s) were added to refs/heads/master by this push:
new 41172202 Initial comet control plane (#726)
41172202 is described below
commit 41172202b03212574362716edcd61d9e5e2a33de
Author: Jian Zhong <[email protected]>
AuthorDate: Mon Jun 2 10:25:52 2025 +0800
Initial comet control plane (#726)
---
comet/galaxy/comet-agent/app/cmd.go | 85 +++++++++++++++++++++++++++++++++
comet/galaxy/comet-agent/main.go | 13 +++++
comet/galaxy/comet-discovery/app/cmd.go | 11 +++++
comet/galaxy/comet-discovery/main.go | 13 +++++
comet/pkg/cmd/cmd.go | 10 ++++
go.mod | 2 +-
6 files changed, 133 insertions(+), 1 deletion(-)
diff --git a/comet/galaxy/comet-agent/app/cmd.go
b/comet/galaxy/comet-agent/app/cmd.go
new file mode 100644
index 00000000..95ddaf85
--- /dev/null
+++ b/comet/galaxy/comet-agent/app/cmd.go
@@ -0,0 +1,85 @@
+package app
+
+import (
+ "context"
+ "fmt"
+ "github.com/apache/dubbo-kubernetes/comet/pkg/cmd"
+ "github.com/spf13/cobra"
+)
+
+func NewRootCommand() *cobra.Command {
+ rootCmd := &cobra.Command{
+ Use: "comet-agent",
+ SilenceUsage: true,
+ }
+ cmd.AddFlags(rootCmd)
+ return rootCmd
+}
+
+func newProxyCommand() *cobra.Command {
+ return &cobra.Command{
+ Use: "proxy",
+ Short: "XDS proxy agent",
+ FParseErrWhitelist: cobra.FParseErrWhitelist{
+ UnknownFlags: true,
+ },
+ RunE: func(c *cobra.Command, args []string) error {
+ err := initProxy(args)
+ if err != nil {
+ return err
+ }
+ proxyConfig, err :=
config.ConstructProxyConfig(proxyArgs.MeshConfigFile, proxyArgs.ServiceCluster,
options.ProxyConfigEnv, proxyArgs.Concurrency)
+ if err != nil {
+ return fmt.Errorf("failed to get proxy config:
%v", err)
+ }
+ if out, err := protomarshal.ToYAML(proxyConfig); err !=
nil {
+ log.Infof("Failed to serialize to YAML: %v",
err)
+ } else {
+ log.Infof("Effective config: %s", out)
+ }
+
+ secOpts, err := options.NewSecurityOptions(proxyConfig,
proxyArgs.StsPort, proxyArgs.TokenManagerPlugin)
+ if err != nil {
+ return err
+ }
+
+ // If we are using a custom template file (for control
plane proxy, for example), configure this.
+ if proxyArgs.TemplateFile != "" &&
proxyConfig.CustomConfigFile == "" {
+ proxyConfig.ProxyBootstrapTemplatePath =
proxyArgs.TemplateFile
+ }
+
+ envoyOptions := envoy.ProxyConfig{
+ LogLevel: proxyArgs.ProxyLogLevel,
+ ComponentLogLevel:
proxyArgs.ProxyComponentLogLevel,
+ LogAsJSON: loggingOptions.JSONEncoding,
+ NodeIPs: proxyArgs.IPAddresses,
+ Sidecar: proxyArgs.Type ==
model.SidecarProxy,
+ OutlierLogPath: proxyArgs.OutlierLogPath,
+ }
+ agentOptions := options.NewAgentOptions(&proxyArgs,
proxyConfig, sds)
+ agent := istioagent.NewAgent(proxyConfig, agentOptions,
secOpts, envoyOptions)
+ ctx, cancel :=
context.WithCancelCause(context.Background())
+ defer cancel(errors.New("application shutdown"))
+ defer agent.Close()
+
+ // If a status port was provided, start handling status
probes.
+ if proxyConfig.StatusPort > 0 {
+ if err := initStatusServer(ctx, proxyConfig,
+ agentOptions.EnvoyPrometheusPort,
proxyArgs.EnableProfiling, agent, cancel); err != nil {
+ return err
+ }
+ }
+
+ // On SIGINT or SIGTERM, cancel the context, triggering
a graceful shutdown
+ go cmd.WaitSignalFunc(cancel)
+
+ // Start in process SDS, dns server, xds proxy, and
Envoy.
+ wait, err := agent.Run(ctx)
+ if err != nil {
+ return err
+ }
+ wait()
+ return nil
+ },
+ }
+}
diff --git a/comet/galaxy/comet-agent/main.go b/comet/galaxy/comet-agent/main.go
new file mode 100644
index 00000000..fbbb9db8
--- /dev/null
+++ b/comet/galaxy/comet-agent/main.go
@@ -0,0 +1,13 @@
+package main
+
+import (
+ "github.com/apache/dubbo-kubernetes/comet/galaxy/comet-agent/app"
+ "os"
+)
+
+func main() {
+ rootCmd := app.NewRootCommand()
+ if err := rootCmd.Execute(); err != nil {
+ os.Exit(-1)
+ }
+}
diff --git a/comet/galaxy/comet-discovery/app/cmd.go
b/comet/galaxy/comet-discovery/app/cmd.go
new file mode 100644
index 00000000..cd74db7c
--- /dev/null
+++ b/comet/galaxy/comet-discovery/app/cmd.go
@@ -0,0 +1,11 @@
+package app
+
+import "github.com/spf13/cobra"
+
+func NewRootCommand() *cobra.Command {
+ rootCmd := &cobra.Command{
+ Use: "pilot-discovery",
+ SilenceUsage: true,
+ }
+ return rootCmd
+}
diff --git a/comet/galaxy/comet-discovery/main.go
b/comet/galaxy/comet-discovery/main.go
new file mode 100644
index 00000000..7e4d4ad0
--- /dev/null
+++ b/comet/galaxy/comet-discovery/main.go
@@ -0,0 +1,13 @@
+package main
+
+import (
+ "github.com/apache/dubbo-kubernetes/comet/galaxy/comet-discovery/app"
+ "os"
+)
+
+func main() {
+ rootCmd := app.NewRootCommand()
+ if err := rootCmd.Execute(); err != nil {
+ os.Exit(-1)
+ }
+}
diff --git a/comet/pkg/cmd/cmd.go b/comet/pkg/cmd/cmd.go
new file mode 100644
index 00000000..ab77cf8d
--- /dev/null
+++ b/comet/pkg/cmd/cmd.go
@@ -0,0 +1,10 @@
+package cmd
+
+import (
+ "flag"
+ "github.com/spf13/cobra"
+)
+
+func AddFlags(rootCmd *cobra.Command) {
+ rootCmd.PersistentFlags().AddGoFlagSet(flag.CommandLine)
+}
diff --git a/go.mod b/go.mod
index db79361f..f1ae260d 100644
--- a/go.mod
+++ b/go.mod
@@ -21,6 +21,7 @@ require (
dubbo.apache.org/dubbo-go/v3 v3.3.0
github.com/AlecAivazis/survey/v2 v2.3.7
github.com/Masterminds/semver/v3 v3.2.1
+ github.com/Microsoft/go-winio v0.6.2
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2
github.com/bakito/go-log-logr-adapter v0.0.2
github.com/buildpacks/pack v0.30.0
@@ -121,7 +122,6 @@ require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
- github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/OneOfOne/xxhash v1.2.8 // indirect
github.com/ProtonMail/go-crypto v1.1.3 // indirect
github.com/RoaringBitmap/roaring v1.2.3 // indirect