Skip to content

Commit 393a7e7

Browse files
Fix webhookCertWatcher setting (#1155)
Signed-off-by: jiangdong <jiangdong@iflytek.com>
1 parent 2525ba1 commit 393a7e7

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

go/pkg/app/app.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)