Skip to content

Commit 48a17ca

Browse files
CSPL-3964: Removing some (seemingly) unecessary stuff.
1 parent dac378e commit 48a17ca

File tree

13 files changed

+8
-354
lines changed

13 files changed

+8
-354
lines changed

.devcontainer/post-install.sh

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

cmd/main.go

Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@ import (
2121
"flag"
2222
"fmt"
2323
"os"
24-
"path/filepath"
2524
"time"
2625

2726
intController "github.com/splunk/splunk-operator/internal/controller"
2827
"github.com/splunk/splunk-operator/internal/controller/debug"
2928
"github.com/splunk/splunk-operator/pkg/config"
30-
"sigs.k8s.io/controller-runtime/pkg/certwatcher"
3129
"sigs.k8s.io/controller-runtime/pkg/metrics/filters"
3230

3331
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
@@ -82,9 +80,6 @@ func main() {
8280

8381
var tlsOpts []func(*tls.Config)
8482

85-
var metricsCertPath, metricsCertName, metricsCertKey string
86-
var webhookCertPath, webhookCertName, webhookCertKey string
87-
8883
flag.StringVar(&logEncoder, "log-encoder", "json", "log encoding ('json' or 'console')")
8984
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
9085
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
@@ -98,34 +93,6 @@ func main() {
9893
"Use :8443 for HTTPS or :8080 for HTTP, or leave as 0 to disable the metrics service.")
9994
flag.BoolVar(&secureMetrics, "metrics-secure", false,
10095
"If set, the metrics endpoint is served securely via HTTPS. Use --metrics-secure=false to use HTTP instead.")
101-
flag.StringVar(&webhookCertPath, "webhook-cert-path", "", "The directory that contains the webhook certificate.")
102-
flag.StringVar(&webhookCertName, "webhook-cert-name", "tls.crt", "The name of the webhook certificate file.")
103-
flag.StringVar(&webhookCertKey, "webhook-cert-key", "tls.key", "The name of the webhook key file.")
104-
flag.StringVar(&metricsCertPath, "metrics-cert-path", "", "The directory that contains the metrics server certificate.")
105-
flag.StringVar(&metricsCertName, "metrics-cert-name", "tls.crt", "The name of the metrics server certificate file.")
106-
flag.StringVar(&metricsCertKey, "metrics-cert-key", "tls.key", "The name of the metrics server key file.")
107-
108-
var metricsCertWatcher, webhookCertWatcher *certwatcher.CertWatcher
109-
webhookTLSOpts := tlsOpts
110-
111-
if len(webhookCertPath) > 0 {
112-
setupLog.Info("Initializing webhook certificate watcher using provided certificates",
113-
"webhook-cert-path", webhookCertPath, "webhook-cert-name", webhookCertName, "webhook-cert-key", webhookCertKey)
114-
115-
var err error
116-
webhookCertWatcher, err = certwatcher.New(
117-
filepath.Join(webhookCertPath, webhookCertName),
118-
filepath.Join(webhookCertPath, webhookCertKey),
119-
)
120-
if err != nil {
121-
setupLog.Error(err, "Failed to initialize webhook certificate watcher")
122-
os.Exit(1)
123-
}
124-
125-
webhookTLSOpts = append(webhookTLSOpts, func(config *tls.Config) {
126-
config.GetCertificate = webhookCertWatcher.GetCertificate
127-
})
128-
}
12996

13097
// Metrics endpoint is enabled in 'config/default/kustomization.yaml'. The Metrics options configure the server.
13198
// More info:
@@ -140,7 +107,7 @@ func main() {
140107
// as certificates issued by a trusted Certificate Authority (CA). The primary risk is potentially allowing
141108
// unauthorized access to sensitive metrics data. Consider replacing with CertDir, CertName, and KeyName
142109
// to provide certificates, ensuring the server communicates using trusted and secure certificates.
143-
TLSOpts: webhookTLSOpts,
110+
TLSOpts: tlsOpts,
144111
FilterProvider: filters.WithAuthenticationAndAuthorization,
145112
}
146113

@@ -189,25 +156,6 @@ func main() {
189156
// Apply namespace-specific configuration
190157
managerOptions := config.ManagerOptionsWithNamespaces(setupLog, baseOptions)
191158

192-
if len(metricsCertPath) > 0 {
193-
setupLog.Info("Initializing metrics certificate watcher using provided certificates",
194-
"metrics-cert-path", metricsCertPath, "metrics-cert-name", metricsCertName, "metrics-cert-key", metricsCertKey)
195-
196-
var err error
197-
metricsCertWatcher, err = certwatcher.New(
198-
filepath.Join(metricsCertPath, metricsCertName),
199-
filepath.Join(metricsCertPath, metricsCertKey),
200-
)
201-
if err != nil {
202-
setupLog.Error(err, "Failed to initialize metrics certificate watcher")
203-
os.Exit(1)
204-
}
205-
206-
metricsServerOptions.TLSOpts = append(metricsServerOptions.TLSOpts, func(config *tls.Config) {
207-
config.GetCertificate = metricsCertWatcher.GetCertificate
208-
})
209-
}
210-
211159
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), managerOptions)
212160

213161
if err != nil {
@@ -275,22 +223,6 @@ func main() {
275223
}
276224
//+kubebuilder:scaffold:builder
277225

278-
if metricsCertWatcher != nil {
279-
setupLog.Info("Adding metrics certificate watcher to manager")
280-
if err := mgr.Add(metricsCertWatcher); err != nil {
281-
setupLog.Error(err, "Unable to add metrics certificate watcher to manager")
282-
os.Exit(1)
283-
}
284-
}
285-
286-
if webhookCertWatcher != nil {
287-
setupLog.Info("Adding webhook certificate watcher to manager")
288-
if err := mgr.Add(webhookCertWatcher); err != nil {
289-
setupLog.Error(err, "Unable to add webhook certificate watcher to manager")
290-
os.Exit(1)
291-
}
292-
}
293-
294226
if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
295227
setupLog.Error(err, "unable to set up health check")
296228
os.Exit(1)

config/certmanager/certificate-metrics.yaml

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

config/certmanager/certificate-webhook.yaml

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

config/certmanager/issuer.yaml

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

config/certmanager/kustomization.yaml

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

config/certmanager/kustomizeconfig.yaml

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

config/default/cert_metrics_manager_patch.yaml

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

config/default/kustomization.yaml

Lines changed: 1 addition & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -134,116 +134,4 @@ patches:
134134
# More info: https://book.kubebuilder.io/reference/metrics
135135
- path: manager_metrics_patch.yaml
136136
target:
137-
kind: Deployment
138-
# Uncomment the patches line if you enable Metrics and CertManager
139-
# [METRICS-WITH-CERTS] To enable metrics protected with certManager, uncomment the following line.
140-
# This patch will protect the metrics with certManager self-signed certs.
141-
- path: cert_metrics_manager_patch.yaml
142-
target:
143-
kind: Deployment
144-
145-
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
146-
# crd/kustomization.yaml
147-
- path: manager_webhook_patch.yaml
148-
target:
149-
kind: Deployment
150-
151-
replacements:
152-
- source: # Uncomment the following block to enable certificates for metrics
153-
kind: Service
154-
version: v1
155-
name: controller-manager-metrics-service
156-
fieldPath: metadata.name
157-
targets:
158-
- select:
159-
kind: Certificate
160-
group: cert-manager.io
161-
version: v1
162-
name: metrics-certs
163-
fieldPaths:
164-
- spec.dnsNames.0
165-
- spec.dnsNames.1
166-
options:
167-
delimiter: '.'
168-
index: 0
169-
create: true
170-
- select: # Uncomment the following to set the Service name for TLS config in Prometheus ServiceMonitor
171-
kind: ServiceMonitor
172-
group: monitoring.coreos.com
173-
version: v1
174-
name: controller-manager-metrics-monitor
175-
fieldPaths:
176-
- spec.endpoints.0.tlsConfig.serverName
177-
options:
178-
delimiter: '.'
179-
index: 0
180-
create: true
181-
182-
- source:
183-
kind: Service
184-
version: v1
185-
name: controller-manager-metrics-service
186-
fieldPath: metadata.namespace
187-
targets:
188-
- select:
189-
kind: Certificate
190-
group: cert-manager.io
191-
version: v1
192-
name: metrics-certs
193-
fieldPaths:
194-
- spec.dnsNames.0
195-
- spec.dnsNames.1
196-
options:
197-
delimiter: '.'
198-
index: 1
199-
create: true
200-
- select: # Uncomment the following to set the Service namespace for TLS in Prometheus ServiceMonitor
201-
kind: ServiceMonitor
202-
group: monitoring.coreos.com
203-
version: v1
204-
name: controller-manager-metrics-monitor
205-
fieldPaths:
206-
- spec.endpoints.0.tlsConfig.serverName
207-
options:
208-
delimiter: '.'
209-
index: 1
210-
create: true
211-
212-
- source: # Uncomment the following block if you have any webhook
213-
kind: Service
214-
version: v1
215-
name: webhook-service
216-
fieldPath: .metadata.name # Name of the service
217-
targets:
218-
- select:
219-
kind: Certificate
220-
group: cert-manager.io
221-
version: v1
222-
name: serving-cert
223-
fieldPaths:
224-
- .spec.dnsNames.0
225-
- .spec.dnsNames.1
226-
options:
227-
delimiter: '.'
228-
index: 0
229-
create: true
230-
# +kubebuilder:scaffold:crdkustomizecainjectionns
231-
232-
- source:
233-
kind: Service
234-
version: v1
235-
name: webhook-service
236-
fieldPath: .metadata.namespace # Namespace of the service
237-
targets:
238-
- select:
239-
kind: Certificate
240-
group: cert-manager.io
241-
version: v1
242-
name: serving-cert
243-
fieldPaths:
244-
- .spec.dnsNames.0
245-
- .spec.dnsNames.1
246-
options:
247-
delimiter: '.'
248-
index: 1
249-
create: true
137+
kind: Deployment

0 commit comments

Comments
 (0)