@@ -99,6 +99,11 @@ type Config struct {
9999 CertName string
100100 CertKey string
101101 }
102+ Webhook struct {
103+ CertPath string
104+ CertName string
105+ CertKey string
106+ }
102107 Streaming struct {
103108 MaxBufSize resource.QuantityValue `default:"1Mi"`
104109 InitialBufSize resource.QuantityValue `default:"4Ki"`
@@ -132,6 +137,10 @@ func (cfg *Config) SetFlags(commandLine *flag.FlagSet) {
132137 "The directory that contains the metrics server certificate." )
133138 commandLine .StringVar (& cfg .Metrics .CertName , "metrics-cert-name" , "tls.crt" , "The name of the metrics server certificate file." )
134139 commandLine .StringVar (& cfg .Metrics .CertKey , "metrics-cert-key" , "tls.key" , "The name of the metrics server key file." )
140+ commandLine .StringVar (& cfg .Webhook .CertPath , "webhook-cert-path" , "" ,
141+ "The directory that contains the webhook server certificate." )
142+ commandLine .StringVar (& cfg .Webhook .CertName , "webhook-cert-name" , "tls.crt" , "The name of the wehbook server certificate file." )
143+ commandLine .StringVar (& cfg .Webhook .CertKey , "webhook-cert-key" , "tls.key" , "The name of the webhook server key file." )
135144 commandLine .BoolVar (& cfg .EnableHTTP2 , "enable-http2" , false ,
136145 "If set, HTTP/2 will be enabled for the metrics and webhook servers" )
137146
@@ -282,6 +291,21 @@ func Start(getExtensionConfig GetExtensionConfig) {
282291 })
283292 }
284293
294+ if len (cfg .Webhook .CertPath ) > 0 {
295+ setupLog .Info ("Initializing webhook certificate watcher using provided certificates" ,
296+ "webhook-cert-path" , cfg .Webhook .CertPath , "webhook-cert-name" , cfg .Webhook .CertName , "webhook-cert-key" , cfg .Webhook .CertKey )
297+
298+ var err error
299+ webhookCertWatcher , err = certwatcher .New (
300+ filepath .Join (cfg .Webhook .CertPath , cfg .Webhook .CertName ),
301+ filepath .Join (cfg .Webhook .CertPath , cfg .Webhook .CertKey ),
302+ )
303+ if err != nil {
304+ setupLog .Error (err , "to initialize webhook certificate watcher" , "error" , err )
305+ os .Exit (1 )
306+ }
307+ }
308+
285309 // filter out invalid namespaces from the watchNamespaces flag (comma separated list)
286310 watchNamespacesList := filterValidNamespaces (strings .Split (cfg .WatchNamespaces , "," ))
287311
0 commit comments