Skip to content

Commit 10c1aa8

Browse files
Provide certmanager certificates for Metrics Service
Instead of use the self signed certs created by controller-runtime it is now provide to the Metrics Service the certs created for OLM
1 parent 23110ae commit 10c1aa8

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

cmd/manager/main.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"net/http"
2424
"os"
2525
"path/filepath"
26-
"sigs.k8s.io/controller-runtime/pkg/metrics/filters"
2726
"strings"
2827
"time"
2928

@@ -45,6 +44,7 @@ import (
4544
"sigs.k8s.io/controller-runtime/pkg/client"
4645
crfinalizer "sigs.k8s.io/controller-runtime/pkg/finalizer"
4746
"sigs.k8s.io/controller-runtime/pkg/healthz"
47+
"sigs.k8s.io/controller-runtime/pkg/metrics/filters"
4848
"sigs.k8s.io/controller-runtime/pkg/metrics/server"
4949

5050
catalogd "github.com/operator-framework/catalogd/api/v1"
@@ -90,6 +90,8 @@ func podNamespace() string {
9090
func main() {
9191
var (
9292
metricsAddr string
93+
certFile string
94+
keyFile string
9395
enableLeaderElection bool
9496
probeAddr string
9597
cachePath string
@@ -101,6 +103,8 @@ func main() {
101103
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8443", "The address the metric endpoint binds to.")
102104
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
103105
flag.StringVar(&caCertDir, "ca-certs-dir", "", "The directory of TLS certificate to use for verifying HTTPS connections to the Catalogd and docker-registry web servers.")
106+
flag.StringVar(&certFile, "tls-cert", "", "The certificate file used for serving catalog contents over HTTPS. Requires tls-key.")
107+
flag.StringVar(&keyFile, "tls-key", "", "The key file used for serving catalog contents over HTTPS. Requires tls-cert.")
104108
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
105109
"Enable leader election for controller manager. "+
106110
"Enabling this will ensure there is only one active controller manager.")
@@ -120,6 +124,11 @@ func main() {
120124
os.Exit(0)
121125
}
122126

127+
if (certFile != "" && keyFile == "") || (certFile == "" && keyFile != "") {
128+
setupLog.Error(nil, "unable to configure TLS certificates: tls-cert and tls-key flags must be used together")
129+
os.Exit(1)
130+
}
131+
123132
ctrl.SetLogger(textlogger.NewLogger(textlogger.NewConfig()))
124133

125134
setupLog.Info("starting up the controller", "version info", version.String())
@@ -171,6 +180,9 @@ func main() {
171180
// These configurations ensure that only authorized users and service accounts
172181
// can access the metrics endpoint.
173182
FilterProvider: filters.WithAuthenticationAndAuthorization,
183+
CertDir: caCertDir,
184+
CertName: certFile,
185+
KeyName: keyFile,
174186
}
175187

176188
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{

config/components/tls/patches/manager_deployment_cert.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@
77
- op: add
88
path: /spec/template/spec/containers/0/args/-
99
value: "--ca-certs-dir=/var/certs"
10+
- op: add
11+
path: /spec/template/spec/containers/0/args/-
12+
value: "--tls-cert=/var/certs/tls.crt"
13+
- op: add
14+
path: /spec/template/spec/containers/0/args/-
15+
value: "--tls-key=/var/certs/tls.key"

0 commit comments

Comments
 (0)