From 440dcd3675989fe91263d48ef6b4a2b3db6753d2 Mon Sep 17 00:00:00 2001 From: Rajat Chopra Date: Tue, 7 Feb 2017 20:43:20 -0500 Subject: [PATCH] For the auto generated kube api-server service, the service spec re-uses the service port itself. The endpoint is created correctly using public port. Fix the service also because there are some plugin controllers that react to service spec itself. --- pkg/master/controller.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/master/controller.go b/pkg/master/controller.go index c98adc89b6f..f080d861cd9 100644 --- a/pkg/master/controller.go +++ b/pkg/master/controller.go @@ -173,7 +173,7 @@ func (c *Controller) UpdateKubernetesService(reconcile bool) error { return err } - servicePorts, serviceType := createPortAndServiceSpec(c.ServicePort, c.KubernetesServiceNodePort, "https", c.ExtraServicePorts) + servicePorts, serviceType := createPortAndServiceSpec(c.ServicePort, c.PublicServicePort, c.KubernetesServiceNodePort, "https", c.ExtraServicePorts) if err := c.CreateOrUpdateMasterServiceIfNeeded(kubernetesServiceName, c.ServiceIP, servicePorts, serviceType, reconcile); err != nil { return err } @@ -205,13 +205,13 @@ func (c *Controller) CreateNamespaceIfNeeded(ns string) error { // createPortAndServiceSpec creates an array of service ports. // If the NodePort value is 0, just the servicePort is used, otherwise, a node port is exposed. -func createPortAndServiceSpec(servicePort int, nodePort int, servicePortName string, extraServicePorts []api.ServicePort) ([]api.ServicePort, api.ServiceType) { +func createPortAndServiceSpec(servicePort int, targetServicePort int, nodePort int, servicePortName string, extraServicePorts []api.ServicePort) ([]api.ServicePort, api.ServiceType) { //Use the Cluster IP type for the service port if NodePort isn't provided. //Otherwise, we will be binding the master service to a NodePort. servicePorts := []api.ServicePort{{Protocol: api.ProtocolTCP, Port: int32(servicePort), Name: servicePortName, - TargetPort: intstr.FromInt(servicePort)}} + TargetPort: intstr.FromInt(targetServicePort)}} serviceType := api.ServiceTypeClusterIP if nodePort > 0 { servicePorts[0].NodePort = int32(nodePort)