Skip to content

Commit 713b76c

Browse files
Cleanup Helm to not add CertManager with Metrics and Prometheus Options
Signed-off-by: Camila Macedo <7708031+camilamacedo86@users.noreply.github.com>
1 parent 3ac7ec1 commit 713b76c

5 files changed

Lines changed: 37 additions & 63 deletions

File tree

internal/plugins/util/cleanup.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

testdata/helm/memcached-operator/config/default/cert_metrics_manager_patch.yaml

Lines changed: 0 additions & 30 deletions
This file was deleted.

testdata/helm/memcached-operator/config/default/kustomization.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,4 @@ patches:
3636
target:
3737
kind: Deployment
3838

39-
# Uncomment the patches line if you enable Metrics and CertManager
40-
# [METRICS-WITH-CERTS] To enable metrics protected with certManager, uncomment the following line.
41-
# This patch will protect the metrics with certManager self-signed certs.
42-
#- path: cert_metrics_manager_patch.yaml
43-
# target:
44-
# kind: Deployment
39+
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
resources:
22
- monitor.yaml
33

4-
# [PROMETHEUS-WITH-CERTS] The following patch configures the ServiceMonitor in ../prometheus
5-
# to securely reference certificates created and managed by cert-manager.
6-
# Additionally, ensure that you uncomment the [METRICS WITH CERTMANAGER] patch under config/default/kustomization.yaml
7-
# to mount the "metrics-server-cert" secret in the Manager Deployment.
8-
#patches:
9-
# - path: monitor_tls_patch.yaml
10-
# target:
11-
# kind: ServiceMonitor
4+

testdata/helm/memcached-operator/config/prometheus/monitor_tls_patch.yaml

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)