@@ -71,6 +71,9 @@ func main() {
7171 var probeAddr string
7272 var secureMetrics bool
7373 var enableHTTP2 bool
74+ var certDir string
75+ var certName string
76+ var keyName string
7477 var tlsOpts []func (* tls.Config )
7578 flag .StringVar (& metricsAddr , "metrics-bind-address" , "0" , "The address the metrics endpoint binds to. " +
7679 "Use :8443 for HTTPS or :8080 for HTTP, or leave as 0 to disable the metrics service." )
@@ -82,6 +85,12 @@ func main() {
8285 "If set, the metrics endpoint is served securely via HTTPS. Use --metrics-secure=false to use HTTP instead." )
8386 flag .BoolVar (& enableHTTP2 , "enable-http2" , false ,
8487 "If set, HTTP/2 will be enabled for the metrics and webhook servers" )
88+ flag .StringVar (& certDir , "cert-dir" , "/tmp/k8s-metrics-server/serving-certs" ,
89+ "The directory where the TLS certificates are stored." )
90+ flag .StringVar (& certName , "cert-name" , "tls.crt" ,
91+ "The name of the TLS certificate file." )
92+ flag .StringVar (& keyName , "key-name" , "tls.key" ,
93+ "The name of the TLS key file." )
8594 opts := zap.Options {
8695 Development : true ,
8796 }
@@ -116,13 +125,10 @@ func main() {
116125 metricsServerOptions := metricsserver.Options {
117126 BindAddress : metricsAddr ,
118127 SecureServing : secureMetrics ,
119- // TODO(user): TLSOpts is used to allow configuring the TLS config used for the server. If certificates are
120- // not provided, self-signed certificates will be generated by default. This option is not recommended for
121- // production environments as self-signed certificates do not offer the same level of trust and security
122- // as certificates issued by a trusted Certificate Authority (CA). The primary risk is potentially allowing
123- // unauthorized access to sensitive metrics data. Consider replacing with CertDir, CertName, and KeyName
124- // to provide certificates, ensuring the server communicates using trusted and secure certificates.
125- TLSOpts : tlsOpts ,
128+ TLSOpts : tlsOpts ,
129+ CertDir : certDir ,
130+ CertName : certName ,
131+ KeyName : keyName ,
126132 }
127133
128134 if secureMetrics {
0 commit comments