@@ -273,6 +273,7 @@ func (c *kubeControllersComponent) SupportedOSType() rmeta.OSType {
273273
274274func (c * kubeControllersComponent ) Objects () ([]client.Object , []client.Object ) {
275275 objectsToCreate := []client.Object {}
276+ objectsToDelete := []client.Object {}
276277
277278 if c .kubeControllerAllowTigeraPolicy != nil {
278279 objectsToCreate = append (objectsToCreate , c .kubeControllerAllowTigeraPolicy )
@@ -288,13 +289,18 @@ func (c *kubeControllersComponent) Objects() ([]client.Object, []client.Object)
288289 c .controllersServiceAccount (),
289290 c .controllersClusterRole (),
290291 c .controllersClusterRoleBinding (),
291- c .controllersDeployment (),
292292 )
293+ if len (c .enabledControllers ) > 0 {
294+ // There's something to run, so create the deployment.
295+ objectsToCreate = append (objectsToCreate , c .controllersDeployment ())
296+ } else {
297+ // No controllers are enabled, so delete the deployment.
298+ objectsToDelete = append (objectsToDelete , c .controllersDeployment ())
299+ }
293300
294301 if c .cfg .Installation .KubernetesProvider .IsOpenShift () {
295302 objectsToCreate = append (objectsToCreate , c .controllersOCPFederationRoleBinding ())
296303 }
297- objectsToDelete := []client.Object {}
298304 if c .cfg .KubeControllersGatewaySecret != nil {
299305 objectsToCreate = append (objectsToCreate , secret .ToRuntimeObjects (
300306 secret .CopyToNamespace (c .cfg .Namespace , c .cfg .KubeControllersGatewaySecret )... )... )
0 commit comments