Skip to content

Commit

Permalink
Connect to vCluster Platform earlier
Browse files Browse the repository at this point in the history
vCluster is now able to request a data source from vCluster Platform.
vCluster is only able to use the data source if it attempts to connect
to the vCluster Platform prior to deploying its own control plane.
vCluster Platform is now connected before control plane is deployed
but the platform controllers and tailscale server are started after
because they require the control plane to be running.
  • Loading branch information
rmweir committed Aug 12, 2024
1 parent 2075c88 commit 6f242e7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
17 changes: 11 additions & 6 deletions cmd/vcluster/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ func ExecuteStart(ctx context.Context, options *StartOptions) error {
// set features for plugins to recognize
plugin.DefaultManager.SetProFeatures(pro.LicenseFeatures())

// check if we should create certs
// connect to vCluster platform if configured
startPlatformServersAndControllers, err := pro.ConnectToPlatform(ctx, vConfig)
if err != nil {
return fmt.Errorf("connect to platform: %w", err)
}

err = setup.Initialize(ctx, vConfig)
if err != nil {
return fmt.Errorf("initialize: %w", err)
Expand All @@ -101,6 +106,11 @@ func ExecuteStart(ctx context.Context, options *StartOptions) error {
return fmt.Errorf("create controller context: %w", err)
}

err = startPlatformServersAndControllers(controllerCtx.VirtualManager)
if err != nil {
return fmt.Errorf("start platform controllers: %w", err)
}

// start integrations
err = integrations.StartIntegrations(controllerCtx)
if err != nil {
Expand Down Expand Up @@ -134,11 +144,6 @@ func ExecuteStart(ctx context.Context, options *StartOptions) error {
}
}

// connect to vCluster platform if configured
if err := pro.ConnectToPlatform(ctx, vConfig, controllerCtx.VirtualManager); err != nil {
return fmt.Errorf("connect to platform: %w", err)
}

// start leader election + controllers
err = StartLeaderElection(controllerCtx, func() error {
return setup.StartControllers(controllerCtx, syncers)
Expand Down
4 changes: 2 additions & 2 deletions pkg/pro/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/manager"
)

var ConnectToPlatform = func(context.Context, *config.VirtualClusterConfig, manager.Manager) error {
return nil
var ConnectToPlatform = func(context.Context, *config.VirtualClusterConfig) (func(mgr manager.Manager) error, error) {
return func(_ manager.Manager) error { return nil }, nil
}

0 comments on commit 6f242e7

Please sign in to comment.