diff --git a/vertical-pod-autoscaler/pkg/admission-controller/config.go b/vertical-pod-autoscaler/pkg/admission-controller/config.go index c1f88ae5d70..aa9e95f74a6 100644 --- a/vertical-pod-autoscaler/pkg/admission-controller/config.go +++ b/vertical-pod-autoscaler/pkg/admission-controller/config.go @@ -82,7 +82,7 @@ func configTLS(clientset *kubernetes.Clientset, serverCert, serverKey []byte) *t // register this webhook admission controller with the kube-apiserver // by creating MutatingWebhookConfiguration. -func selfRegistration(clientset *kubernetes.Clientset, caCert []byte, namespace *string) { +func selfRegistration(clientset *kubernetes.Clientset, caCert []byte, namespace *string, webhookHostName *string) { time.Sleep(10 * time.Second) client := clientset.AdmissionregistrationV1beta1().MutatingWebhookConfigurations() _, err := client.Get(webhookConfigName, metav1.GetOptions{}) @@ -116,6 +116,7 @@ func selfRegistration(clientset *kubernetes.Clientset, caCert []byte, namespace }, }}, ClientConfig: v1beta1.WebhookClientConfig{ + URL: webhookHostName, Service: &v1beta1.ServiceReference{ Namespace: *namespace, Name: "vpa-webhook", diff --git a/vertical-pod-autoscaler/pkg/admission-controller/main.go b/vertical-pod-autoscaler/pkg/admission-controller/main.go index d244cf60edf..95eafbe71e5 100644 --- a/vertical-pod-autoscaler/pkg/admission-controller/main.go +++ b/vertical-pod-autoscaler/pkg/admission-controller/main.go @@ -41,8 +41,10 @@ var ( tlsPrivateKey: flag.String("tls-private-key", "/etc/tls-certs/serverKey.pem", "Path to server certificate key PEM file."), } - address = flag.String("address", ":8944", "The address to expose Prometheus metrics.") - namespace = os.Getenv("NAMESPACE") + address = flag.String("address", ":8944", "The address to expose Prometheus metrics.") + namespace = os.Getenv("NAMESPACE") + webhookHostName = flag.String("webhookHostName", "", "path for admission controller.Blank for default") + serverPort = flag.String("Server Port", "", "Server Port for Webhook") ) func newReadyVPALister(stopChannel <-chan struct{}) vpa_lister.VerticalPodAutoscalerLister { @@ -75,6 +77,6 @@ func main() { Addr: ":8000", TLSConfig: configTLS(clientset, certs.serverCert, certs.serverKey), } - go selfRegistration(clientset, certs.caCert, &namespace) + go selfRegistration(clientset, certs.caCert, &namespace, webhookHostName) server.ListenAndServeTLS("", "") }