Remove unused cert-manager/webhook scaffolding
kubebuilder's generic scaffold defensively wires up webhook TLS-cert machinery and an unconditional cert-manager install in the e2e suite, in case a project grows admission webhooks later. This one never will -- the spec's non-goals explicitly rule out admission webhooks and cert-manager wiring -- so none of it does anything. Verified before removing: no config/webhook/, no +kubebuilder:webhook markers anywhere, and config/*/kustomization.yaml's [CERTMANAGER] blocks are all inert (never uncommented). cmd/main.go: drops the webhook import, the three webhook-cert-* flags, and the WebhookServer wiring on ctrl.Options -- the manager now runs with no webhook server, correctly, since nothing registers one. Left the metrics-cert flags alone; those are unrelated to webhooks. test/e2e/e2e_suite_test.go: drops the unconditional cert-manager install/uninstall around the suite. test/utils/utils.go: drops the now-dead InstallCertManager/ UninstallCertManager/IsCertManagerCRDsInstalled and their warnError helper, plus UncommentCode -- unrelated to cert-manager, but found to have zero callers even before this cleanup. Left the inert commented-out [WEBHOOK]/[CERTMANAGER] kustomize blocks and kubebuilder's scaffold marker comments alone: pure comments, no runtime behavior, unlike the cert-manager install this actually removed. Verified clean with both build tags (go build/vet, and -tags=e2e for test/e2e). make test unchanged and green. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
33
cmd/main.go
33
cmd/main.go
@@ -33,7 +33,6 @@ import (
|
||||
"sigs.k8s.io/controller-runtime/pkg/log/zap"
|
||||
"sigs.k8s.io/controller-runtime/pkg/metrics/filters"
|
||||
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
|
||||
"sigs.k8s.io/controller-runtime/pkg/webhook"
|
||||
|
||||
crawlv1alpha1 "gitea.home.hrajfrisbee.cz/kacerr/egress-proxies-operator/api/v1alpha1"
|
||||
"gitea.home.hrajfrisbee.cz/kacerr/egress-proxies-operator/internal/controller"
|
||||
@@ -56,7 +55,6 @@ func init() {
|
||||
func main() {
|
||||
var metricsAddr string
|
||||
var metricsCertPath, metricsCertName, metricsCertKey string
|
||||
var webhookCertPath, webhookCertName, webhookCertKey string
|
||||
var enableLeaderElection bool
|
||||
var probeAddr string
|
||||
var secureMetrics bool
|
||||
@@ -70,15 +68,12 @@ func main() {
|
||||
"Enabling this will ensure there is only one active controller manager.")
|
||||
flag.BoolVar(&secureMetrics, "metrics-secure", true,
|
||||
"If set, the metrics endpoint is served securely via HTTPS. Use --metrics-secure=false to use HTTP instead.")
|
||||
flag.StringVar(&webhookCertPath, "webhook-cert-path", "", "The directory that contains the webhook certificate.")
|
||||
flag.StringVar(&webhookCertName, "webhook-cert-name", "tls.crt", "The name of the webhook certificate file.")
|
||||
flag.StringVar(&webhookCertKey, "webhook-cert-key", "tls.key", "The name of the webhook key file.")
|
||||
flag.StringVar(&metricsCertPath, "metrics-cert-path", "",
|
||||
"The directory that contains the metrics server certificate.")
|
||||
flag.StringVar(&metricsCertName, "metrics-cert-name", "tls.crt", "The name of the metrics server certificate file.")
|
||||
flag.StringVar(&metricsCertKey, "metrics-cert-key", "tls.key", "The name of the metrics server key file.")
|
||||
flag.BoolVar(&enableHTTP2, "enable-http2", false,
|
||||
"If set, HTTP/2 will be enabled for the metrics and webhook servers")
|
||||
"If set, HTTP/2 will be enabled for the metrics server")
|
||||
opts := zap.Options{
|
||||
Development: true,
|
||||
}
|
||||
@@ -102,23 +97,6 @@ func main() {
|
||||
tlsOpts = append(tlsOpts, disableHTTP2)
|
||||
}
|
||||
|
||||
// Initial webhook TLS options
|
||||
webhookTLSOpts := tlsOpts
|
||||
webhookServerOptions := webhook.Options{
|
||||
TLSOpts: webhookTLSOpts,
|
||||
}
|
||||
|
||||
if len(webhookCertPath) > 0 {
|
||||
setupLog.Info("Initializing webhook certificate watcher using provided certificates",
|
||||
"webhook-cert-path", webhookCertPath, "webhook-cert-name", webhookCertName, "webhook-cert-key", webhookCertKey)
|
||||
|
||||
webhookServerOptions.CertDir = webhookCertPath
|
||||
webhookServerOptions.CertName = webhookCertName
|
||||
webhookServerOptions.KeyName = webhookCertKey
|
||||
}
|
||||
|
||||
webhookServer := webhook.NewServer(webhookServerOptions)
|
||||
|
||||
// Metrics endpoint is enabled in 'config/default/kustomization.yaml'. The Metrics options configure the server.
|
||||
// More info:
|
||||
// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.24.1/pkg/metrics/server
|
||||
@@ -139,12 +117,8 @@ func main() {
|
||||
|
||||
// If the certificate is not specified, controller-runtime will automatically
|
||||
// generate self-signed certificates for the metrics server. While convenient for development and testing,
|
||||
// this setup is not recommended for production.
|
||||
//
|
||||
// TODO(user): If you enable certManager, uncomment the following lines:
|
||||
// - [METRICS-WITH-CERTS] at config/default/kustomization.yaml to generate and use certificates
|
||||
// managed by cert-manager for the metrics server.
|
||||
// - [PROMETHEUS-WITH-CERTS] at config/prometheus/kustomization.yaml for TLS certification.
|
||||
// this setup is not recommended for production. This project doesn't use cert-manager (no admission
|
||||
// webhooks, no other consumer of managed certs) -- pass real certs via the flags below if needed.
|
||||
if len(metricsCertPath) > 0 {
|
||||
setupLog.Info("Initializing metrics certificate watcher using provided certificates",
|
||||
"metrics-cert-path", metricsCertPath, "metrics-cert-name", metricsCertName, "metrics-cert-key", metricsCertKey)
|
||||
@@ -157,7 +131,6 @@ func main() {
|
||||
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
|
||||
Scheme: scheme,
|
||||
Metrics: metricsServerOptions,
|
||||
WebhookServer: webhookServer,
|
||||
HealthProbeBindAddress: probeAddr,
|
||||
LeaderElection: enableLeaderElection,
|
||||
LeaderElectionID: "b47711d1.example.com",
|
||||
|
||||
Reference in New Issue
Block a user