Adding AppProtocol to Service and Endpoints Ports

This commit is contained in:
Rob Scott
2020-02-18 17:30:57 -08:00
parent 4e79344501
commit 6a33727632
29 changed files with 1598 additions and 986 deletions

View File

@@ -444,17 +444,14 @@ func (e *EndpointController) syncService(key string) error {
} else {
for i := range service.Spec.Ports {
servicePort := &service.Spec.Ports[i]
portName := servicePort.Name
portProto := servicePort.Protocol
portNum, err := podutil.FindPort(pod, servicePort)
if err != nil {
klog.V(4).Infof("Failed to find port for service %s/%s: %v", service.Namespace, service.Name, err)
continue
}
epp := endpointPortFromServicePort(servicePort, portNum)
var readyEps, notReadyEps int
epp := &v1.EndpointPort{Name: portName, Port: int32(portNum), Protocol: portProto}
subsets, readyEps, notReadyEps = addEndpointSubset(subsets, pod, epa, epp, tolerateUnreadyEndpoints)
totalReadyEps = totalReadyEps + readyEps
totalNotReadyEps = totalNotReadyEps + notReadyEps
@@ -608,3 +605,15 @@ func shouldPodBeInEndpoints(pod *v1.Pod) bool {
return true
}
}
func endpointPortFromServicePort(servicePort *v1.ServicePort, portNum int) *v1.EndpointPort {
epp := &v1.EndpointPort{
Name: servicePort.Name,
Port: int32(portNum),
Protocol: servicePort.Protocol,
}
if utilfeature.DefaultFeatureGate.Enabled(features.ServiceAppProtocol) {
epp.AppProtocol = servicePort.AppProtocol
}
return epp
}