Repository: kubernetes-sigs/kubebuilder (language: go)

Issue:
Meta - ComponentConfig scaffolds should not be done by default 
### What broke? What's expected?

Users should have the scaffold of https://github.com/kubernetes-sigs/kubebuilder/blob/master/docs/book/src/component-config-tutorial/testdata/project/config/manager/controller_manager_config.yaml ONLY/when they create the project following the tutorial: https://book.kubebuilder.io/component-config-tutorial/api-changes.html

That means, the scaffold should only be done when we run `kubebuilder init --domain tutorial.kubebuilder.io --component-config`. However, it has been added to the default scaffolds when we run `kubebuilder init` and it has brought confusion since users do not understand how properly use it and that their code in the main.go also needs to be customized accordingly. 

### Reproducing this issue

**Examples:**
- https://github.com/kubernetes-sigs/kubebuilder/pull/2778
- https://github.com/operator-framework/operator-sdk/issues/5884

### KubeBuilder (CLI) Version

3.5.0

### Plugin versions

Therefore, these options would fit in a plugin and should not be a flag. It is only a flag because it was implemented in the past (Kubebuilder 2.X) before the plugin design was introduced. 

- [x] **Proposed changes (Bug FIX)**
a) Ensure that the component config scaffolds are not done by default and are only done when the flag is used - https://github.com/kubernetes-sigs/kubebuilder/pull/2826
b) Review the documentation and ensure that it proper clarifies how it should be used and work - done

- [ ] **Proposed changes in the long term (RFE)**
a) Deprecated the flag
b) Move ComponentConfig behaviour to a plugin that can be used in the init/edit subcommands.



Discussion / hints:
/assign

Fix patch:
diff --git a/docs/book/src/component-config-tutorial/api-changes.md b/docs/book/src/component-config-tutorial/api-changes.md
index 592269dcabb..850fb1411cb 100644
--- a/docs/book/src/component-config-tutorial/api-changes.md
+++ b/docs/book/src/component-config-tutorial/api-changes.md
@@ -67,3 +67,68 @@ mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options)
 With that out of the way, we can get on to defining our new config!
 
 [tutorial-source]: https://github.com/kubernetes-sigs/kubebuilder/tree/master/docs/book/src/component-config-tutorial/testdata/project
+
+Create the file `/config/manager/controller_manager_config.yaml` with the following content:
+
+```yaml
+apiVersion: controller-runtime.sigs.k8s.io/v1alpha1
+kind: ControllerManagerConfig
+health:
+  healthProbeBindAddress: :8081
+metrics:
+  bindAddress: 127.0.0.1:8080
+webhook:
+  port: 9443
+leaderElection:
+  leaderElect: true
+  resourceName: ecaf1259.tutorial.kubebuilder.io
+# leaderElectionReleaseOnCancel defines if the leader should step down volume
+# when the Manager ends. This requires the binary to immediately end when the
+# Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
+# speeds up voluntary leader transitions as the new leader don't have to wait
+# LeaseDuration time first.
+# In the default scaffold provided, the program ends immediately after
+# the manager stops, so would be fine to enable this option. However,
+# if you are doing or is intended to do any operation such as perform cleanups
+# after the manager stops then its usage might be unsafe.
+# leaderElectionReleaseOnCancel: true
+```
+
+Update the file `/config/manager/kustomization.yaml` by adding at the bottom the following content:
+
+```yaml
+generatorOptions:
+  disableNameSuffixHash: true
+
+configMapGenerator:
+- name: manager-config
+  files:
+  - controller_manager_config.yaml
+```
+
+Update the file `default/kustomization.yaml` by adding under the patchesStrategicMerge: the following patch:
+
+# Mount the controller config file for loading manager configurations
+# through a ComponentConfig type
+- manager_config_patch.yaml
+
+Update the file `default/manager_config_patch.yaml` by adding under the spec: the following patch:
+
+```yaml
+spec:
+  template:
+    spec:
+      containers:
+      - name: manager
+        args:
+        - "--config=controller_manager_config.yaml"
+        volumeMounts:
+        - name: manager-config
+          mountPath: /controller_manager_config.yaml
+          subPath: controller_manager_config.yaml
+      volumes:
+      - name: manager-config
+        configMap:
+          name: manager-config
+```
+
diff --git a/pkg/plugins/common/kustomize/v1/scaffolds/init.go b/pkg/plugins/common/kustomize/v1/scaffolds/init.go
index ff12fb03064..bfb5e32c6c4 100644
--- a/pkg/plugins/common/kustomize/v1/scaffolds/init.go
+++ b/pkg/plugins/common/kustomize/v1/scaffolds/init.go
@@ -62,7 +62,7 @@ func (s *initScaffolder) Scaffold() error {
 		machinery.WithConfig(s.config),
 	)
 
-	return scaffold.Execute(
+	templates := []machinery.Builder{
 		&rbac.Kustomization{},
 		&rbac.AuthProxyRole{},
 		&rbac.AuthProxyRoleBinding{},
@@ -74,11 +74,16 @@ func (s *initScaffolder) Scaffold() error {
 		&rbac.ServiceAccount{},
 		&manager.Kustomization{},
 		&manager.Config{Image: imageName},
-		&manager.ControllerManagerConfig{},
 		&kdefault.Kustomization{},
 		&kdefault.ManagerAuthProxyPatch{},
 		&kdefault.ManagerConfigPatch{},
 		&prometheus.Kustomization{},
 		&prometheus.Monitor{},
-	)
+	}
+
+	if s.config.IsComponentConfig() {
+		templates = append(templates, &manager.ControllerManagerConfig{})
+	}
+
+	return scaffold.Execute(templates...)
 }
diff --git a/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/kdefault/kustomization.go b/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/kdefault/kustomization.go
index b6860c307d0..dac2814a2e8 100644
--- a/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/kdefault/kustomization.go
+++ b/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/kdefault/kustomization.go
@@ -76,9 +76,10 @@ patchesStrategicMerge:
 # endpoint w/o any authn/z, please comment the following line.
 - manager_auth_proxy_patch.yaml
 
+{{ if .ComponentConfig }}
 # Mount the controller config file for loading manager configurations
 # through a ComponentConfig type
-{{ if not .ComponentConfig }}#{{ end }}- manager_config_patch.yaml
+- manager_config_patch.yaml{{ end }}
 
 # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
 # crd/kustomization.yaml
diff --git a/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/kdefault/manager_config_patch.go b/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/kdefault/manager_config_patch.go
index fb620573bbe..bf7fce47d95 100644
--- a/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/kdefault/manager_config_patch.go
+++ b/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/kdefault/manager_config_patch.go
@@ -27,6 +27,7 @@ var _ machinery.Template = &ManagerConfigPatch{}
 // ManagerConfigPatch scaffolds a ManagerConfigPatch for a Resource
 type ManagerConfigPatch struct {
 	machinery.TemplateMixin
+	machinery.ComponentConfigMixin
 }
 
 // SetTemplateDefaults implements input.Template
@@ -50,6 +51,7 @@ spec:
     spec:
       containers:
       - name: manager
+{{- if .ComponentConfig }}
         args:
         - "--config=controller_manager_config.yaml"
         volumeMounts:
@@ -60,4 +62,5 @@ spec:
       - name: manager-config
         configMap:
           name: manager-config
+{{- end }}
 `
diff --git a/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/manager/kustomization.go b/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/manager/kustomization.go
index eec807da3d1..1faa0750c30 100644
--- a/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/manager/kustomization.go
+++ b/pkg/plugins/common/kustomize/v1/scaffolds/internal/templates/config/manager/kustomization.go
@@ -27,6 +27,7 @@ var _ machinery.Template = &Kustomization{}
 // Kustomization scaffolds a file that defines the kustomization scheme for the manager folder
 type Kustomization struct {
 	machinery.TemplateMixin
+	machinery.ComponentConfigMixin
 }
 
 // SetTemplateDefaults implements file.Template
@@ -45,6 +46,8 @@ func (f *Kustomization) SetTemplateDefaults() error {
 const kustomizeManagerTemplate = `resources:
 - manager.yaml
 
+{{- if .ComponentConfig }}
+
 generatorOptions:
   disableNameSuffixHash: true
 
@@ -52,4 +55,5 @@ configMapGenerator:
 - name: manager-config
   files:
   - controller_manager_config.yaml
+{{- end }}
 `
diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/init.go b/pkg/plugins/common/kustomize/v2-alpha/scaffolds/init.go
index 5eba7a17b8b..f19334e2199 100644
--- a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/init.go
+++ b/pkg/plugins/common/kustomize/v2-alpha/scaffolds/init.go
@@ -62,7 +62,7 @@ func (s *initScaffolder) Scaffold() error {
 		machinery.WithConfig(s.config),
 	)
 
-	return scaffold.Execute(
+	templates := []machinery.Builder{
 		&rbac.Kustomization{},
 		&rbac.AuthProxyRole{},
 		&rbac.AuthProxyRoleBinding{},
@@ -74,11 +74,16 @@ func (s *initScaffolder) Scaffold() error {
 		&rbac.ServiceAccount{},
 		&manager.Kustomization{},
 		&manager.Config{Image: imageName},
-		&manager.ControllerManagerConfig{},
 		&kdefault.Kustomization{},
 		&kdefault.ManagerAuthProxyPatch{},
 		&kdefault.ManagerConfigPatch{},
 		&prometheus.Kustomization{},
 		&prometheus.Monitor{},
-	)
+	}
+
+	if s.config.IsComponentConfig() {
+		templates = append(templates, &manager.ControllerManagerConfig{})
+	}
+
+	return scaffold.Execute(templates...)
 }
diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault/kustomization.go b/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault/kustomization.go
index 0f8dbe2696e..4919a8d8c9b 100644
--- a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault/kustomization.go
+++ b/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault/kustomization.go
@@ -78,9 +78,10 @@ patchesStrategicMerge:
 # endpoint w/o any authn/z, please comment the following line.
 - manager_auth_proxy_patch.yaml
 
+{{ if .ComponentConfig }}
 # Mount the controller config file for loading manager configurations
 # through a ComponentConfig type
-{{ if not .ComponentConfig }}#{{ end }}- manager_config_patch.yaml
+- manager_config_patch.yaml{{ end }}
 
 # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
 # crd/kustomization.yaml
diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault/manager_config_patch.go b/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault/manager_config_patch.go
index fb620573bbe..bf7fce47d95 100644
--- a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault/manager_config_patch.go
+++ b/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault/manager_config_patch.go
@@ -27,6 +27,7 @@ var _ machinery.Template = &ManagerConfigPatch{}
 // ManagerConfigPatch scaffolds a ManagerConfigPatch for a Resource
 type ManagerConfigPatch struct {
 	machinery.TemplateMixin
+	machinery.ComponentConfigMixin
 }
 
 // SetTemplateDefaults implements input.Template
@@ -50,6 +51,7 @@ spec:
     spec:
       containers:
       - name: manager
+{{- if .ComponentConfig }}
         args:
         - "--config=controller_manager_config.yaml"
         volumeMounts:
@@ -60,4 +62,5 @@ spec:
       - name: manager-config
         configMap:
           name: manager-config
+{{- end }}
 `
diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/manager/kustomization.go b/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/manager/kustomization.go
index eec807da3d1..1faa0750c30 100644
--- a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/manager/kustomization.go
+++ b/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/manager/kustomization.go
@@ -27,6 +27,7 @@ var _ machinery.Template = &Kustomization{}
 // Kustomization scaffolds a file that defines the kustomization scheme for the manager folder
 type Kustomization struct {
 	machinery.TemplateMixin
+	machinery.ComponentConfigMixin
 }
 
 // SetTemplateDefaults implements file.Template
@@ -45,6 +46,8 @@ func (f *Kustomization) SetTemplateDefaults() error {
 const kustomizeManagerTemplate = `resources:
 - manager.yaml
 
+{{- if .ComponentConfig }}
+
 generatorOptions:
   disableNameSuffixHash: true
 
@@ -52,4 +55,5 @@ configMapGenerator:
 - name: manager-config
   files:
   - controller_manager_config.yaml
+{{- end }}
 `


Test patch:
diff --git a/test/e2e/v3/generate_test.go b/test/e2e/v3/generate_test.go
index ba8ff503eac..77453180cca 100644
--- a/test/e2e/v3/generate_test.go
+++ b/test/e2e/v3/generate_test.go
@@ -235,6 +235,113 @@ Count int `+"`"+`json:"count,omitempty"`+"`"+`
 	}
 }
 
+// GenerateV3 implements a go/v3(-alpha) plugin project defined by a TestContext.
+func GenerateV3ComponentConfig(kbc *utils.TestContext, crdAndWebhookVersion string) {
+	var err error
+
+	By("initializing a project")
+	err = kbc.Init(
+		"--plugins", "go/v3",
+		"--project-version", "3",
+		"--domain", kbc.Domain,
+		"--fetch-deps=false",
+		"--component-config=true",
+	)
+	ExpectWithOffset(1, err).NotTo(HaveOccurred())
+
+	By("creating API definition")
+	err = kbc.CreateAPI(
+		"--group", kbc.Group,
+		"--version", kbc.Version,
+		"--kind", kbc.Kind,
+		"--namespaced",
+		"--resource",
+		"--controller",
+		"--make=false",
+		"--crd-version", crdAndWebhookVersion,
+	)
+	ExpectWithOffset(1, err).NotTo(HaveOccurred())
+
+	By("implementing the API")
+	ExpectWithOffset(1, pluginutil.InsertCode(
+		filepath.Join(kbc.Dir, "api", kbc.Version, fmt.Sprintf("%s_types.go", strings.ToLower(kbc.Kind))),
+		fmt.Sprintf(`type %sSpec struct {
+`, kbc.Kind),
+		`	// +optional
+Count int `+"`"+`json:"count,omitempty"`+"`"+`
+`)).Should(Succeed())
+
+	By("scaffolding mutating and validating webhooks")
+	err = kbc.CreateWebhook(
+		"--group", kbc.Group,
+		"--version", kbc.Version,
+		"--kind", kbc.Kind,
+		"--defaulting",
+		"--programmatic-validation",
+		"--webhook-version", crdAndWebhookVersion,
+	)
+	ExpectWithOffset(1, err).NotTo(HaveOccurred())
+
+	By("implementing the mutating and validating webhooks")
+	err = pluginutil.ImplementWebhooks(filepath.Join(
+		kbc.Dir, "api", kbc.Version,
+		fmt.Sprintf("%s_webhook.go", strings.ToLower(kbc.Kind))))
+	ExpectWithOffset(1, err).NotTo(HaveOccurred())
+
+	By("uncomment kustomization.yaml to enable webhook and ca injection")
+	ExpectWithOffset(1, pluginutil.UncommentCode(
+		filepath.Join(kbc.Dir, "config", "default", "kustomization.yaml"),
+		"#- ../webhook", "#")).To(Succeed())
+	ExpectWithOffset(1, pluginutil.UncommentCode(
+		filepath.Join(kbc.Dir, "config", "default", "kustomization.yaml"),
+		"#- ../certmanager", "#")).To(Succeed())
+	ExpectWithOffset(1, pluginutil.UncommentCode(
+		filepath.Join(kbc.Dir, "config", "default", "kustomization.yaml"),
+		"#- ../prometheus", "#")).To(Succeed())
+	ExpectWithOffset(1, pluginutil.UncommentCode(
+		filepath.Join(kbc.Dir, "config", "default", "kustomization.yaml"),
+		"#- manager_webhook_patch.yaml", "#")).To(Succeed())
+	ExpectWithOffset(1, pluginutil.UncommentCode(
+		filepath.Join(kbc.Dir, "config", "default", "kustomization.yaml"),
+		"#- webhookcainjection_patch.yaml", "#")).To(Succeed())
+	ExpectWithOffset(1, pluginutil.UncommentCode(filepath.Join(kbc.Dir, "config", "default", "kustomization.yaml"),
+		`#- name: CERTIFICATE_NAMESPACE # namespace of the certificate CR
+#  objref:
+#    kind: Certificate
+#    group: cert-manager.io
+#    version: v1
+#    name: serving-cert # this name should match the one in certificate.yaml
+#  fieldref:
+#    fieldpath: metadata.namespace
+#- name: CERTIFICATE_NAME
+#  objref:
+#    kind: Certificate
+#    group: cert-manager.io
+#    version: v1
+#    name: serving-cert # this name should match the one in certificate.yaml
+#- name: SERVICE_NAMESPACE # namespace of the service
+#  objref:
+#    kind: Service
+#    version: v1
+#    name: webhook-service
+#  fieldref:
+#    fieldpath: metadata.namespace
+#- name: SERVICE_NAME
+#  objref:
+#    kind: Service
+#    version: v1
+#    name: webhook-service`, "#")).To(Succeed())
+
+	if crdAndWebhookVersion == "v1beta1" {
+		_ = pluginutil.RunCmd("Update dependencies", "go", "mod", "tidy")
+	}
+
+	if kbc.IsRestricted {
+		By("uncomment kustomize files to ensure that pods are restricted")
+		uncommentPodStandards(kbc)
+	}
+}
+
 func uncommentPodStandards(kbc *utils.TestContext) {
 	configManager := filepath.Join(kbc.Dir, "config", "manager", "manager.yaml")
 
diff --git a/test/e2e/v3/plugin_cluster_test.go b/test/e2e/v3/plugin_cluster_test.go
index fed9a31bf8e..547dcae06b5 100644
--- a/test/e2e/v3/plugin_cluster_test.go
+++ b/test/e2e/v3/plugin_cluster_test.go
@@ -174,6 +174,17 @@ var _ = Describe("kubebuilder", func() {
 				GenerateV3(kbc, "v1beta1")
 				Run(kbc)
 			})
+			It("should generate a runnable project go/v3 with v1 CRDs and Webhooks"+
+				"with --component-config flag enabled", func() {
+				// Skip if cluster version < 1.16, when v1 CRDs and webhooks did not exist.
+				if srvVer := kbc.K8sVersion.ServerVersion; srvVer.GetMajorInt() <= 1 && srvVer.GetMinorInt() < 16 {
+					Skip(fmt.Sprintf("cluster version %s does not support v1 CRDs or webhooks",
+						srvVer.GitVersion))
+				}
+
+				GenerateV3ComponentConfig(kbc, "v1")
+				Run(kbc)
+			})
 		})
 	})
 })
diff --git a/test/e2e/v4/generate_test.go b/test/e2e/v4/generate_test.go
index fadfa10e0fe..e6daf07efa8 100644
--- a/test/e2e/v4/generate_test.go
+++ b/test/e2e/v4/generate_test.go
@@ -204,6 +204,177 @@ Count int `+"`"+`json:"count,omitempty"`+"`"+`
 	}
 }
 
+// GenerateV4 implements a go/v4(-alpha) plugin project defined by a TestContext.
+func GenerateV4ComponentConfig(kbc *utils.TestContext) {
+	var err error
+
+	By("initializing a project")
+	err = kbc.Init(
+		"--plugins", "go/v4-alpha",
+		"--project-version", "3",
+		"--domain", kbc.Domain,
+		"--component-config=true",
+	)
+	ExpectWithOffset(1, err).NotTo(HaveOccurred())
+
+	By("creating API definition")
+	err = kbc.CreateAPI(
+		"--group", kbc.Group,
+		"--version", kbc.Version,
+		"--kind", kbc.Kind,
+		"--namespaced",
+		"--resource",
+		"--controller",
+		"--make=false",
+	)
+	ExpectWithOffset(1, err).NotTo(HaveOccurred())
+
+	By("implementing the API")
+	ExpectWithOffset(1, pluginutil.InsertCode(
+		filepath.Join(kbc.Dir, "api", kbc.Version, fmt.Sprintf("%s_types.go", strings.ToLower(kbc.Kind))),
+		fmt.Sprintf(`type %sSpec struct {
+`, kbc.Kind),
+		`	// +optional
+Count int `+"`"+`json:"count,omitempty"`+"`"+`
+`)).Should(Succeed())
+
+	By("scaffolding mutating and validating webhooks")
+	err = kbc.CreateWebhook(
+		"--group", kbc.Group,
+		"--version", kbc.Version,
+		"--kind", kbc.Kind,
+		"--defaulting",
+		"--programmatic-validation",
+	)
+	ExpectWithOffset(1, err).NotTo(HaveOccurred())
+
+	By("implementing the mutating and validating webhooks")
+	err = pluginutil.ImplementWebhooks(filepath.Join(
+		kbc.Dir, "api", kbc.Version,
+		fmt.Sprintf("%s_webhook.go", strings.ToLower(kbc.Kind))))
+	ExpectWithOffset(1, err).NotTo(HaveOccurred())
+
+	By("uncomment kustomization.yaml to enable webhook and ca injection")
+	ExpectWithOffset(1, pluginutil.UncommentCode(
+		filepath.Join(kbc.Dir, "config", "default", "kustomization.yaml"),
+		"#- ../webhook", "#")).To(Succeed())
+	ExpectWithOffset(1, pluginutil.UncommentCode(
+		filepath.Join(kbc.Dir, "config", "default", "kustomization.yaml"),
+		"#- ../certmanager", "#")).To(Succeed())
+	ExpectWithOffset(1, pluginutil.UncommentCode(
+		filepath.Join(kbc.Dir, "config", "default", "kustomization.yaml"),
+		"#- ../prometheus", "#")).To(Succeed())
+	ExpectWithOffset(1, pluginutil.UncommentCode(
+		filepath.Join(kbc.Dir, "config", "default", "kustomization.yaml"),
+		"#- manager_webhook_patch.yaml", "#")).To(Succeed())
+	ExpectWithOffset(1, pluginutil.UncommentCode(
+		filepath.Join(kbc.Dir, "config", "default", "kustomization.yaml"),
+		"#- webhookcainjection_patch.yaml", "#")).To(Succeed())
+	ExpectWithOffset(1, pluginutil.UncommentCode(filepath.Join(kbc.Dir, "config", "default", "kustomization.yaml"),
+		`#replacements:
+#  - source: # Add cert-manager annotation to ValidatingWebhookConfiguration, MutatingWebhookConfiguration and CRDs
+#      kind: Certificate
+#      group: cert-manager.io
+#      version: v1
+#      name: serving-cert # this name should match the one in certificate.yaml
+#      fieldPath: .metadata.namespace # namespace of the certificate CR
+#    targets:
+#      - select:
+#          kind: ValidatingWebhookConfiguration
+#        fieldPaths:
+#          - .metadata.annotations.[cert-manager.io/inject-ca-from]
+#        options:
+#          delimiter: '/'
+#          index: 0
+#          create: true
+#      - select:
+#          kind: MutatingWebhookConfiguration
+#        fieldPaths:
+#          - .metadata.annotations.[cert-manager.io/inject-ca-from]
+#        options:
+#          delimiter: '/'
+#          index: 0
+#          create: true
+#      - select:
+#          kind: CustomResourceDefinition
+#        fieldPaths:
+#          - .metadata.annotations.[cert-manager.io/inject-ca-from]
+#        options:
+#          delimiter: '/'
+#          index: 0
+#          create: true
+#  - source:
+#      kind: Certificate
+#      group: cert-manager.io
+#      version: v1
+#      name: serving-cert # this name should match the one in certificate.yaml
+#      fieldPath: .metadata.name
+#    targets:
+#      - select:
+#          kind: ValidatingWebhookConfiguration
+#        fieldPaths:
+#          - .metadata.annotations.[cert-manager.io/inject-ca-from]
+#        options:
+#          delimiter: '/'
+#          index: 1
+#          create: true
+#      - select:
+#          kind: MutatingWebhookConfiguration
+#        fieldPaths:
+#          - .metadata.annotations.[cert-manager.io/inject-ca-from]
+#        options:
+#          delimiter: '/'
+#          index: 1
+#          create: true
+#      - select:
+#          kind: CustomResourceDefinition
+#        fieldPaths:
+#          - .metadata.annotations.[cert-manager.io/inject-ca-from]
+#        options:
+#          delimiter: '/'
+#          index: 1
+#          create: true
+#  - source: # Add cert-manager annotation to the webhook Service
+#      kind: Service
+#      version: v1
+#      name: webhook-service
+#      fieldPath: .metadata.name # namespace of the service
+#    targets:
+#      - select:
+#          kind: Certificate
+#          group: cert-manager.io
+#          version: v1
+#        fieldPaths:
+#          - .spec.dnsNames.0
+#          - .spec.dnsNames.1
+#        options:
+#          delimiter: '.'
+#          index: 0
+#          create: true
+#  - source:
+#      kind: Service
+#      version: v1
+#      name: webhook-service
+#      fieldPath: .metadata.namespace # namespace of the service
+#    targets:
+#      - select:
+#          kind: Certificate
+#          group: cert-manager.io
+#          version: v1
+#        fieldPaths:
+#          - .spec.dnsNames.0
+#          - .spec.dnsNames.1
+#        options:
+#          delimiter: '.'
+#          index: 1
+#          create: true`, "#")).To(Succeed())
+
+	if kbc.IsRestricted {
+		By("uncomment kustomize files to ensure that pods are restricted")
+		uncommentPodStandards(kbc)
+	}
+}
+
 func uncommentPodStandards(kbc *utils.TestContext) {
 	configManager := filepath.Join(kbc.Dir, "config", "manager", "manager.yaml")
 
diff --git a/test/e2e/v4/plugin_cluster_test.go b/test/e2e/v4/plugin_cluster_test.go
index 2afa5908d29..59a4b755a9e 100644
--- a/test/e2e/v4/plugin_cluster_test.go
+++ b/test/e2e/v4/plugin_cluster_test.go
@@ -97,6 +97,21 @@ var _ = Describe("kubebuilder", func() {
 			GenerateV4(kbc)
 			Run(kbc)
 		})
+
+		It("should generate a runnable project"+
+			" with restricted pods and with --component-config field enabled", func() {
+			// Skip if cluster version < 1.16, when v1 CRDs and webhooks did not exist.
+			// Skip if cluster version < 1.19, because securityContext.seccompProfile only works from 1.19
+			// Otherwise, unknown field "seccompProfile" in io.k8s.api.core.v1.PodSecurityContext will be faced
+			if srvVer := kbc.K8sVersion.ServerVersion; srvVer.GetMajorInt() <= 1 && srvVer.GetMinorInt() < 19 {
+				Skip(fmt.Sprintf("cluster version %s does not support v1 CRDs or webhooks "+
+					"and securityContext.seccompProfile", srvVer.GitVersion))
+			}
+
+			kbc.IsRestricted = true
+			GenerateV4ComponentConfig(kbc)
+			Run(kbc)
+		})
 	})
 })
 
diff --git a/testdata/project-v3-addon-and-grafana/config/default/kustomization.yaml b/testdata/project-v3-addon-and-grafana/config/default/kustomization.yaml
index 47e14c303aa..f46d62e16ef 100644
--- a/testdata/project-v3-addon-and-grafana/config/default/kustomization.yaml
+++ b/testdata/project-v3-addon-and-grafana/config/default/kustomization.yaml
@@ -30,9 +30,7 @@ patchesStrategicMerge:
 # endpoint w/o any authn/z, please comment the following line.
 - manager_auth_proxy_patch.yaml
 
-# Mount the controller config file for loading manager configurations
-# through a ComponentConfig type
-#- manager_config_patch.yaml
+
 
 # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
 # crd/kustomization.yaml
diff --git a/testdata/project-v3-addon-and-grafana/config/default/manager_config_patch.yaml b/testdata/project-v3-addon-and-grafana/config/default/manager_config_patch.yaml
index 6c400155cfb..f6f58916922 100644
--- a/testdata/project-v3-addon-and-grafana/config/default/manager_config_patch.yaml
+++ b/testdata/project-v3-addon-and-grafana/config/default/manager_config_patch.yaml
@@ -8,13 +8,3 @@ spec:
     spec:
       containers:
       - name: manager
-        args:
-        - "--config=controller_manager_config.yaml"
-        volumeMounts:
-        - name: manager-config
-          mountPath: /controller_manager_config.yaml
-          subPath: controller_manager_config.yaml
-      volumes:
-      - name: manager-config
-        configMap:
-          name: manager-config
diff --git a/testdata/project-v3-addon-and-grafana/config/manager/controller_manager_config.yaml b/testdata/project-v3-addon-and-grafana/config/manager/controller_manager_config.yaml
deleted file mode 100644
index 92f10de71d0..00000000000
--- a/testdata/project-v3-addon-and-grafana/config/manager/controller_manager_config.yaml
+++ /dev/null
@@ -1,21 +0,0 @@
-apiVersion: controller-runtime.sigs.k8s.io/v1alpha1
-kind: ControllerManagerConfig
-health:
-  healthProbeBindAddress: :8081
-metrics:
-  bindAddress: 127.0.0.1:8080
-webhook:
-  port: 9443
-leaderElection:
-  leaderElect: true
-  resourceName: 5a3ee359.testproject.org
-# leaderElectionReleaseOnCancel defines if the leader should step down volume
-# when the Manager ends. This requires the binary to immediately end when the
-# Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
-# speeds up voluntary leader transitions as the new leader don't have to wait
-# LeaseDuration time first.
-# In the default scaffold provided, the program ends immediately after
-# the manager stops, so would be fine to enable this option. However,
-# if you are doing or is intended to do any operation such as perform cleanups
-# after the manager stops then its usage might be unsafe.
-# leaderElectionReleaseOnCancel: true
diff --git a/testdata/project-v3-addon-and-grafana/config/manager/kustomization.yaml b/testdata/project-v3-addon-and-grafana/config/manager/kustomization.yaml
index 2bcd3eeaa94..5c5f0b84cba 100644
--- a/testdata/project-v3-addon-and-grafana/config/manager/kustomization.yaml
+++ b/testdata/project-v3-addon-and-grafana/config/manager/kustomization.yaml
@@ -1,10 +1,2 @@
 resources:
 - manager.yaml
-
-generatorOptions:
-  disableNameSuffixHash: true
-
-configMapGenerator:
-- name: manager-config
-  files:
-  - controller_manager_config.yaml
diff --git a/testdata/project-v3-config/config/default/kustomization.yaml b/testdata/project-v3-config/config/default/kustomization.yaml
index 53d22a3b176..83ed9be71a3 100644
--- a/testdata/project-v3-config/config/default/kustomization.yaml
+++ b/testdata/project-v3-config/config/default/kustomization.yaml
@@ -30,6 +30,7 @@ patchesStrategicMerge:
 # endpoint w/o any authn/z, please comment the following line.
 - manager_auth_proxy_patch.yaml
 
+
 # Mount the controller config file for loading manager configurations
 # through a ComponentConfig type
 - manager_config_patch.yaml
diff --git a/testdata/project-v3-multigroup/config/default/kustomization.yaml b/testdata/project-v3-multigroup/config/default/kustomization.yaml
index 5391c2c6431..d59152e6443 100644
--- a/testdata/project-v3-multigroup/config/default/kustomization.yaml
+++ b/testdata/project-v3-multigroup/config/default/kustomization.yaml
@@ -30,9 +30,7 @@ patchesStrategicMerge:
 # endpoint w/o any authn/z, please comment the following line.
 - manager_auth_proxy_patch.yaml
 
-# Mount the controller config file for loading manager configurations
-# through a ComponentConfig type
-#- manager_config_patch.yaml
+
 
 # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
 # crd/kustomization.yaml
diff --git a/testdata/project-v3-multigroup/config/default/manager_config_patch.yaml b/testdata/project-v3-multigroup/config/default/manager_config_patch.yaml
index 6c400155cfb..f6f58916922 100644
--- a/testdata/project-v3-multigroup/config/default/manager_config_patch.yaml
+++ b/testdata/project-v3-multigroup/config/default/manager_config_patch.yaml
@@ -8,13 +8,3 @@ spec:
     spec:
       containers:
       - name: manager
-        args:
-        - "--config=controller_manager_config.yaml"
-        volumeMounts:
-        - name: manager-config
-          mountPath: /controller_manager_config.yaml
-          subPath: controller_manager_config.yaml
-      volumes:
-      - name: manager-config
-        configMap:
-          name: manager-config
diff --git a/testdata/project-v3-multigroup/config/manager/controller_manager_config.yaml b/testdata/project-v3-multigroup/config/manager/controller_manager_config.yaml
deleted file mode 100644
index e69e1d7f679..00000000000
--- a/testdata/project-v3-multigroup/config/manager/controller_manager_config.yaml
+++ /dev/null
@@ -1,21 +0,0 @@
-apiVersion: controller-runtime.sigs.k8s.io/v1alpha1
-kind: ControllerManagerConfig
-health:
-  healthProbeBindAddress: :8081
-metrics:
-  bindAddress: 127.0.0.1:8080
-webhook:
-  port: 9443
-leaderElection:
-  leaderElect: true
-  resourceName: 14be1926.testproject.org
-# leaderElectionReleaseOnCancel defines if the leader should step down volume
-# when the Manager ends. This requires the binary to immediately end when the
-# Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
-# speeds up voluntary leader transitions as the new leader don't have to wait
-# LeaseDuration time first.
-# In the default scaffold provided, the program ends immediately after
-# the manager stops, so would be fine to enable this option. However,
-# if you are doing or is intended to do any operation such as perform cleanups
-# after the manager stops then its usage might be unsafe.
-# leaderElectionReleaseOnCancel: true
diff --git a/testdata/project-v3-multigroup/config/manager/kustomization.yaml b/testdata/project-v3-multigroup/config/manager/kustomization.yaml
index 2bcd3eeaa94..5c5f0b84cba 100644
--- a/testdata/project-v3-multigroup/config/manager/kustomization.yaml
+++ b/testdata/project-v3-multigroup/config/manager/kustomization.yaml
@@ -1,10 +1,2 @@
 resources:
 - manager.yaml
-
-generatorOptions:
-  disableNameSuffixHash: true
-
-configMapGenerator:
-- name: manager-config
-  files:
-  - controller_manager_config.yaml
diff --git a/testdata/project-v3-with-deploy-image/config/default/kustomization.yaml b/testdata/project-v3-with-deploy-image/config/default/kustomization.yaml
index c6dd3c530d5..dfc8fbc85ab 100644
--- a/testdata/project-v3-with-deploy-image/config/default/kustomization.yaml
+++ b/testdata/project-v3-with-deploy-image/config/default/kustomization.yaml
@@ -30,9 +30,7 @@ patchesStrategicMerge:
 # endpoint w/o any authn/z, please comment the following line.
 - manager_auth_proxy_patch.yaml
 
-# Mount the controller config file for loading manager configurations
-# through a ComponentConfig type
-#- manager_config_patch.yaml
+
 
 # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
 # crd/kustomization.yaml
diff --git a/testdata/project-v3-with-deploy-image/config/default/manager_config_patch.yaml b/testdata/project-v3-with-deploy-image/config/default/manager_config_patch.yaml
index 6c400155cfb..f6f58916922 100644
--- a/testdata/project-v3-with-deploy-image/config/default/manager_config_patch.yaml
+++ b/testdata/project-v3-with-deploy-image/config/default/manager_config_patch.yaml
@@ -8,13 +8,3 @@ spec:
     spec:
       containers:
       - name: manager
-        args:
-        - "--config=controller_manager_config.yaml"
-        volumeMounts:
-        - name: manager-config
-          mountPath: /controller_manager_config.yaml
-          subPath: controller_manager_config.yaml
-      volumes:
-      - name: manager-config
-        configMap:
-          name: manager-config
diff --git a/testdata/project-v3-with-deploy-image/config/manager/controller_manager_config.yaml b/testdata/project-v3-with-deploy-image/config/manager/controller_manager_config.yaml
deleted file mode 100644
index 95af7d3eef1..00000000000
--- a/testdata/project-v3-with-deploy-image/config/manager/controller_manager_config.yaml
+++ /dev/null
@@ -1,21 +0,0 @@
-apiVersion: controller-runtime.sigs.k8s.io/v1alpha1
-kind: ControllerManagerConfig
-health:
-  healthProbeBindAddress: :8081
-metrics:
-  bindAddress: 127.0.0.1:8080
-webhook:
-  port: 9443
-leaderElection:
-  leaderElect: true
-  resourceName: 4d73a076.testproject.org
-# leaderElectionReleaseOnCancel defines if the leader should step down volume
-# when the Manager ends. This requires the binary to immediately end when the
-# Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
-# speeds up voluntary leader transitions as the new leader don't have to wait
-# LeaseDuration time first.
-# In the default scaffold provided, the program ends immediately after
-# the manager stops, so would be fine to enable this option. However,
-# if you are doing or is intended to do any operation such as perform cleanups
-# after the manager stops then its usage might be unsafe.
-# leaderElectionReleaseOnCancel: true
diff --git a/testdata/project-v3-with-deploy-image/config/manager/kustomization.yaml b/testdata/project-v3-with-deploy-image/config/manager/kustomization.yaml
index 2bcd3eeaa94..5c5f0b84cba 100644
--- a/testdata/project-v3-with-deploy-image/config/manager/kustomization.yaml
+++ b/testdata/project-v3-with-deploy-image/config/manager/kustomization.yaml
@@ -1,10 +1,2 @@
 resources:
 - manager.yaml
-
-generatorOptions:
-  disableNameSuffixHash: true
-
-configMapGenerator:
-- name: manager-config
-  files:
-  - controller_manager_config.yaml
diff --git a/testdata/project-v3/config/default/kustomization.yaml b/testdata/project-v3/config/default/kustomization.yaml
index 3680acb0fdd..9f11a640f62 100644
--- a/testdata/project-v3/config/default/kustomization.yaml
+++ b/testdata/project-v3/config/default/kustomization.yaml
@@ -30,9 +30,7 @@ patchesStrategicMerge:
 # endpoint w/o any authn/z, please comment the following line.
 - manager_auth_proxy_patch.yaml
 
-# Mount the controller config file for loading manager configurations
-# through a ComponentConfig type
-#- manager_config_patch.yaml
+
 
 # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
 # crd/kustomization.yaml
diff --git a/testdata/project-v3/config/default/manager_config_patch.yaml b/testdata/project-v3/config/default/manager_config_patch.yaml
index 6c400155cfb..f6f58916922 100644
--- a/testdata/project-v3/config/default/manager_config_patch.yaml
+++ b/testdata/project-v3/config/default/manager_config_patch.yaml
@@ -8,13 +8,3 @@ spec:
     spec:
       containers:
       - name: manager
-        args:
-        - "--config=controller_manager_config.yaml"
-        volumeMounts:
-        - name: manager-config
-          mountPath: /controller_manager_config.yaml
-          subPath: controller_manager_config.yaml
-      volumes:
-      - name: manager-config
-        configMap:
-          name: manager-config
diff --git a/testdata/project-v3/config/manager/controller_manager_config.yaml b/testdata/project-v3/config/manager/controller_manager_config.yaml
deleted file mode 100644
index c3215af535b..00000000000
--- a/testdata/project-v3/config/manager/controller_manager_config.yaml
+++ /dev/null
@@ -1,21 +0,0 @@
-apiVersion: controller-runtime.sigs.k8s.io/v1alpha1
-kind: ControllerManagerConfig
-health:
-  healthProbeBindAddress: :8081
-metrics:
-  bindAddress: 127.0.0.1:8080
-webhook:
-  port: 9443
-leaderElection:
-  leaderElect: true
-  resourceName: dd1da13f.testproject.org
-# leaderElectionReleaseOnCancel defines if the leader should step down volume
-# when the Manager ends. This requires the binary to immediately end when the
-# Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
-# speeds up voluntary leader transitions as the new leader don't have to wait
-# LeaseDuration time first.
-# In the default scaffold provided, the program ends immediately after
-# the manager stops, so would be fine to enable this option. However,
-# if you are doing or is intended to do any operation such as perform cleanups
-# after the manager stops then its usage might be unsafe.
-# leaderElectionReleaseOnCancel: true
diff --git a/testdata/project-v3/config/manager/kustomization.yaml b/testdata/project-v3/config/manager/kustomization.yaml
index 2bcd3eeaa94..5c5f0b84cba 100644
--- a/testdata/project-v3/config/manager/kustomization.yaml
+++ b/testdata/project-v3/config/manager/kustomization.yaml
@@ -1,10 +1,2 @@
 resources:
 - manager.yaml
-
-generatorOptions:
-  disableNameSuffixHash: true
-
-configMapGenerator:
-- name: manager-config
-  files:
-  - controller_manager_config.yaml
diff --git a/testdata/project-v4-addon-and-grafana/config/default/kustomization.yaml b/testdata/project-v4-addon-and-grafana/config/default/kustomization.yaml
index e3ad74ca4e6..a338c345638 100644
--- a/testdata/project-v4-addon-and-grafana/config/default/kustomization.yaml
+++ b/testdata/project-v4-addon-and-grafana/config/default/kustomization.yaml
@@ -32,9 +32,7 @@ patchesStrategicMerge:
 # endpoint w/o any authn/z, please comment the following line.
 - manager_auth_proxy_patch.yaml
 
-# Mount the controller config file for loading manager configurations
-# through a ComponentConfig type
-#- manager_config_patch.yaml
+
 
 # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
 # crd/kustomization.yaml
diff --git a/testdata/project-v4-addon-and-grafana/config/default/manager_config_patch.yaml b/testdata/project-v4-addon-and-grafana/config/default/manager_config_patch.yaml
index 6c400155cfb..f6f58916922 100644
--- a/testdata/project-v4-addon-and-grafana/config/default/manager_config_patch.yaml
+++ b/testdata/project-v4-addon-and-grafana/config/default/manager_config_patch.yaml
@@ -8,13 +8,3 @@ spec:
     spec:
       containers:
       - name: manager
-        args:
-        - "--config=controller_manager_config.yaml"
-        volumeMounts:
-        - name: manager-config
-          mountPath: /controller_manager_config.yaml
-          subPath: controller_manager_config.yaml
-      volumes:
-      - name: manager-config
-        configMap:
-          name: manager-config
diff --git a/testdata/project-v4-addon-and-grafana/config/manager/controller_manager_config.yaml b/testdata/project-v4-addon-and-grafana/config/manager/controller_manager_config.yaml
deleted file mode 100644
index 13caecd4b34..00000000000
--- a/testdata/project-v4-addon-and-grafana/config/manager/controller_manager_config.yaml
+++ /dev/null
@@ -1,21 +0,0 @@
-apiVersion: controller-runtime.sigs.k8s.io/v1alpha1
-kind: ControllerManagerConfig
-health:
-  healthProbeBindAddress: :8081
-metrics:
-  bindAddress: 127.0.0.1:8080
-webhook:
-  port: 9443
-leaderElection:
-  leaderElect: true
-  resourceName: 52a2c700.testproject.org
-# leaderElectionReleaseOnCancel defines if the leader should step down volume
-# when the Manager ends. This requires the binary to immediately end when the
-# Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
-# speeds up voluntary leader transitions as the new leader don't have to wait
-# LeaseDuration time first.
-# In the default scaffold provided, the program ends immediately after
-# the manager stops, so would be fine to enable this option. However,
-# if you are doing or is intended to do any operation such as perform cleanups
-# after the manager stops then its usage might be unsafe.
-# leaderElectionReleaseOnCancel: true
diff --git a/testdata/project-v4-addon-and-grafana/config/manager/kustomization.yaml b/testdata/project-v4-addon-and-grafana/config/manager/kustomization.yaml
index 2bcd3eeaa94..5c5f0b84cba 100644
--- a/testdata/project-v4-addon-and-grafana/config/manager/kustomization.yaml
+++ b/testdata/project-v4-addon-and-grafana/config/manager/kustomization.yaml
@@ -1,10 +1,2 @@
 resources:
 - manager.yaml
-
-generatorOptions:
-  disableNameSuffixHash: true
-
-configMapGenerator:
-- name: manager-config
-  files:
-  - controller_manager_config.yaml
diff --git a/testdata/project-v4-config/config/default/kustomization.yaml b/testdata/project-v4-config/config/default/kustomization.yaml
index 72a3e40c046..6ff4eea9962 100644
--- a/testdata/project-v4-config/config/default/kustomization.yaml
+++ b/testdata/project-v4-config/config/default/kustomization.yaml
@@ -32,6 +32,7 @@ patchesStrategicMerge:
 # endpoint w/o any authn/z, please comment the following line.
 - manager_auth_proxy_patch.yaml
 
+
 # Mount the controller config file for loading manager configurations
 # through a ComponentConfig type
 - manager_config_patch.yaml
diff --git a/testdata/project-v4-multigroup/config/default/kustomization.yaml b/testdata/project-v4-multigroup/config/default/kustomization.yaml
index ea4beb39a17..baea92fc167 100644
--- a/testdata/project-v4-multigroup/config/default/kustomization.yaml
+++ b/testdata/project-v4-multigroup/config/default/kustomization.yaml
@@ -32,9 +32,7 @@ patchesStrategicMerge:
 # endpoint w/o any authn/z, please comment the following line.
 - manager_auth_proxy_patch.yaml
 
-# Mount the controller config file for loading manager configurations
-# through a ComponentConfig type
-#- manager_config_patch.yaml
+
 
 # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
 # crd/kustomization.yaml
diff --git a/testdata/project-v4-multigroup/config/default/manager_config_patch.yaml b/testdata/project-v4-multigroup/config/default/manager_config_patch.yaml
index 6c400155cfb..f6f58916922 100644
--- a/testdata/project-v4-multigroup/config/default/manager_config_patch.yaml
+++ b/testdata/project-v4-multigroup/config/default/manager_config_patch.yaml
@@ -8,13 +8,3 @@ spec:
     spec:
       containers:
       - name: manager
-        args:
-        - "--config=controller_manager_config.yaml"
-        volumeMounts:
-        - name: manager-config
-          mountPath: /controller_manager_config.yaml
-          subPath: controller_manager_config.yaml
-      volumes:
-      - name: manager-config
-        configMap:
-          name: manager-config
diff --git a/testdata/project-v4-multigroup/config/manager/controller_manager_config.yaml b/testdata/project-v4-multigroup/config/manager/controller_manager_config.yaml
deleted file mode 100644
index f22e09bf5e8..00000000000
--- a/testdata/project-v4-multigroup/config/manager/controller_manager_config.yaml
+++ /dev/null
@@ -1,21 +0,0 @@
-apiVersion: controller-runtime.sigs.k8s.io/v1alpha1
-kind: ControllerManagerConfig
-health:
-  healthProbeBindAddress: :8081
-metrics:
-  bindAddress: 127.0.0.1:8080
-webhook:
-  port: 9443
-leaderElection:
-  leaderElect: true
-  resourceName: 3e9f67a9.testproject.org
-# leaderElectionReleaseOnCancel defines if the leader should step down volume
-# when the Manager ends. This requires the binary to immediately end when the
-# Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
-# speeds up voluntary leader transitions as the new leader don't have to wait
-# LeaseDuration time first.
-# In the default scaffold provided, the program ends immediately after
-# the manager stops, so would be fine to enable this option. However,
-# if you are doing or is intended to do any operation such as perform cleanups
-# after the manager stops then its usage might be unsafe.
-# leaderElectionReleaseOnCancel: true
diff --git a/testdata/project-v4-multigroup/config/manager/kustomization.yaml b/testdata/project-v4-multigroup/config/manager/kustomization.yaml
index 2bcd3eeaa94..5c5f0b84cba 100644
--- a/testdata/project-v4-multigroup/config/manager/kustomization.yaml
+++ b/testdata/project-v4-multigroup/config/manager/kustomization.yaml
@@ -1,10 +1,2 @@
 resources:
 - manager.yaml
-
-generatorOptions:
-  disableNameSuffixHash: true
-
-configMapGenerator:
-- name: manager-config
-  files:
-  - controller_manager_config.yaml
diff --git a/testdata/project-v4-with-deploy-image/config/default/kustomization.yaml b/testdata/project-v4-with-deploy-image/config/default/kustomization.yaml
index 4f1a5b72a6f..faf2235f91f 100644
--- a/testdata/project-v4-with-deploy-image/config/default/kustomization.yaml
+++ b/testdata/project-v4-with-deploy-image/config/default/kustomization.yaml
@@ -32,9 +32,7 @@ patchesStrategicMerge:
 # endpoint w/o any authn/z, please comment the following line.
 - manager_auth_proxy_patch.yaml
 
-# Mount the controller config file for loading manager configurations
-# through a ComponentConfig type
-#- manager_config_patch.yaml
+
 
 # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
 # crd/kustomization.yaml
diff --git a/testdata/project-v4-with-deploy-image/config/default/manager_config_patch.yaml b/testdata/project-v4-with-deploy-image/config/default/manager_config_patch.yaml
index 6c400155cfb..f6f58916922 100644
--- a/testdata/project-v4-with-deploy-image/config/default/manager_config_patch.yaml
+++ b/testdata/project-v4-with-deploy-image/config/default/manager_config_patch.yaml
@@ -8,13 +8,3 @@ spec:
     spec:
       containers:
       - name: manager
-        args:
-        - "--config=controller_manager_config.yaml"
-        volumeMounts:
-        - name: manager-config
-          mountPath: /controller_manager_config.yaml
-          subPath: controller_manager_config.yaml
-      volumes:
-      - name: manager-config
-        configMap:
-          name: manager-config
diff --git a/testdata/project-v4-with-deploy-image/config/manager/controller_manager_config.yaml b/testdata/project-v4-with-deploy-image/config/manager/controller_manager_config.yaml
deleted file mode 100644
index 5a6a877abc0..00000000000
--- a/testdata/project-v4-with-deploy-image/config/manager/controller_manager_config.yaml
+++ /dev/null
@@ -1,21 +0,0 @@
-apiVersion: controller-runtime.sigs.k8s.io/v1alpha1
-kind: ControllerManagerConfig
-health:
-  healthProbeBindAddress: :8081
-metrics:
-  bindAddress: 127.0.0.1:8080
-webhook:
-  port: 9443
-leaderElection:
-  leaderElect: true
-  resourceName: 1836d577.testproject.org
-# leaderElectionReleaseOnCancel defines if the leader should step down volume
-# when the Manager ends. This requires the binary to immediately end when the
-# Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
-# speeds up voluntary leader transitions as the new leader don't have to wait
-# LeaseDuration time first.
-# In the default scaffold provided, the program ends immediately after
-# the manager stops, so would be fine to enable this option. However,
-# if you are doing or is intended to do any operation such as perform cleanups
-# after the manager stops then its usage might be unsafe.
-# leaderElectionReleaseOnCancel: true
diff --git a/testdata/project-v4-with-deploy-image/config/manager/kustomization.yaml b/testdata/project-v4-with-deploy-image/config/manager/kustomization.yaml
index 2bcd3eeaa94..5c5f0b84cba 100644
--- a/testdata/project-v4-with-deploy-image/config/manager/kustomization.yaml
+++ b/testdata/project-v4-with-deploy-image/config/manager/kustomization.yaml
@@ -1,10 +1,2 @@
 resources:
 - manager.yaml
-
-generatorOptions:
-  disableNameSuffixHash: true
-
-configMapGenerator:
-- name: manager-config
-  files:
-  - controller_manager_config.yaml
diff --git a/testdata/project-v4/config/default/kustomization.yaml b/testdata/project-v4/config/default/kustomization.yaml
index c88147a4a82..1516d32747f 100644
--- a/testdata/project-v4/config/default/kustomization.yaml
+++ b/testdata/project-v4/config/default/kustomization.yaml
@@ -32,9 +32,7 @@ patchesStrategicMerge:
 # endpoint w/o any authn/z, please comment the following line.
 - manager_auth_proxy_patch.yaml
 
-# Mount the controller config file for loading manager configurations
-# through a ComponentConfig type
-#- manager_config_patch.yaml
+
 
 # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
 # crd/kustomization.yaml
diff --git a/testdata/project-v4/config/default/manager_config_patch.yaml b/testdata/project-v4/config/default/manager_config_patch.yaml
index 6c400155cfb..f6f58916922 100644
--- a/testdata/project-v4/config/default/manager_config_patch.yaml
+++ b/testdata/project-v4/config/default/manager_config_patch.yaml
@@ -8,13 +8,3 @@ spec:
     spec:
       containers:
       - name: manager
-        args:
-        - "--config=controller_manager_config.yaml"
-        volumeMounts:
-        - name: manager-config
-          mountPath: /controller_manager_config.yaml
-          subPath: controller_manager_config.yaml
-      volumes:
-      - name: manager-config
-        configMap:
-          name: manager-config
diff --git a/testdata/project-v4/config/manager/controller_manager_config.yaml b/testdata/project-v4/config/manager/controller_manager_config.yaml
deleted file mode 100644
index ae6ac5a18b5..00000000000
--- a/testdata/project-v4/config/manager/controller_manager_config.yaml
+++ /dev/null
@@ -1,21 +0,0 @@
-apiVersion: controller-runtime.sigs.k8s.io/v1alpha1
-kind: ControllerManagerConfig
-health:
-  healthProbeBindAddress: :8081
-metrics:
-  bindAddress: 127.0.0.1:8080
-webhook:
-  port: 9443
-leaderElection:
-  leaderElect: true
-  resourceName: da1d9c86.testproject.org
-# leaderElectionReleaseOnCancel defines if the leader should step down volume
-# when the Manager ends. This requires the binary to immediately end when the
-# Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
-# speeds up voluntary leader transitions as the new leader don't have to wait
-# LeaseDuration time first.
-# In the default scaffold provided, the program ends immediately after
-# the manager stops, so would be fine to enable this option. However,
-# if you are doing or is intended to do any operation such as perform cleanups
-# after the manager stops then its usage might be unsafe.
-# leaderElectionReleaseOnCancel: true
diff --git a/testdata/project-v4/config/manager/kustomization.yaml b/testdata/project-v4/config/manager/kustomization.yaml
index 2bcd3eeaa94..5c5f0b84cba 100644
--- a/testdata/project-v4/config/manager/kustomization.yaml
+++ b/testdata/project-v4/config/manager/kustomization.yaml
@@ -1,10 +1,2 @@
 resources:
 - manager.yaml
-
-generatorOptions:
-  disableNameSuffixHash: true
-
-configMapGenerator:
-- name: manager-config
-  files:
-  - controller_manager_config.yaml