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