Check for multiport services on Global Backend Ingress

This commit is contained in:
Daniel Tomcej
2019-06-27 01:42:03 -06:00
committed by Traefiker Bot
parent d35d5bd2e8
commit 8027e8ee23
5 changed files with 66 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
apiVersion: v1
kind: Endpoints
metadata:
name: service1
namespace: testing
subsets:
- addresses:
- ip: 10.10.0.1
ports:
- port: 8080
name: http
- port: 1111
name: foo

View File

@@ -0,0 +1,8 @@
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
namespace: testing
spec:
backend:
serviceName: service1
servicePort: 80

View File

@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: service1
namespace: testing
spec:
clusterIP: 10.0.0.1
ports:
- name: http
port: 80
targetPort: 8080
- name: foo
port: 1111
targetPort: 1111

View File

@@ -508,6 +508,10 @@ func (p *Provider) addGlobalBackend(cl Client, i *extensionsv1beta1.Ingress, tem
for _, port := range service.Spec.Ports {
if !equalPorts(port, i.Spec.Backend.ServicePort) {
continue
}
// We have to treat external-name service differently here b/c it doesn't have any endpoints
if service.Spec.Type == corev1.ServiceTypeExternalName {

View File

@@ -168,6 +168,33 @@ func TestProvider_loadIngresses(t *testing.T) {
),
),
},
{
desc: "loadGlobalIngressWithMultiplePortNumbers",
fixtures: []string{
filepath.Join("fixtures", "loadGlobalIngressWithMultiplePortNumbers_ingresses.yml"),
filepath.Join("fixtures", "loadGlobalIngressWithMultiplePortNumbers_services.yml"),
filepath.Join("fixtures", "loadGlobalIngressWithMultiplePortNumbers_endpoints.yml"),
},
expected: buildConfiguration(
backends(
backend("global-default-backend",
lbMethod("wrr"),
servers(
server("http://10.10.0.1:8080", weight(1)),
),
),
),
frontends(
frontend("global-default-backend",
frontendName("global-default-frontend"),
passHostHeader(),
routes(
route("/", "PathPrefix:/"),
),
),
),
),
},
{
desc: "loadGlobalIngressWithHttpsPortNames",
fixtures: []string{