@@ -33,11 +33,6 @@ import (
33
33
"sigs.k8s.io/controller-runtime/pkg/webhook/internal/metrics"
34
34
)
35
35
36
- const (
37
- certName = "tls.crt"
38
- keyName = "tls.key"
39
- )
40
-
41
36
// DefaultPort is the default port that the webhook server serves.
42
37
var DefaultPort = 443
43
38
@@ -53,10 +48,15 @@ type Server struct {
53
48
Port int
54
49
55
50
// CertDir is the directory that contains the server key and certificate. The
56
- // server key and certificate must be named tls.key and tls.crt,
57
- // respectively.
51
+ // server key and certificate.
58
52
CertDir string
59
53
54
+ // CertName is the server certificate name. Defaults to tls.crt.
55
+ CertName string
56
+
57
+ // CertName is the server key name. Defaults to tls.key.
58
+ KeyName string
59
+
60
60
// WebhookMux is the multiplexer that handles different webhooks.
61
61
WebhookMux * http.ServeMux
62
62
@@ -85,6 +85,14 @@ func (s *Server) setDefaults() {
85
85
if len (s .CertDir ) == 0 {
86
86
s .CertDir = filepath .Join (os .TempDir (), "k8s-webhook-server" , "serving-certs" )
87
87
}
88
+
89
+ if len (s .CertName ) == 0 {
90
+ s .CertName = "tls.crt"
91
+ }
92
+
93
+ if len (s .KeyName ) == 0 {
94
+ s .KeyName = "tls.key"
95
+ }
88
96
}
89
97
90
98
// NeedLeaderElection implements the LeaderElectionRunnable interface, which indicates
@@ -141,8 +149,8 @@ func (s *Server) Start(stop <-chan struct{}) error {
141
149
}
142
150
}
143
151
144
- certPath := filepath .Join (s .CertDir , certName )
145
- keyPath := filepath .Join (s .CertDir , keyName )
152
+ certPath := filepath .Join (s .CertDir , s . CertName )
153
+ keyPath := filepath .Join (s .CertDir , s . KeyName )
146
154
147
155
certWatcher , err := certwatcher .New (certPath , keyPath )
148
156
if err != nil {
0 commit comments