@@ -2,6 +2,7 @@ package main
2
2
3
3
import (
4
4
"context"
5
+ "crypto/tls"
5
6
"flag"
6
7
"fmt"
7
8
"net/http"
@@ -18,6 +19,7 @@ import (
18
19
19
20
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client"
20
21
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/catalog"
22
+ "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/filemonitor"
21
23
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient"
22
24
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorstatus"
23
25
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/profile"
@@ -138,8 +140,20 @@ func main() {
138
140
metricsMux := http .NewServeMux ()
139
141
metricsMux .Handle ("/metrics" , promhttp .Handler ())
140
142
if useTLS {
143
+ tlsGetCertFn , err := filemonitor .OLMGetCertRotationFn (logger , * tlsCertPath , * tlsKeyPath )
144
+ if err != nil {
145
+ logger .Errorf ("Certificate monitoring for metrics (https) failed: %v" , err )
146
+ }
147
+
141
148
go func () {
142
- err := http .ListenAndServeTLS (":8081" , * tlsCertPath , * tlsKeyPath , metricsMux )
149
+ httpsServer := & http.Server {
150
+ Addr : ":8081" ,
151
+ Handler : metricsMux ,
152
+ TLSConfig : & tls.Config {
153
+ GetCertificate : tlsGetCertFn ,
154
+ },
155
+ }
156
+ err := httpsServer .ListenAndServeTLS ("" , "" )
143
157
if err != nil {
144
158
logger .Errorf ("Metrics (https) serving failed: %v" , err )
145
159
}
0 commit comments