diff --git a/cmd/stackset-controller/main.go b/cmd/stackset-controller/main.go index 65fdb350..5449c1fa 100644 --- a/cmd/stackset-controller/main.go +++ b/cmd/stackset-controller/main.go @@ -42,6 +42,7 @@ var ( RouteGroupSupportEnabled bool IngressSourceSwitchTTL time.Duration ReconcileWorkers int + ConfigMapSupportEnabled bool } ) @@ -59,6 +60,7 @@ func main() { kingpin.Flag("enable-routegroup-support", "Enable support for RouteGroups on StackSets.").Default("false").BoolVar(&config.RouteGroupSupportEnabled) kingpin.Flag("ingress-source-switch-ttl", "The ttl before an ingress source is deleted when replaced with another one e.g. switching from RouteGroup to Ingress or vice versa."). Default(defaultIngressSourceSwitchTTL).DurationVar(&config.IngressSourceSwitchTTL) + kingpin.Flag("enable-configmap-support", "Enable support for ConfigMaps on StackSets.").Default("false").BoolVar(&config.ConfigMapSupportEnabled) kingpin.Parse() if config.Debug { @@ -86,6 +88,7 @@ func main() { config.Interval, config.RouteGroupSupportEnabled, config.IngressSourceSwitchTTL, + config.ConfigMapSupportEnabled, ) if err != nil { log.Fatalf("Failed to create Stackset controller: %v", err) diff --git a/controller/stackset.go b/controller/stackset.go index e4e9c69b..e34278df 100644 --- a/controller/stackset.go +++ b/controller/stackset.go @@ -63,6 +63,7 @@ type StackSetController struct { ingressSourceSwitchTTL time.Duration now func() string reconcileWorkers int + configMapSupportEnabled bool sync.Mutex } @@ -85,7 +86,18 @@ func now() string { } // NewStackSetController initializes a new StackSetController. -func NewStackSetController(client clientset.Interface, controllerID string, parallelWork int, backendWeightsAnnotationKey string, clusterDomains []string, registry prometheus.Registerer, interval time.Duration, routeGroupSupportEnabled bool, ingressSourceSwitchTTL time.Duration) (*StackSetController, error) { +func NewStackSetController( + client clientset.Interface, + controllerID string, + parallelWork int, + backendWeightsAnnotationKey string, + clusterDomains []string, + registry prometheus.Registerer, + interval time.Duration, + routeGroupSupportEnabled bool, + ingressSourceSwitchTTL time.Duration, + configMapSupportEnabled bool, +) (*StackSetController, error) { metricsReporter, err := core.NewMetricsReporter(registry) if err != nil { return nil, err @@ -105,6 +117,7 @@ func NewStackSetController(client clientset.Interface, controllerID string, para HealthReporter: healthcheck.NewHandler(), routeGroupSupportEnabled: routeGroupSupportEnabled, ingressSourceSwitchTTL: ingressSourceSwitchTTL, + configMapSupportEnabled: configMapSupportEnabled, now: now, reconcileWorkers: parallelWork, }, nil @@ -990,12 +1003,14 @@ func (c *StackSetController) ReconcileStackSetDesiredTraffic(ctx context.Context } func (c *StackSetController) ReconcileStackResources(ctx context.Context, ssc *core.StackSetContainer, sc *core.StackContainer) error { - err := c.ReconcileStackConfigMap(ctx, sc.Stack, sc.Resources.ConfigMaps, sc.GenerateConfigMap) - if err != nil { - return c.errorEventf(sc.Stack, "FailedManageConfigMap", err) + if c.configMapSupportEnabled { + err := c.ReconcileStackConfigMap(ctx, sc.Stack, sc.Resources.ConfigMaps, sc.GenerateConfigMap) + if err != nil { + return c.errorEventf(sc.Stack, "FailedManageConfigMap", err) + } } - err = c.ReconcileStackDeployment(ctx, sc.Stack, sc.Resources.Deployment, sc.GenerateDeployment) + err := c.ReconcileStackDeployment(ctx, sc.Stack, sc.Resources.Deployment, sc.GenerateDeployment) if err != nil { return c.errorEventf(sc.Stack, "FailedManageDeployment", err) }