Skip to content
This repository was archived by the owner on Jul 13, 2026. It is now read-only.

Commit 130ebec

Browse files
committed
parametierise cert paths via command-line flags
1 parent f09cae8 commit 130ebec

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

‎cmd/main.go‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ func main() {
6565
var probeAddr string
6666
var secureMetrics bool
6767
var enableHTTP2 bool
68+
var certDir string
69+
var certName string
70+
var keyName string
6871
var tlsOpts []func(*tls.Config)
6972
flag.StringVar(&metricsAddr, "metrics-bind-address", "0", "The address the metrics endpoint binds to. "+
7073
"Use :8443 for HTTPS or :8080 for HTTP, or leave as 0 to disable the metrics service.")
@@ -76,6 +79,12 @@ func main() {
7679
"If set, the metrics endpoint is served securely via HTTPS. Use --metrics-secure=false to use HTTP instead.")
7780
flag.BoolVar(&enableHTTP2, "enable-http2", false,
7881
"If set, HTTP/2 will be enabled for the metrics and webhook servers")
82+
flag.StringVar(&certDir, "cert-dir", "/tmp/k8s-metrics-server/serving-certs",
83+
"The directory where the TLS certificates are stored.")
84+
flag.StringVar(&certName, "cert-name", "tls.crt",
85+
"The name of the TLS certificate file.")
86+
flag.StringVar(&keyName, "key-name", "tls.key",
87+
"The name of the TLS key file.")
7988
opts := zap.Options{
8089
Development: true,
8190
}
@@ -110,11 +119,11 @@ func main() {
110119
metricsServerOptions := metricsserver.Options{
111120
BindAddress: metricsAddr,
112121
SecureServing: secureMetrics,
113-
// Use certificates from service-ca mounted at /tmp/k8s-metrics-server/serving-certs
122+
// Use certificates from service-ca mounted via flags (defaults to /tmp/k8s-metrics-server/serving-certs)
114123
TLSOpts: tlsOpts,
115-
CertDir: "/tmp/k8s-metrics-server/serving-certs",
116-
CertName: "tls.crt",
117-
KeyName: "tls.key",
124+
CertDir: certDir,
125+
CertName: certName,
126+
KeyName: keyName,
118127
}
119128

120129
if secureMetrics {

0 commit comments

Comments
 (0)