mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 05:03:09 +00:00
Merge pull request #107872 from danwinship/apiserver-extra-ports
Remove unused and un-enable-able apiserver multiple ports feature
This commit is contained in:
commit
cb0e460343
@ -82,8 +82,6 @@ type Controller struct {
|
|||||||
// ServiceIP indicates where the kubernetes service will live. It may not be nil.
|
// ServiceIP indicates where the kubernetes service will live. It may not be nil.
|
||||||
ServiceIP net.IP
|
ServiceIP net.IP
|
||||||
ServicePort int
|
ServicePort int
|
||||||
ExtraServicePorts []corev1.ServicePort
|
|
||||||
ExtraEndpointPorts []corev1.EndpointPort
|
|
||||||
PublicServicePort int
|
PublicServicePort int
|
||||||
KubernetesServiceNodePort int
|
KubernetesServiceNodePort int
|
||||||
|
|
||||||
@ -137,8 +135,6 @@ func (c *completedConfig) NewBootstrapController(legacyRESTStorage corerest.Lega
|
|||||||
|
|
||||||
ServiceIP: c.ExtraConfig.APIServerServiceIP,
|
ServiceIP: c.ExtraConfig.APIServerServiceIP,
|
||||||
ServicePort: c.ExtraConfig.APIServerServicePort,
|
ServicePort: c.ExtraConfig.APIServerServicePort,
|
||||||
ExtraServicePorts: c.ExtraConfig.ExtraServicePorts,
|
|
||||||
ExtraEndpointPorts: c.ExtraConfig.ExtraEndpointPorts,
|
|
||||||
PublicServicePort: publicServicePort,
|
PublicServicePort: publicServicePort,
|
||||||
KubernetesServiceNodePort: c.ExtraConfig.KubernetesServiceNodePort,
|
KubernetesServiceNodePort: c.ExtraConfig.KubernetesServiceNodePort,
|
||||||
}, nil
|
}, nil
|
||||||
@ -164,7 +160,7 @@ func (c *Controller) Start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reconcile during first run removing itself until server is ready.
|
// Reconcile during first run removing itself until server is ready.
|
||||||
endpointPorts := createEndpointPortSpec(c.PublicServicePort, "https", c.ExtraEndpointPorts)
|
endpointPorts := createEndpointPortSpec(c.PublicServicePort, "https")
|
||||||
if err := c.EndpointReconciler.RemoveEndpoints(kubernetesServiceName, c.PublicIP, endpointPorts); err == nil {
|
if err := c.EndpointReconciler.RemoveEndpoints(kubernetesServiceName, c.PublicIP, endpointPorts); err == nil {
|
||||||
klog.Error("Found stale data, removed previous endpoints on kubernetes service, apiserver didn't exit successfully previously")
|
klog.Error("Found stale data, removed previous endpoints on kubernetes service, apiserver didn't exit successfully previously")
|
||||||
} else if !storage.IsNotFound(err) {
|
} else if !storage.IsNotFound(err) {
|
||||||
@ -216,7 +212,7 @@ func (c *Controller) Stop() {
|
|||||||
if c.runner != nil {
|
if c.runner != nil {
|
||||||
c.runner.Stop()
|
c.runner.Stop()
|
||||||
}
|
}
|
||||||
endpointPorts := createEndpointPortSpec(c.PublicServicePort, "https", c.ExtraEndpointPorts)
|
endpointPorts := createEndpointPortSpec(c.PublicServicePort, "https")
|
||||||
finishedReconciling := make(chan struct{})
|
finishedReconciling := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
defer close(finishedReconciling)
|
defer close(finishedReconciling)
|
||||||
@ -278,11 +274,11 @@ func (c *Controller) UpdateKubernetesService(reconcile bool) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
servicePorts, serviceType := createPortAndServiceSpec(c.ServicePort, c.PublicServicePort, c.KubernetesServiceNodePort, "https", c.ExtraServicePorts)
|
servicePorts, serviceType := createPortAndServiceSpec(c.ServicePort, c.PublicServicePort, c.KubernetesServiceNodePort, "https")
|
||||||
if err := c.CreateOrUpdateMasterServiceIfNeeded(kubernetesServiceName, c.ServiceIP, servicePorts, serviceType, reconcile); err != nil {
|
if err := c.CreateOrUpdateMasterServiceIfNeeded(kubernetesServiceName, c.ServiceIP, servicePorts, serviceType, reconcile); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
endpointPorts := createEndpointPortSpec(c.PublicServicePort, "https", c.ExtraEndpointPorts)
|
endpointPorts := createEndpointPortSpec(c.PublicServicePort, "https")
|
||||||
if err := c.EndpointReconciler.ReconcileEndpoints(kubernetesServiceName, c.PublicIP, endpointPorts, reconcile); err != nil {
|
if err := c.EndpointReconciler.ReconcileEndpoints(kubernetesServiceName, c.PublicIP, endpointPorts, reconcile); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -291,34 +287,30 @@ func (c *Controller) UpdateKubernetesService(reconcile bool) error {
|
|||||||
|
|
||||||
// createPortAndServiceSpec creates an array of service ports.
|
// createPortAndServiceSpec creates an array of service ports.
|
||||||
// If the NodePort value is 0, just the servicePort is used, otherwise, a node port is exposed.
|
// If the NodePort value is 0, just the servicePort is used, otherwise, a node port is exposed.
|
||||||
func createPortAndServiceSpec(servicePort int, targetServicePort int, nodePort int, servicePortName string, extraServicePorts []corev1.ServicePort) ([]corev1.ServicePort, corev1.ServiceType) {
|
func createPortAndServiceSpec(servicePort int, targetServicePort int, nodePort int, servicePortName string) ([]corev1.ServicePort, corev1.ServiceType) {
|
||||||
//Use the Cluster IP type for the service port if NodePort isn't provided.
|
// 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.
|
// Otherwise, we will be binding the master service to a NodePort.
|
||||||
servicePorts := []corev1.ServicePort{{Protocol: corev1.ProtocolTCP,
|
servicePorts := []corev1.ServicePort{{
|
||||||
|
Protocol: corev1.ProtocolTCP,
|
||||||
Port: int32(servicePort),
|
Port: int32(servicePort),
|
||||||
Name: servicePortName,
|
Name: servicePortName,
|
||||||
TargetPort: intstr.FromInt(targetServicePort)}}
|
TargetPort: intstr.FromInt(targetServicePort),
|
||||||
|
}}
|
||||||
serviceType := corev1.ServiceTypeClusterIP
|
serviceType := corev1.ServiceTypeClusterIP
|
||||||
if nodePort > 0 {
|
if nodePort > 0 {
|
||||||
servicePorts[0].NodePort = int32(nodePort)
|
servicePorts[0].NodePort = int32(nodePort)
|
||||||
serviceType = corev1.ServiceTypeNodePort
|
serviceType = corev1.ServiceTypeNodePort
|
||||||
}
|
}
|
||||||
if extraServicePorts != nil {
|
|
||||||
servicePorts = append(servicePorts, extraServicePorts...)
|
|
||||||
}
|
|
||||||
return servicePorts, serviceType
|
return servicePorts, serviceType
|
||||||
}
|
}
|
||||||
|
|
||||||
// createEndpointPortSpec creates an array of endpoint ports
|
// createEndpointPortSpec creates the endpoint ports
|
||||||
func createEndpointPortSpec(endpointPort int, endpointPortName string, extraEndpointPorts []corev1.EndpointPort) []corev1.EndpointPort {
|
func createEndpointPortSpec(endpointPort int, endpointPortName string) []corev1.EndpointPort {
|
||||||
endpointPorts := []corev1.EndpointPort{{Protocol: corev1.ProtocolTCP,
|
return []corev1.EndpointPort{{
|
||||||
Port: int32(endpointPort),
|
Protocol: corev1.ProtocolTCP,
|
||||||
Name: endpointPortName,
|
Port: int32(endpointPort),
|
||||||
|
Name: endpointPortName,
|
||||||
}}
|
}}
|
||||||
if extraEndpointPorts != nil {
|
|
||||||
endpointPorts = append(endpointPorts, extraEndpointPorts...)
|
|
||||||
}
|
|
||||||
return endpointPorts
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateOrUpdateMasterServiceIfNeeded will create the specified service if it
|
// CreateOrUpdateMasterServiceIfNeeded will create the specified service if it
|
||||||
|
@ -159,17 +159,6 @@ type ExtraConfig struct {
|
|||||||
|
|
||||||
// The range of ports to be assigned to services with type=NodePort or greater
|
// The range of ports to be assigned to services with type=NodePort or greater
|
||||||
ServiceNodePortRange utilnet.PortRange
|
ServiceNodePortRange utilnet.PortRange
|
||||||
// Additional ports to be exposed on the GenericAPIServer service
|
|
||||||
// extraServicePorts is injectable in the event that more ports
|
|
||||||
// (other than the default 443/tcp) are exposed on the GenericAPIServer
|
|
||||||
// and those ports need to be load balanced by the GenericAPIServer
|
|
||||||
// service because this pkg is linked by out-of-tree projects
|
|
||||||
// like openshift which want to use the GenericAPIServer but also do
|
|
||||||
// more stuff.
|
|
||||||
ExtraServicePorts []apiv1.ServicePort
|
|
||||||
// Additional ports to be exposed on the GenericAPIServer endpoints
|
|
||||||
// Port names should align with ports defined in ExtraServicePorts
|
|
||||||
ExtraEndpointPorts []apiv1.EndpointPort
|
|
||||||
// If non-zero, the "kubernetes" services uses this port as NodePort.
|
// If non-zero, the "kubernetes" services uses this port as NodePort.
|
||||||
KubernetesServiceNodePort int
|
KubernetesServiceNodePort int
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user