Skip to content

Commit

Permalink
Allow vpa-admission-controler to installl on specific path
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajat-0 committed Feb 14, 2019
1 parent 0a82f0e commit a291fd3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion vertical-pod-autoscaler/pkg/admission-controller/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 5 additions & 3 deletions vertical-pod-autoscaler/pkg/admission-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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("", "")
}

0 comments on commit a291fd3

Please sign in to comment.