From c6589325d42fb38b1d91ee1fe525c57bd0534522 Mon Sep 17 00:00:00 2001 From: xrmzju Date: Mon, 19 Aug 2019 16:19:43 +0800 Subject: [PATCH] should support webhook certDir args --- pkg/manager/internal.go | 9 +++++++-- pkg/manager/manager.go | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/manager/internal.go b/pkg/manager/internal.go index ed4ae806e3..5e5a2611e0 100644 --- a/pkg/manager/internal.go +++ b/pkg/manager/internal.go @@ -111,6 +111,10 @@ type controllerManager struct { port int // host is the hostname that the webhook server binds to. host string + // CertDir is the directory that contains the server key and certificate. + // if not set, webhook server would look up the server key and certificate in + // {TempDir}/k8s-webhook-server/serving-certs + certDir string webhookServer *webhook.Server @@ -219,8 +223,9 @@ func (cm *controllerManager) GetAPIReader() client.Reader { func (cm *controllerManager) GetWebhookServer() *webhook.Server { if cm.webhookServer == nil { cm.webhookServer = &webhook.Server{ - Port: cm.port, - Host: cm.host, + Port: cm.port, + Host: cm.host, + CertDir: cm.certDir, } if err := cm.Add(cm.webhookServer); err != nil { panic("unable to add webhookServer to the controller manager") diff --git a/pkg/manager/manager.go b/pkg/manager/manager.go index 56a34cba6e..222ab4f4fa 100644 --- a/pkg/manager/manager.go +++ b/pkg/manager/manager.go @@ -149,6 +149,10 @@ type Options struct { // It is used to set webhook.Server.Host. Host string + // CertDir is the directory that contains the server key and certificate. + // if not set, webhook server would look up the server key and certificate in + // {TempDir}/k8s-webhook-server/serving-certs + CertDir string // Functions to all for a user to customize the values that will be injected. // NewCache is the function that will create the cache to be used @@ -271,6 +275,7 @@ func New(config *rest.Config, options Options) (Manager, error) { internalStopper: stop, port: options.Port, host: options.Host, + certDir: options.CertDir, leaseDuration: *options.LeaseDuration, renewDeadline: *options.RenewDeadline, retryPeriod: *options.RetryPeriod,