@@ -72,6 +72,41 @@ func UpdateKustomizationsInit() error {
7272 return fmt .Errorf ("remove %s resources: %v" , defaultKFile , err )
7373 }
7474
75+ if err := kbutil .ReplaceInFile (defaultKFile ,
76+ `# Uncomment the patches line if you enable Metrics and CertManager
77+ # [METRICS-WITH-CERTS] To enable metrics protected with certManager, uncomment the following line.
78+ # This patch will protect the metrics with certManager self-signed certs.
79+ #- path: cert_metrics_manager_patch.yaml
80+ # target:
81+ # kind: Deployment` , "" ); err != nil {
82+ return fmt .Errorf ("remove %s resources: %v" , defaultKFile , err )
83+ }
84+
85+ // Remove the file not used for Helm projects since we do not scaffold the cert-manager
86+ certPatchPath := filepath .Join ("config" , "default" , "cert_metrics_manager_patch.yaml" )
87+ if err := os .Remove (certPatchPath ); err != nil && ! os .IsNotExist (err ) {
88+ return fmt .Errorf ("failed to remove unused file %s: %v" , certPatchPath , err )
89+ }
90+
91+ // Remove the file not used for Helm projects since we do not scaffold the cert-manager
92+ monitorTLSPatchPath := filepath .Join ("config" , "prometheus" , "monitor_tls_patch.yaml" )
93+ if err := os .Remove (monitorTLSPatchPath ); err != nil && ! os .IsNotExist (err ) {
94+ return fmt .Errorf ("failed to remove unused file %s: %v" , monitorTLSPatchPath , err )
95+ }
96+
97+ prometheusKustomize := filepath .Join ("config" , "prometheus" , "kustomization.yaml" )
98+ if err := kbutil .ReplaceInFile (prometheusKustomize ,
99+ `# [PROMETHEUS-WITH-CERTS] The following patch configures the ServiceMonitor in ../prometheus
100+ # to securely reference certificates created and managed by cert-manager.
101+ # Additionally, ensure that you uncomment the [METRICS WITH CERTMANAGER] patch under config/default/kustomization.yaml
102+ # to mount the "metrics-server-cert" secret in the Manager Deployment.
103+ #patches:
104+ # - path: monitor_tls_patch.yaml
105+ # target:
106+ # kind: ServiceMonitor` , "" ); err != nil {
107+ return fmt .Errorf ("remove %s resources: %v" , defaultKFile , err )
108+ }
109+
75110 if err := kbutil .ReplaceInFile (defaultKFile ,
76111 `
77112# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
0 commit comments