Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor fsm-connector #133

Merged
merged 38 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e6c871b
traffic split based on eureka metadata
cybwan Nov 20, 2023
f07815f
refactor connector
cybwan Nov 27, 2023
3662665
refactor connector
cybwan Nov 27, 2023
15e03ea
refactor connector
cybwan Nov 28, 2023
cab0642
refactor connector
cybwan Nov 28, 2023
a0228d0
refactor connector
cybwan Nov 28, 2023
f81fd41
refactor fsm-connector
cybwan Nov 28, 2023
a580587
refactor fsm-connector
cybwan Nov 28, 2023
3729652
refactor fsm-connector
cybwan Nov 28, 2023
176bac8
refactor fsm-connector
cybwan Nov 28, 2023
a9afb53
refactor fsm-connector
cybwan Nov 28, 2023
53e9328
refactor fsm-connector
cybwan Nov 28, 2023
2d5b2bb
refactor fsm-connector
cybwan Nov 28, 2023
22d9dcb
refactor fsm-connector
cybwan Nov 28, 2023
f2cb19b
refactor fsm-connector
cybwan Nov 29, 2023
16e473d
refactor fsm-connector
cybwan Nov 29, 2023
f796808
refactor fsm-connector
cybwan Nov 29, 2023
73252b0
refactor fsm-connector
cybwan Nov 29, 2023
612f32c
refactor fsm-connector
cybwan Nov 29, 2023
a1927e6
refactor fsm-connector
cybwan Nov 29, 2023
a392667
refactor fsm-connector
cybwan Nov 29, 2023
b6f9247
refactor fsm-connector
cybwan Nov 29, 2023
c02e8ed
refactor fsm-connector
cybwan Nov 29, 2023
c1ae0c7
refactor fsm-connector
cybwan Nov 29, 2023
e86df0c
refactor fsm-connector
cybwan Nov 29, 2023
7a51e6d
refactor fsm-connector
cybwan Nov 30, 2023
f6bda67
refactor fsm-connector
cybwan Nov 30, 2023
46fd22e
refactor fsm-connector
cybwan Nov 30, 2023
2481671
refactor fsm-connector
cybwan Nov 30, 2023
a983bb7
refactor fsm-connector
cybwan Nov 30, 2023
e133a0a
refactor fsm-connector
cybwan Nov 30, 2023
26b5e6c
refactor fsm-connector
cybwan Nov 30, 2023
84423dd
refactor fsm-connector
cybwan Nov 30, 2023
7b6ee45
refactor fsm-connector
cybwan Dec 1, 2023
b8e827e
refactor fsm-connector
cybwan Dec 1, 2023
1a90b0e
refactor fsm-connector
cybwan Dec 1, 2023
1e8f776
refactor fsm-connector
cybwan Dec 1, 2023
f59ba7a
refactor fsm-connector
cybwan Dec 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor fsm-connector
  • Loading branch information
cybwan committed Nov 28, 2023
commit 3729652c74eeaec593c3cbd59509f95ac6c466db
3 changes: 2 additions & 1 deletion charts/fsm/templates/fsm-consul-connector-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ spec:
"-trust-domain", "{{.Values.fsm.trustDomain}}",
"-derive-namespace={{.Values.fsm.cloudConnector.consul.deriveNamespace}}",
"-with-gateway-api={{.Values.fsm.fsmGateway.enabled}}",
"-http-addr={{.Values.fsm.cloudConnector.consul.httpAddr}}",
"-sdr-provider=consul",
"-sdr-http-addr={{.Values.fsm.cloudConnector.consul.httpAddr}}",
"-passing-only={{.Values.fsm.cloudConnector.consul.passingOnly}}",
"-filter-tag={{.Values.fsm.cloudConnector.consul.filterTag}}",
"-prefix-tag={{.Values.fsm.cloudConnector.consul.prefixTag}}",
Expand Down
3 changes: 2 additions & 1 deletion charts/fsm/templates/fsm-eureka-connector-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ spec:
"-trust-domain", "{{.Values.fsm.trustDomain}}",
"-derive-namespace={{.Values.fsm.cloudConnector.eureka.deriveNamespace}}",
"-with-gateway-api={{.Values.fsm.fsmGateway.enabled}}",
"-http-addr={{.Values.fsm.cloudConnector.eureka.httpAddr}}",
"-sdr-provider=eureka",
"-sdr-http-addr={{.Values.fsm.cloudConnector.eureka.httpAddr}}",
"-passing-only={{.Values.fsm.cloudConnector.eureka.passingOnly}}",
"-filter-tag={{.Values.fsm.cloudConnector.eureka.filterMetadata}}",
"-prefix-tag={{.Values.fsm.cloudConnector.eureka.prefixMetadata}}",
Expand Down
20 changes: 16 additions & 4 deletions cmd/fsm-connector/fsm-connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"k8s.io/client-go/tools/clientcmd"

"github.com/flomesh-io/fsm/pkg/connector"
"github.com/flomesh-io/fsm/pkg/connector/cli"
"github.com/flomesh-io/fsm/pkg/connector/ctok"
"github.com/flomesh-io/fsm/pkg/connector/provider"
Expand Down Expand Up @@ -82,10 +83,21 @@ func main() {

msgBroker := messaging.NewBroker(stop)

discClient, err := provider.GetEurekaDiscoveryClient(cli.Cfg.HttpAddr)
if err != nil {
events.GenericEventRecorder().FatalEvent(err, events.InitializationError, "Error creating cloud client")
log.Fatal().Msg("Error creating cloud client")
var discClient provider.ServiceDiscoveryClient = nil
if connector.EurekaDiscoveryService == cli.Cfg.SdrProvider {
discClient, err = provider.GetEurekaDiscoveryClient(cli.Cfg.HttpAddr)
if err != nil {
events.GenericEventRecorder().FatalEvent(err, events.InitializationError, "Error creating cloud client")
log.Fatal().Msg("Error creating cloud client")
}
} else if connector.ConsulDiscoveryService == cli.Cfg.SdrProvider {
discClient, err = provider.GetConsulDiscoveryClient(cli.Cfg.HttpAddr)
if err != nil {
events.GenericEventRecorder().FatalEvent(err, events.InitializationError, "Error creating cloud client")
log.Fatal().Msg("Error creating cloud client")
}
} else {
log.Fatal().Msg("Unsupported service discovery and registration provider")
}

gatewayClient := gwapi.NewForConfigOrDie(kubeConfig)
Expand Down
14 changes: 13 additions & 1 deletion pkg/connector/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (

mapset "github.com/deckarep/golang-set"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/flomesh-io/fsm/pkg/connector"
)

var (
Expand Down Expand Up @@ -87,6 +89,7 @@ type Config struct {
FsmVersion string
TrustDomain string
DeriveNamespace string
SdrProvider string
HttpAddr string

C2K C2KCfg
Expand All @@ -102,7 +105,8 @@ func init() {
flags.StringVar(&Cfg.FsmVersion, "fsm-version", "", "Version of FSM")
flags.StringVar(&Cfg.TrustDomain, "trust-domain", "cluster.local", "The trust domain to use as part of the common name when requesting new certificates")
flags.StringVar(&Cfg.DeriveNamespace, "derive-namespace", "", "derive namespace")
flags.StringVar(&Cfg.HttpAddr, "http-addr", "", "http addr")
flags.StringVar(&Cfg.SdrProvider, "sdr-provider", "", "service discovery and registration (eureka, consul)")
flags.StringVar(&Cfg.HttpAddr, "sdr-http-addr", "", "http addr")

flags.StringVar(&Cfg.C2K.FlagFilterTag, "filter-tag", "", "filter tag")
flags.StringVar(&Cfg.C2K.FlagPrefixTag, "prefix-tag", "", "prefix tag")
Expand Down Expand Up @@ -183,6 +187,14 @@ func ValidateCLIParams() error {
return fmt.Errorf("please specify the cloud derive namespace using -derive-namespace")
}

if Cfg.SdrProvider == "" || (connector.EurekaDiscoveryService != Cfg.SdrProvider && connector.ConsulDiscoveryService != Cfg.SdrProvider) {
return fmt.Errorf("please specify service discovery and registration provider using -sdr-provider")
}

if Cfg.HttpAddr == "" {
return fmt.Errorf("please specify service discovery and registration server address using -sdr-http-addr")
}

return nil
}

Expand Down