@@ -59,6 +59,7 @@ import (
5959 configv1beta1 "github.com/projectsveltos/addon-controller/api/v1beta1"
6060 "github.com/projectsveltos/addon-controller/api/v1beta1/index"
6161 "github.com/projectsveltos/addon-controller/controllers"
62+ "github.com/projectsveltos/addon-controller/controllers/dependencymanager"
6263 "github.com/projectsveltos/addon-controller/internal/telemetry"
6364 libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1"
6465 "github.com/projectsveltos/libsveltos/lib/crd"
9192 capiOnboardAnnotation string
9293 disableCaching bool
9394 disableTelemetry bool
95+ autoDeployDependencies bool
9496)
9597
9698const (
@@ -177,6 +179,8 @@ func main() {
177179 controllers .SetDriftdetectionConfigMap (driftDetectionConfigMap )
178180 controllers .SetLuaConfigMap (luaConfigMap )
179181 controllers .SetCAPIOnboardAnnotation (capiOnboardAnnotation )
182+ // Start dependency manager
183+ dependencymanager .InitializeManagerInstance (ctx , mgr .GetClient (), autoDeployDependencies , ctrl .Log .WithName ("dependency_manager" ))
180184
181185 logsettings .RegisterForLogSettings (ctx ,
182186 libsveltosv1beta1 .ComponentAddonManager , ctrl .Log .WithName ("log-setter" ),
@@ -277,6 +281,27 @@ func initFlags(fs *pflag.FlagSet) {
277281 fs .DurationVar (& conflictRetryTime , "conflict-retry-time" , defaultConflictRetryTime * time .Second ,
278282 fmt .Sprintf ("The minimum interval at which watched ClusterProfile with conflicts are retried. Defaul: %d seconds" ,
279283 defaultConflictRetryTime ))
284+
285+ // AutoDeployDependencies enables automatic deployment of prerequisite profiles.
286+ //
287+ // Profile instances can specify dependencies on other profiles using the
288+ // DependsOn field, forming a directed acyclic graph (DAG) of dependencies.
289+ //
290+ // When AutoDeployDependencies is set to true, Sveltos automatically resolves and deploys
291+ // the prerequisite profiles listed in the DependsOn field. This automation
292+ // ensures that all required dependencies are deployed to the same managed clusters
293+ // as the dependent profile. Sveltos analyzes the dependency graph to identify
294+ // and deploy prerequisites in the correct order.
295+ //
296+ // By default, AutoDeployDependencies is enabled (true). When disabled, administrators
297+ // are responsible for ensuring that both the dependent and prerequisite profiles
298+ // target the same set of managed clusters through matching cluster selectors.
299+ //
300+ // Enabling AutoDeployDependencies simplifies multi-cluster management by automating
301+ // dependency resolution, reducing manual effort, and minimizing the risk of
302+ // configuration inconsistencies.
303+ fs .BoolVar (& autoDeployDependencies , "auto-deploy-dependencies" , true ,
304+ " When AutoDeployDependencies is set to true, Sveltos will automatically resolve and deploy the prerequisite profiles specified in the DependsOn field" )
280305}
281306
282307func setupIndexes (ctx context.Context , mgr ctrl.Manager ) {
0 commit comments