Merge pull request #3615 from kppullin/fix-l4-external-names

Pass k8s `Service` data through to the TCP balancer script.
This commit is contained in:
Kubernetes Prow Robot 2019-01-03 06:53:56 -08:00 committed by GitHub
commit c62dc221bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 0 deletions

View file

@ -337,6 +337,7 @@ func (n *NGINXController) getStreamServices(configmapName string, proto apiv1.Pr
ProxyProtocol: svcProxyProtocol, ProxyProtocol: svcProxyProtocol,
}, },
Endpoints: endps, Endpoints: endps,
Service: svc,
}) })
} }
// Keep upstream order sorted to reduce unnecessary nginx config reloads. // Keep upstream order sorted to reduce unnecessary nginx config reloads.

View file

@ -816,19 +816,31 @@ func configureDynamically(pcfg *ingress.Configuration, port int, isDynamicCertif
streams := make([]ingress.Backend, 0) streams := make([]ingress.Backend, 0)
for _, ep := range pcfg.TCPEndpoints { for _, ep := range pcfg.TCPEndpoints {
var service *apiv1.Service
if ep.Service != nil {
service = &apiv1.Service{Spec: ep.Service.Spec}
}
key := fmt.Sprintf("tcp-%v-%v-%v", ep.Backend.Namespace, ep.Backend.Name, ep.Backend.Port.String()) key := fmt.Sprintf("tcp-%v-%v-%v", ep.Backend.Namespace, ep.Backend.Name, ep.Backend.Port.String())
streams = append(streams, ingress.Backend{ streams = append(streams, ingress.Backend{
Name: key, Name: key,
Endpoints: ep.Endpoints, Endpoints: ep.Endpoints,
Port: intstr.FromInt(ep.Port), Port: intstr.FromInt(ep.Port),
Service: service,
}) })
} }
for _, ep := range pcfg.UDPEndpoints { for _, ep := range pcfg.UDPEndpoints {
var service *apiv1.Service
if ep.Service != nil {
service = &apiv1.Service{Spec: ep.Service.Spec}
}
key := fmt.Sprintf("udp-%v-%v-%v", ep.Backend.Namespace, ep.Backend.Name, ep.Backend.Port.String()) key := fmt.Sprintf("udp-%v-%v-%v", ep.Backend.Namespace, ep.Backend.Name, ep.Backend.Port.String())
streams = append(streams, ingress.Backend{ streams = append(streams, ingress.Backend{
Name: key, Name: key,
Endpoints: ep.Endpoints, Endpoints: ep.Endpoints,
Port: intstr.FromInt(ep.Port), Port: intstr.FromInt(ep.Port),
Service: service,
}) })
} }

View file

@ -322,6 +322,8 @@ type L4Service struct {
Backend L4Backend `json:"backend"` Backend L4Backend `json:"backend"`
// Endpoints active endpoints of the service // Endpoints active endpoints of the service
Endpoints []Endpoint `json:"endpoints,omitempty"` Endpoints []Endpoint `json:"endpoints,omitempty"`
// k8s Service
Service *apiv1.Service `json:"service,omitempty"`
} }
// L4Backend describes the kubernetes service behind L4 Ingress service // L4Backend describes the kubernetes service behind L4 Ingress service