diff --git a/dataclients/kubernetes/eastwest.go b/dataclients/kubernetes/eastwest.go index 9fe99b8575..7c98cd7dbd 100644 --- a/dataclients/kubernetes/eastwest.go +++ b/dataclients/kubernetes/eastwest.go @@ -21,29 +21,6 @@ func createEastWestRouteIng(eastWestDomainRegexpPostfix, name, ns string, r *esk return &ewR } -func createEastWestRoutesIng(eastWestDomainRegexpPostfix, name, ns string, routes []*eskip.Route) []*eskip.Route { - ewroutes := make([]*eskip.Route, 0) - newHostRegexps := []string{"^" + name + "[.]" + ns + eastWestDomainRegexpPostfix + "$"} - ingressAlreadyHandled := false - - for _, r := range routes { - // TODO(sszuecs) we have to rethink how to handle eastwest routes in more complex cases - n := countPathRoutes(r) - // FIX memory leak in route creation - if strings.HasPrefix(r.Id, "kubeew") || (n == 0 && ingressAlreadyHandled) { - continue - } - r.Namespace = ns // store namespace - r.Name = name // store name - ewR := *r - ewR.HostRegexps = newHostRegexps - ewR.Id = eastWestRouteID(r.Id) - ewroutes = append(ewroutes, &ewR) - ingressAlreadyHandled = true - } - return ewroutes -} - func createEastWestRouteRG(name, ns, postfix string, r *eskip.Route) *eskip.Route { hostRx := createHostRx(fmt.Sprintf("%s.%s.%s", name, ns, postfix)) diff --git a/dataclients/kubernetes/ingress.go b/dataclients/kubernetes/ingress.go index 80971f2362..8a41278f5a 100644 --- a/dataclients/kubernetes/ingress.go +++ b/dataclients/kubernetes/ingress.go @@ -278,7 +278,8 @@ func applyAnnotationPredicates(m PathMode, r *eskip.Route, annotation string) er } func (ing *ingress) addEndpointsRule(ic ingressContext, host string, prule *definitions.PathRule) error { - endpointsRoute, err := convertPathRule(ic.state, ic.ingress.Metadata, host, prule, ic.pathMode) + meta := ic.ingress.Metadata + endpointsRoute, err := convertPathRule(ic.state, meta, host, prule, ic.pathMode) if err != nil { // if the service is not found the route should be removed if err == errServiceNotFound || err == errResourceNotFound { @@ -295,7 +296,7 @@ func (ing *ingress) addEndpointsRule(ic ingressContext, host string, prule *defi endpointsRoute.Filters = filters // add pre-configured default filters - df, err := ic.defaultFilters.getNamed(ic.ingress.Metadata.Namespace, prule.Backend.ServiceName) + df, err := ic.defaultFilters.getNamed(meta.Namespace, prule.Backend.ServiceName) if err != nil { ic.logger.Errorf("Failed to retrieve default filters: %v.", err) } else { @@ -318,17 +319,24 @@ func (ing *ingress) addEndpointsRule(ic ingressContext, host string, prule *defi redirect.setHostDisabled(host) } + if ing.kubernetesEnableEastWest { + ewRoute := createEastWestRouteIng(ing.eastWestDomainRegexpPostfix, meta.Name, meta.Namespace, endpointsRoute) + ewHost := fmt.Sprintf("%s.%s.%s", meta.Name, meta.Namespace, ing.eastWestDomainRegexpPostfix) + ic.addHostRoute(ewHost, ewRoute) + } return nil } -func addExtraRoutes(ic ingressContext, hosts []string, host string, path string) { +func addExtraRoutes(ic ingressContext, hosts []string, host, path, eastWestDomainRegexpPostfix string, enableEastWest bool) { // add extra routes from optional annotation for extraIndex, r := range ic.extraRoutes { + name := ic.ingress.Metadata.Name + ns := ic.ingress.Metadata.Namespace route := *r route.HostRegexps = hosts route.Id = routeIDForCustom( - ic.ingress.Metadata.Namespace, - ic.ingress.Metadata.Name, + ns, + name, route.Id, host+strings.Replace(path, "/", "_", -1), extraIndex) @@ -339,6 +347,11 @@ func addExtraRoutes(ic ingressContext, hosts []string, host string, path string) } else { log.Errorf("Failed to add route having %d path routes: %v", n, r) } + if enableEastWest { + ewRoute := createEastWestRouteIng(eastWestDomainRegexpPostfix, name, ns, &route) + ewHost := fmt.Sprintf("%s.%s.%s", name, ns, eastWestDomainRegexpPostfix) + ic.addHostRoute(ewHost, ewRoute) + } } } @@ -439,7 +452,7 @@ func (ing *ingress) addSpecRule(ic ingressContext, ru *definitions.Rule) error { // update Traffic field for each backend computeBackendWeights(ic.backendWeights, ru) for _, prule := range ru.Http.Paths { - addExtraRoutes(ic, host, ru.Host, prule.Path) + addExtraRoutes(ic, host, ru.Host, prule.Path, ing.eastWestDomainRegexpPostfix, ing.kubernetesEnableEastWest) if prule.Backend.Traffic > 0 { err := ing.addEndpointsRule(ic, ru.Host, prule) if err != nil { @@ -550,16 +563,6 @@ func countPathRoutes(r *eskip.Route) int { return i } -// TODO: check if this creates additional routes also for routes like the HTTPS redirect -func (ing *ingress) addEastWestRoutes(hostRoutes map[string][]*eskip.Route, i *definitions.IngressItem) { - for _, rule := range i.Spec.Rules { - if rs, ok := hostRoutes[rule.Host]; ok { - rs = append(rs, createEastWestRoutesIng(ing.eastWestDomainRegexpPostfix, i.Metadata.Name, i.Metadata.Namespace, rs)...) - hostRoutes[rule.Host] = rs - } - } -} - // parse filter and ratelimit annotation func annotationFilter(i *definitions.IngressItem, logger *log.Entry) []*eskip.Filter { var annotationFilter string @@ -675,9 +678,6 @@ func (ing *ingress) ingressRoute( return nil, err } } - if ing.kubernetesEnableEastWest { - ing.addEastWestRoutes(hostRoutes, i) - } return route, nil } @@ -728,6 +728,10 @@ func hasCatchAllRoutes(routes []*eskip.Route) bool { // because Ingress status field is v1beta1.LoadBalancerIngress that only // supports IP and Hostname as string. func (ing *ingress) convert(state *clusterState, df defaultFilters) ([]*eskip.Route, error) { + var ewIngInfo map[string][]string // r.Id -> {namespace, name} + if ing.kubernetesEnableEastWest { + ewIngInfo = make(map[string][]string) + } routes := make([]*eskip.Route, 0, len(state.ingresses)) hostRoutes := make(map[string][]*eskip.Route) redirect := createRedirectInfo(ing.provideHTTPSRedirect, ing.httpsRedirectCode) @@ -738,6 +742,9 @@ func (ing *ingress) convert(state *clusterState, df defaultFilters) ([]*eskip.Ro } if r != nil { routes = append(routes, r) + if ing.kubernetesEnableEastWest { + ewIngInfo[r.Id] = []string{i.Metadata.Namespace, i.Metadata.Name} + } } } @@ -755,5 +762,17 @@ func (ing *ingress) convert(state *clusterState, df defaultFilters) ([]*eskip.Ro } } + if ing.kubernetesEnableEastWest && len(routes) > 0 && len(ewIngInfo) > 0 { + ewroutes := make([]*eskip.Route, 0, len(routes)) + for _, r := range routes { + if v, ok := ewIngInfo[r.Id]; ok { + ewroutes = append(ewroutes, createEastWestRouteIng(ing.eastWestDomainRegexpPostfix, v[0], v[1], r)) + } + } + l := len(routes) + routes = append(routes, ewroutes...) + log.Infof("enabled east west routes: %d %d %d %d", l, len(routes), len(ewroutes), len(hostRoutes)) + } + return routes, nil } diff --git a/dataclients/kubernetes/ingress_test.go b/dataclients/kubernetes/ingress_test.go index 768a7b8f21..1aa6c25637 100644 --- a/dataclients/kubernetes/ingress_test.go +++ b/dataclients/kubernetes/ingress_test.go @@ -9,4 +9,5 @@ import ( func TestIngressFixtures(t *testing.T) { kubernetestest.FixturesToTest(t, "testdata/ingress/named-ports") kubernetestest.FixturesToTest(t, "testdata/ingress/ingress-data") + kubernetestest.FixturesToTest(t, "testdata/ingress/eastwest") } diff --git a/dataclients/kubernetes/kube_test.go b/dataclients/kubernetes/kube_test.go index 0806e6abd9..cd8997157a 100644 --- a/dataclients/kubernetes/kube_test.go +++ b/dataclients/kubernetes/kube_test.go @@ -300,8 +300,10 @@ func checkRoutes(t *testing.T, r []*eskip.Route, expected map[string]string) { } for id, backend := range expected { + t.Logf("id: %s", id) var found bool for _, ri := range r { + t.Logf("%s", ri.Id) if ri.Id == id { if ri.Backend != backend { t.Errorf("invalid backend for route %s, %v", ri.Id, cmp.Diff(ri.Backend, backend)) @@ -1390,10 +1392,10 @@ func TestConvertPathRuleEastWestEnabled(t *testing.T) { } checkRoutes(t, r, map[string]string{ - "kube___catchall__new1_example_org____": "", - "kube_namespace1__new1__new1_example_org___test1__service1": "http://1.1.1.0:8080", - "kubeew_namespace1__new1__new1_example_org___test1__service1": "http://1.1.1.0:8080", - "kubeew___catchall__new1_example_org____": "", + "kube___catchall__new1_example_org____": "", + "kube_namespace1__new1__new1_example_org___test1__service1": "http://1.1.1.0:8080", + "kubeew_namespace1__new1__new1_example_org___test1__service1": "http://1.1.1.0:8080", + "kube___catchall__new1_namespace1____skipper___cluster___local____": "", }) }) @@ -1462,12 +1464,12 @@ func TestConvertPathRuleEastWestEnabled(t *testing.T) { } checkRoutes(t, r, map[string]string{ - "kube_namespace1__new1__new1_example_org___test1__service1": "http://1.1.1.0:8080", - "kube___catchall__new1_example_org____": "", - "kube_namespace1__new1__new1_example_org___test2__service1": "http://1.1.1.0:8080", - //"kubeew_namespace1__new1__new1_example_org___test1__service1": "http://1.1.1.0:8080", - "kubeew_namespace1__new1__new1_example_org___test2__service1": "http://1.1.1.0:8080", - "kubeew___catchall__new1_example_org____": "", + "kube_namespace1__new1__new1_example_org___test1__service1": "http://1.1.1.0:8080", + "kube___catchall__new1_example_org____": "", + "kube_namespace1__new1__new1_example_org___test2__service1": "http://1.1.1.0:8080", + "kubeew_namespace1__new1__new1_example_org___test1__service1": "http://1.1.1.0:8080", + "kubeew_namespace1__new1__new1_example_org___test2__service1": "http://1.1.1.0:8080", + "kube___catchall__new1_namespace1____skipper___cluster___local____": "", }) }) @@ -1574,6 +1576,7 @@ func TestConvertPathRuleEastWestEnabled(t *testing.T) { "kube_namespace1__test1__host1_____svcname1": "http://2.2.2.0:8080", "kube_namespace1__test1__host2_____svcname1": "http://2.2.2.0:8181", "kube_namespace1__test1______": "http://2.2.2.0:8080", + "kubeew_namespace1__test1______": "http://2.2.2.0:8080", "kubeew_namespace1__test1__host1_____svcname1": "http://2.2.2.0:8080", "kubeew_namespace1__test1__host2_____svcname1": "http://2.2.2.0:8181", }) @@ -3156,256 +3159,6 @@ func TestSkipperCustomRoutes(t *testing.T) { } } -func TestSkipperCustomRoutesEastWest(t *testing.T) { - for _, ti := range []struct { - msg string - endpoints []*endpoint - services []*service - ingresses []*definitions.IngressItem - expectedRoutes map[string]string - }{{ - msg: "ingress with 1 host definitions and 1 additional custom route", - endpoints: testEndpoints("foo", "bar", "1.1.1", 1, map[string]int{"baz": 8181}), - services: []*service{ - testService("foo", "bar", "1.2.3.4", map[string]int{"baz": 8181}), - }, - ingresses: []*definitions.IngressItem{testIngress("foo", "qux", "", "", "", "", - `Method("OPTIONS") -> `, - "", "", definitions.BackendPort{}, 1.0, - testRule("www1.example.org", testPathRule("/", "bar", definitions.BackendPort{Value: "baz"})), - )}, - expectedRoutes: map[string]string{ - "kube_foo__qux__www1_example_org_____bar": "Host(/^www1[.]example[.]org$/) && PathRegexp(/^\\//) -> \"http://1.1.1.0:8181\"", - "kube_foo__qux__0__www1_example_org_____": "Host(/^www1[.]example[.]org$/) && PathRegexp(/^\\//) && Method(\"OPTIONS\") -> ", - //"kubeew_foo__qux__www1_example_org_____bar": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\\//) -> \"http://1.1.1.0:8181\"", - "kubeew_foo__qux__0__www1_example_org_____": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\\//) && Method(\"OPTIONS\") -> ", - }, - }, { - msg: "ingress with 1 host definitions with path and 1 additional custom route", - endpoints: testEndpoints("foo", "bar", "1.1.1", 1, map[string]int{"baz": 8181}), - services: []*service{ - testService("foo", "bar", "1.2.3.4", map[string]int{"baz": 8181}), - }, - ingresses: []*definitions.IngressItem{testIngress("foo", "qux", "", "", "", "", - `Method("OPTIONS") -> `, - "", "", definitions.BackendPort{}, 1.0, - testRule("www1.example.org", testPathRule("/a/path", "bar", definitions.BackendPort{Value: "baz"})), - )}, - expectedRoutes: map[string]string{ - "kube_foo__qux__www1_example_org___a_path__bar": "Host(/^www1[.]example[.]org$/) && PathRegexp(/^(\\/a\\/path)/) -> \"http://1.1.1.0:8181\"", - "kube_foo__qux__0__www1_example_org_a_path____": "Host(/^www1[.]example[.]org$/) && PathRegexp(/^(\\/a\\/path)/) && Method(\"OPTIONS\") -> ", - "kube___catchall__www1_example_org____": "Host(/^www1[.]example[.]org$/) -> ", - //"kubeew_foo__qux__www1_example_org___a_path__bar": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\\/a\\/path/) -> \"http://1.1.1.0:8181\"", - "kubeew_foo__qux__0__www1_example_org_a_path____": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^(\\/a\\/path)/) && Method(\"OPTIONS\") -> ", - "kubeew___catchall__www1_example_org____": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) -> ", - }, - }, { - msg: "ingress with 2 host definitions and 1 additional custom route", - endpoints: testEndpoints("foo", "bar", "1.1.1", 1, map[string]int{"baz": 8181}), - services: []*service{ - testService("foo", "bar", "1.2.3.4", map[string]int{"baz": 8181}), - }, - ingresses: []*definitions.IngressItem{testIngress("foo", "qux", "", "", "", "", - `Method("OPTIONS") -> `, - "", "", definitions.BackendPort{}, 1.0, - testRule("www1.example.org", testPathRule("/", "bar", definitions.BackendPort{Value: "baz"})), - testRule("www2.example.org", testPathRule("/", "bar", definitions.BackendPort{Value: "baz"})), - )}, - expectedRoutes: map[string]string{ - "kube_foo__qux__www1_example_org_____bar": "Host(/^www1[.]example[.]org$/) && PathRegexp(/^\\//) -> \"http://1.1.1.0:8181\"", - "kube_foo__qux__0__www1_example_org_____": "Host(/^www1[.]example[.]org$/) && PathRegexp(/^\\//) && Method(\"OPTIONS\") -> ", - "kube_foo__qux__www2_example_org_____bar": "Host(/^www2[.]example[.]org$/) && PathRegexp(/^\\//) -> \"http://1.1.1.0:8181\"", - "kube_foo__qux__0__www2_example_org_____": "Host(/^www2[.]example[.]org$/) && PathRegexp(/^\\//) && Method(\"OPTIONS\") -> ", - //"kubeew_foo__qux__www1_example_org_____bar": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\\//) -> \"http://1.1.1.0:8181\"", - "kubeew_foo__qux__0__www1_example_org_____": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\\//) && Method(\"OPTIONS\") -> ", - //"kubeew_foo__qux__www2_example_org_____bar": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\\//) -> \"http://1.1.1.0:8181\"", - "kubeew_foo__qux__0__www2_example_org_____": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\\//) && Method(\"OPTIONS\") -> ", - }, - }, { - msg: "ingress with 2 host definitions with path and 1 additional custom route", - endpoints: testEndpoints("foo", "bar", "1.1.1", 1, map[string]int{"baz": 8181}), - services: []*service{ - testService("foo", "bar", "1.2.3.4", map[string]int{"baz": 8181}), - }, - ingresses: []*definitions.IngressItem{testIngress("foo", "qux", "", "", "", "", - `Method("OPTIONS") -> `, - "", "", definitions.BackendPort{}, 1.0, - testRule("www1.example.org", testPathRule("/a/path", "bar", definitions.BackendPort{Value: "baz"})), - testRule("www2.example.org", testPathRule("/another/path", "bar", definitions.BackendPort{Value: "baz"})), - )}, - expectedRoutes: map[string]string{ - "kube_foo__qux__www1_example_org___a_path__bar": "Host(/^www1[.]example[.]org$/) && PathRegexp(/^(\\/a\\/path)/) -> \"http://1.1.1.0:8181\"", - "kube_foo__qux__0__www1_example_org_a_path____": "Host(/^www1[.]example[.]org$/) && PathRegexp(/^(\\/a\\/path)/) && Method(\"OPTIONS\") -> ", - "kube___catchall__www1_example_org____": "Host(/^www1[.]example[.]org$/) -> ", - "kube_foo__qux__www2_example_org___another_path__bar": "Host(/^www2[.]example[.]org$/) && PathRegexp(/^(\\/another\\/path)/) -> \"http://1.1.1.0:8181\"", - "kube_foo__qux__0__www2_example_org_another_path____": "Host(/^www2[.]example[.]org$/) && PathRegexp(/^(\\/another\\/path)/) && Method(\"OPTIONS\") -> ", - "kube___catchall__www2_example_org____": "Host(/^www2[.]example[.]org$/) -> ", - //"kubeew_foo__qux__www1_example_org___a_path__bar": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^(\\/a\\/path)/) -> \"http://1.1.1.0:8181\"", - "kubeew_foo__qux__0__www1_example_org_a_path____": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^(\\/a\\/path)/) && Method(\"OPTIONS\") -> ", - "kubeew___catchall__www1_example_org____": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) -> ", - //"kubeew_foo__qux__www2_example_org___another_path__bar": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^(\\/another\\/path)/) -> \"http://1.1.1.0:8181\"", - "kubeew_foo__qux__0__www2_example_org_another_path____": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^(\\/another\\/path)/) && Method(\"OPTIONS\") -> ", - "kubeew___catchall__www2_example_org____": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) -> ", - }, - }, { - msg: "ingress with 3 host definitions with one path and 3 additional custom routes", - endpoints: append(testEndpoints("foo", "bar", "1.1.1", 1, map[string]int{"baz": 8181}), - testEndpoints("foo", "baz", "1.1.2", 1, map[string]int{"baz": 8181})...), - services: []*service{ - testService("foo", "bar", "1.2.3.4", map[string]int{"baz": 8181}), - testService("foo", "baz", "1.2.3.6", map[string]int{"baz": 8181}), - }, - ingresses: []*definitions.IngressItem{testIngress("foo", "qux", "", "", "", "", - `a: Method("OPTIONS") -> ; - b: Cookie("alpha", /^enabled$/) -> "http://1.1.2.0:8181"; - c: Path("/a/path/somewhere") -> "https://some.other-url.org/a/path/somewhere";`, - "", "", definitions.BackendPort{}, 1.0, - testRule("www1.example.org", testPathRule("/", "bar", definitions.BackendPort{Value: "baz"})), - testRule("www2.example.org", testPathRule("/", "bar", definitions.BackendPort{Value: "baz"})), - testRule("www3.example.org", testPathRule("/a/path", "bar", definitions.BackendPort{Value: "baz"})), - )}, - expectedRoutes: map[string]string{ - "kube_foo__qux__www1_example_org_____bar": "Host(/^www1[.]example[.]org$/) && PathRegexp(/^\\//) -> \"http://1.1.1.0:8181\"", - "kube_foo__qux_a_0__www1_example_org_____": "Host(/^www1[.]example[.]org$/) && PathRegexp(/^\\//) && Method(\"OPTIONS\") -> ", - "kube_foo__qux_b_1__www1_example_org_____": "Host(/^www1[.]example[.]org$/) && PathRegexp(/^\\//) && Cookie(\"alpha\", \"^enabled$\") -> \"http://1.1.2.0:8181\"", - "kube_foo__qux_c_2__www1_example_org_____": "Path(\"/a/path/somewhere\") && Host(/^www1[.]example[.]org$/) && PathRegexp(/^\\//) -> \"https://some.other-url.org/a/path/somewhere\"", - - "kube_foo__qux__www2_example_org_____bar": "Host(/^www2[.]example[.]org$/) && PathRegexp(/^\\//) -> \"http://1.1.1.0:8181\"", - "kube_foo__qux_a_0__www2_example_org_____": "Host(/^www2[.]example[.]org$/) && PathRegexp(/^\\//) && Method(\"OPTIONS\") -> ", - "kube_foo__qux_b_1__www2_example_org_____": "Host(/^www2[.]example[.]org$/) && PathRegexp(/^\\//) && Cookie(\"alpha\", \"^enabled$\") -> \"http://1.1.2.0:8181\"", - "kube_foo__qux_c_2__www2_example_org_____": "Path(\"/a/path/somewhere\") && Host(/^www2[.]example[.]org$/) && PathRegexp(/^\\//) -> \"https://some.other-url.org/a/path/somewhere\"", - - "kube_foo__qux__www3_example_org___a_path__bar": "Host(/^www3[.]example[.]org$/) && PathRegexp(/^(\\/a\\/path)/) -> \"http://1.1.1.0:8181\"", - "kube_foo__qux_a_0__www3_example_org_a_path____": "Host(/^www3[.]example[.]org$/) && PathRegexp(/^(\\/a\\/path)/) && Method(\"OPTIONS\") -> ", - "kube_foo__qux_b_1__www3_example_org_a_path____": "Host(/^www3[.]example[.]org$/) && PathRegexp(/^(\\/a\\/path)/) && Cookie(\"alpha\", \"^enabled$\") -> \"http://1.1.2.0:8181\"", - "kube_foo__qux_c_2__www3_example_org_a_path____": "Path(\"/a/path/somewhere\") && Host(/^www3[.]example[.]org$/) && PathRegexp(/^(\\/a\\/path)/) -> \"https://some.other-url.org/a/path/somewhere\"", - "kube___catchall__www3_example_org____": "Host(/^www3[.]example[.]org$/) -> ", - - //"kubeew_foo__qux__www1_example_org_____bar": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\\//) -> \"http://1.1.1.0:8181\"", - "kubeew_foo__qux_a_0__www1_example_org_____": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\\//) && Method(\"OPTIONS\") -> ", - //"kubeew_foo__qux_b_1__www1_example_org_____": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\\//) && Cookie(\"alpha\", \"^enabled$\") -> \"http://1.1.2.0:8181\"", - //"kubeew_foo__qux__www2_example_org_____bar": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\\//) -> \"http://1.1.1.0:8181\"", - "kubeew_foo__qux_a_0__www2_example_org_____": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\\//) && Method(\"OPTIONS\") -> ", - //"kubeew_foo__qux_b_1__www2_example_org_____": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\\//) && Cookie(\"alpha\", \"^enabled$\") -> \"http://1.1.2.0:8181\"", - - //"kubeew_foo__qux__www3_example_org___a_path__bar": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\\/a\\/path/) -> \"http://1.1.1.0:8181\"", - "kubeew_foo__qux_a_0__www3_example_org_a_path____": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^(\\/a\\/path)/) && Method(\"OPTIONS\") -> ", - //"kubeew_foo__qux_b_1__www3_example_org_a_path____": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\\/a\\/path/) && Cookie(\"alpha\", \"^enabled$\") -> \"http://1.1.2.0:8181\"", - - "kubeew_foo__qux_c_2__www3_example_org_a_path____": "Path(\"/a/path/somewhere\") && Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^(\\/a\\/path)/) -> \"https://some.other-url.org/a/path/somewhere\"", - "kubeew_foo__qux_c_2__www1_example_org_____": "Path(\"/a/path/somewhere\") && Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\\//) -> \"https://some.other-url.org/a/path/somewhere\"", - "kubeew_foo__qux_c_2__www2_example_org_____": "Path(\"/a/path/somewhere\") && Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\\//) -> \"https://some.other-url.org/a/path/somewhere\"", - "kubeew___catchall__www3_example_org____": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) -> "}, - }, { - msg: "ingress with 3 host definitions with one without path and 3 additional custom routes", - endpoints: append(testEndpoints("foo", "bar", "1.1.1", 1, map[string]int{"baz": 8181}), - testEndpoints("foo", "baz", "1.1.2", 1, map[string]int{"baz": 8181})...), - services: []*service{ - testService("foo", "bar", "1.2.3.4", map[string]int{"baz": 8181}), - testService("foo", "baz", "1.2.3.6", map[string]int{"baz": 8181}), - }, - ingresses: []*definitions.IngressItem{testIngress("foo", "qux", "", "", "", "", - `a: Method("OPTIONS") -> ; - b: Cookie("alpha", /^enabled$/) -> "http://1.1.2.0:8181"; - c: Path("/a/path/somewhere") -> "https://some.other-url.org/a/path/somewhere";`, - "", "", definitions.BackendPort{}, 1.0, - testRule("www1.example.org", testPathRule("", "bar", definitions.BackendPort{Value: "baz"})), - testRule("www2.example.org", testPathRule("/", "bar", definitions.BackendPort{Value: "baz"})), - testRule("www3.example.org", testPathRule("/a/path", "bar", definitions.BackendPort{Value: "baz"})), - )}, - expectedRoutes: map[string]string{ - "kube_foo__qux__www1_example_org____bar": "Host(/^www1[.]example[.]org$/) -> \"http://1.1.1.0:8181\"", - "kube_foo__qux_a_0__www1_example_org____": "Host(/^www1[.]example[.]org$/) && Method(\"OPTIONS\") -> ", - "kube_foo__qux_b_1__www1_example_org____": "Host(/^www1[.]example[.]org$/) && Cookie(\"alpha\", \"^enabled$\") -> \"http://1.1.2.0:8181\"", - "kube_foo__qux_c_2__www1_example_org____": "Path(\"/a/path/somewhere\") && Host(/^www1[.]example[.]org$/) -> \"https://some.other-url.org/a/path/somewhere\"", - - //"kubeew_foo__qux__www1_example_org____bar": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) -> \"http://1.1.1.0:8181\"", - //"kubeew_foo__qux__www2_example_org_____bar": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\\//) -> \"http://1.1.1.0:8181\"", - - "kubeew_foo__qux_a_0__www1_example_org____": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && Method(\"OPTIONS\") -> ", - //"kubeew_foo__qux_b_1__www1_example_org____": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && Cookie(\"alpha\", \"^enabled$\") -> \"http://1.1.2.0:8181\"", - "kubeew_foo__qux_c_2__www1_example_org____": "Path(\"/a/path/somewhere\") && Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) -> \"https://some.other-url.org/a/path/somewhere\"", - - "kube_foo__qux__www2_example_org_____bar": "Host(/^www2[.]example[.]org$/) && PathRegexp(/^\\//) -> \"http://1.1.1.0:8181\"", - "kube_foo__qux_a_0__www2_example_org_____": "Host(/^www2[.]example[.]org$/) && PathRegexp(/^\\//) && Method(\"OPTIONS\") -> ", - "kube_foo__qux_b_1__www2_example_org_____": "Host(/^www2[.]example[.]org$/) && PathRegexp(/^\\//) && Cookie(\"alpha\", \"^enabled$\") -> \"http://1.1.2.0:8181\"", - "kube_foo__qux_c_2__www2_example_org_____": "Path(\"/a/path/somewhere\") && Host(/^www2[.]example[.]org$/) && PathRegexp(/^\\//) -> \"https://some.other-url.org/a/path/somewhere\"", - - "kubeew_foo__qux_a_0__www2_example_org_____": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\\//) && Method(\"OPTIONS\") -> ", - //"kubeew_foo__qux_b_1__www2_example_org_____": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\\//) && Cookie(\"alpha\", \"^enabled$\") -> \"http://1.1.2.0:8181\"", - "kubeew_foo__qux_c_2__www2_example_org_____": "Path(\"/a/path/somewhere\") && Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\\//) -> \"https://some.other-url.org/a/path/somewhere\"", - - "kube_foo__qux__www3_example_org___a_path__bar": "Host(/^www3[.]example[.]org$/) && PathRegexp(/^(\\/a\\/path)/) -> \"http://1.1.1.0:8181\"", - "kube_foo__qux_a_0__www3_example_org_a_path____": "Host(/^www3[.]example[.]org$/) && PathRegexp(/^(\\/a\\/path)/) && Method(\"OPTIONS\") -> ", - "kube_foo__qux_b_1__www3_example_org_a_path____": "Host(/^www3[.]example[.]org$/) && PathRegexp(/^(\\/a\\/path)/) && Cookie(\"alpha\", \"^enabled$\") -> \"http://1.1.2.0:8181\"", - "kube_foo__qux_c_2__www3_example_org_a_path____": "Path(\"/a/path/somewhere\") && Host(/^www3[.]example[.]org$/) && PathRegexp(/^(\\/a\\/path)/) -> \"https://some.other-url.org/a/path/somewhere\"", - //"kubeew_foo__qux__www3_example_org___a_path__bar": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\\/a\\/path/) -> \"http://1.1.1.0:8181\"", - "kubeew_foo__qux_a_0__www3_example_org_a_path____": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^(\\/a\\/path)/) && Method(\"OPTIONS\") -> ", - //"kubeew_foo__qux_b_1__www3_example_org_a_path____": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\\/a\\/path/) && Cookie(\"alpha\", \"^enabled$\") -> \"http://1.1.2.0:8181\"", - "kubeew_foo__qux_c_2__www3_example_org_a_path____": "Path(\"/a/path/somewhere\") && Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^(\\/a\\/path)/) -> \"https://some.other-url.org/a/path/somewhere\"", - - "kube___catchall__www3_example_org____": "Host(/^www3[.]example[.]org$/) -> ", - "kubeew___catchall__www3_example_org____": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) -> ", - }, - }, { - msg: "ingress with 1 host definitions and 1 additional custom route, changed pathmode to PathSubtree", - endpoints: testEndpoints("foo", "bar", "1.1.1", 1, map[string]int{"baz": 8181}), - services: []*service{ - testService("foo", "bar", "1.2.3.4", map[string]int{"baz": 8181}), - }, - ingresses: []*definitions.IngressItem{testIngress("foo", "qux", "", "", "", "", - `Method("OPTIONS") -> `, - "path-prefix", "", definitions.BackendPort{}, 1.0, - testRule("www1.example.org", testPathRule("/", "bar", definitions.BackendPort{Value: "baz"})), - )}, - expectedRoutes: map[string]string{ - "kube_foo__qux__www1_example_org_____bar": "Host(/^www1[.]example[.]org$/) && PathSubtree(\"/\") -> \"http://1.1.1.0:8181\"", - "kube_foo__qux__0__www1_example_org_____": "Host(/^www1[.]example[.]org$/) && Method(\"OPTIONS\") && PathSubtree(\"/\") -> ", - "kubeew_foo__qux__www1_example_org_____bar": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathSubtree(\"/\") -> \"http://1.1.1.0:8181\"", - "kubeew_foo__qux__0__www1_example_org_____": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && Method(\"OPTIONS\") && PathSubtree(\"/\") -> ", - }, - }, { - msg: "ingress with 1 host definitions and 1 additional custom route with path predicate, changed pathmode to PathSubtree", - endpoints: testEndpoints("foo", "bar", "1.1.1", 1, map[string]int{"baz": 8181}), - services: []*service{ - testService("foo", "bar", "1.2.3.4", map[string]int{"baz": 8181}), - }, - ingresses: []*definitions.IngressItem{testIngress("foo", "qux", "", "", "", "", - `Path("/foo") -> `, - "path-prefix", "", definitions.BackendPort{}, 1.0, - testRule("www1.example.org", testPathRule("/", "bar", definitions.BackendPort{Value: "baz"})), - )}, - expectedRoutes: map[string]string{ - "kube_foo__qux__www1_example_org_____bar": "Host(/^www1[.]example[.]org$/) && PathSubtree(\"/\") -> \"http://1.1.1.0:8181\"", - "kubeew_foo__qux__www1_example_org_____bar": "Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathSubtree(\"/\") -> \"http://1.1.1.0:8181\"", - }, - }} { - t.Run(ti.msg, func(t *testing.T) { - api := newTestAPIWithEndpoints(t, &serviceList{Items: ti.services}, &definitions.IngressList{Items: ti.ingresses}, &endpointList{ - Items: ti.endpoints, - }) - defer api.Close() - dc, err := New(Options{ - KubernetesURL: api.server.URL, - KubernetesEnableEastWest: true, - }) - if err != nil { - t.Error(err) - } - - defer dc.Close() - - r, err := dc.LoadAll() - if err != nil { - t.Error(err) - return - } - - checkPrettyRoutes(t, r, ti.expectedRoutes) - }) - } -} - func checkPrettyRoutes(t *testing.T, r []*eskip.Route, expected map[string]string) { if len(r) != len(expected) { curIDs := make([]string, len(r)) @@ -3474,8 +3227,7 @@ func TestCreateEastWestRoute(t *testing.T) { expectedID: "kubeew_foo__qux__www3_example_org___a_path__bar", }} { t.Run(ti.msg, func(t *testing.T) { - ewrs := createEastWestRoutesIng(rxDots("."+defaultEastWestDomain), "foo", "qux", []*eskip.Route{ti.route}) - ewr := ewrs[0] + ewr := createEastWestRouteIng(rxDots("."+defaultEastWestDomain), "foo", "qux", ti.route) if ewr.Id != ti.expectedID { t.Errorf("Failed to create east west route ID, %s, but expected %s", ewr.Id, ti.expectedID) } @@ -3549,8 +3301,7 @@ func TestCreateEastWestRouteOverwriteDomain(t *testing.T) { } ing := kube.ingress - ewrs := createEastWestRoutesIng(ing.eastWestDomainRegexpPostfix, ti.name, ti.namespace, []*eskip.Route{ti.route}) - ewr := ewrs[0] + ewr := createEastWestRouteIng(ing.eastWestDomainRegexpPostfix, ti.name, ti.namespace, ti.route) if ewr.Id != ti.expectedID { t.Errorf("Failed to create east west route ID, %s, but expected %s", ewr.Id, ti.expectedID) } diff --git a/dataclients/kubernetes/kubernetestest/fixtures.go b/dataclients/kubernetes/kubernetestest/fixtures.go index e83b534a46..a9951d8e77 100644 --- a/dataclients/kubernetes/kubernetestest/fixtures.go +++ b/dataclients/kubernetes/kubernetestest/fixtures.go @@ -217,6 +217,12 @@ func testFixture(t *testing.T, f fixtureSet) { } if !eskip.EqLists(routes, expectedRoutes) { + sort.SliceStable(routes, func(i, j int) bool { + return routes[i].Id < routes[j].Id + }) + sort.SliceStable(expectedRoutes, func(i, j int) bool { + return expectedRoutes[i].Id < expectedRoutes[j].Id + }) t.Error("Failed to convert the resources to the right routes.") t.Logf("routes: %d, expected: %d", len(routes), len(expectedRoutes)) t.Logf("got:\n%s", eskip.String(eskip.CanonicalList(routes)...)) diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-1customroute-changedpathmodepathsubtree.eskip b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-1customroute-changedpathmodepathsubtree.eskip new file mode 100644 index 0000000000..6b1c7b731f --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-1customroute-changedpathmodepathsubtree.eskip @@ -0,0 +1,13 @@ +kube_foo__qux__0__www_example_org_____: + Host("^www[.]example[.]org$") && PathSubtree("/") && Method("OPTIONS") -> ; +kube_foo__qux__www_example_org_____qux: + Host("^www[.]example[.]org$") && PathSubtree("/") + -> ; +kubeew_foo__qux__0__www_example_org_____: + Host("^qux[.]foo[.]skipper[.]cluster[.]local$") && + Method("OPTIONS") && PathSubtree("/") + -> ; +kubeew_foo__qux__www_example_org_____qux: + Host("^qux[.]foo[.]skipper[.]cluster[.]local$") && PathSubtree("/") + -> ; + diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-1customroute-changedpathmodepathsubtree.kube b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-1customroute-changedpathmodepathsubtree.kube new file mode 100644 index 0000000000..f132b7626b --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-1customroute-changedpathmodepathsubtree.kube @@ -0,0 +1 @@ +eastWest: true diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-1customroute-changedpathmodepathsubtree.yaml b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-1customroute-changedpathmodepathsubtree.yaml new file mode 100644 index 0000000000..8b54bbb5f5 --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-1customroute-changedpathmodepathsubtree.yaml @@ -0,0 +1,49 @@ +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: qux + namespace: foo + annotations: + zalando.org/skipper-routes: Method("OPTIONS") -> + zalando.org/skipper-ingress-path-mode: path-prefix +spec: + rules: + - host: www.example.org + http: + paths: + - path: "/" + backend: + serviceName: qux + servicePort: baz +--- +apiVersion: v1 +kind: Service +metadata: + name: qux + namespace: foo +spec: + clusterIP: 10.3.190.97 + ports: + - name: baz + port: 8181 + protocol: TCP + targetPort: 8080 + selector: + application: myapp + type: ClusterIP +--- +apiVersion: v1 +kind: Endpoints +metadata: + labels: + application: myapp + name: qux + namespace: foo +subsets: +- addresses: + - ip: 10.2.9.103 + - ip: 10.2.9.104 + ports: + - name: bar + port: 8080 + protocol: TCP diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-1customroute.eskip b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-1customroute.eskip new file mode 100644 index 0000000000..cb04652fcf --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-1customroute.eskip @@ -0,0 +1,12 @@ +kube_foo__qux__0__www_example_org_____: + Host("^www[.]example[.]org$") && PathRegexp("^/") && Method("OPTIONS") -> ; +kube_foo__qux__www_example_org_____qux: + Host("^www[.]example[.]org$") && PathRegexp("^/") + -> ; +kubeew_foo__qux__0__www_example_org_____: + Host("^qux[.]foo[.]skipper[.]cluster[.]local$") && Method("OPTIONS") && PathRegexp("^/") + -> ; +kubeew_foo__qux__www_example_org_____qux: + Host("^qux[.]foo[.]skipper[.]cluster[.]local$") && PathRegexp("^/") + -> ; + diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-1customroute.kube b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-1customroute.kube new file mode 100644 index 0000000000..f132b7626b --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-1customroute.kube @@ -0,0 +1 @@ +eastWest: true diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-1customroute.yaml b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-1customroute.yaml new file mode 100644 index 0000000000..868a8f34de --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-1customroute.yaml @@ -0,0 +1,48 @@ +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: qux + namespace: foo + annotations: + zalando.org/skipper-routes: Method("OPTIONS") -> +spec: + rules: + - host: www.example.org + http: + paths: + - path: "/" + backend: + serviceName: qux + servicePort: baz +--- +apiVersion: v1 +kind: Service +metadata: + name: qux + namespace: foo +spec: + clusterIP: 10.3.190.97 + ports: + - name: baz + port: 8181 + protocol: TCP + targetPort: 8080 + selector: + application: myapp + type: ClusterIP +--- +apiVersion: v1 +kind: Endpoints +metadata: + labels: + application: myapp + name: qux + namespace: foo +subsets: +- addresses: + - ip: 10.2.9.103 + - ip: 10.2.9.104 + ports: + - name: bar + port: 8080 + protocol: TCP diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-1filter.eskip b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-1filter.eskip new file mode 100644 index 0000000000..ba5f466626 --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-1filter.eskip @@ -0,0 +1,8 @@ +kube_foo__qux__www_example_org_____qux: + Host("^www[.]example[.]org$") && PathRegexp("^/") + -> consecutiveBreaker(15) + -> ; +kubeew_foo__qux__www_example_org_____qux: + Host("^qux[.]foo[.]skipper[.]cluster[.]local$") && PathRegexp("^/") + -> consecutiveBreaker(15) + -> ; diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-1filter.kube b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-1filter.kube new file mode 100644 index 0000000000..f132b7626b --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-1filter.kube @@ -0,0 +1 @@ +eastWest: true diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-1filter.yaml b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-1filter.yaml new file mode 100644 index 0000000000..5d3cf43959 --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-1filter.yaml @@ -0,0 +1,48 @@ +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: qux + namespace: foo + annotations: + zalando.org/skipper-filter: consecutiveBreaker(15) +spec: + rules: + - host: www.example.org + http: + paths: + - path: "/" + backend: + serviceName: qux + servicePort: baz +--- +apiVersion: v1 +kind: Service +metadata: + name: qux + namespace: foo +spec: + clusterIP: 10.3.190.97 + ports: + - name: baz + port: 8181 + protocol: TCP + targetPort: 8080 + selector: + application: myapp + type: ClusterIP +--- +apiVersion: v1 +kind: Endpoints +metadata: + labels: + application: myapp + name: qux + namespace: foo +subsets: +- addresses: + - ip: 10.2.9.103 + - ip: 10.2.9.104 + ports: + - name: bar + port: 8080 + protocol: TCP diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-2filters.eskip b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-2filters.eskip new file mode 100644 index 0000000000..8085ad7193 --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-2filters.eskip @@ -0,0 +1,10 @@ +kube_foo__qux__www_example_org_____qux: + Host("^www[.]example[.]org$") && PathRegexp("^/") + -> consecutiveBreaker(15) + -> preserveHost("true") + -> ; +kubeew_foo__qux__www_example_org_____qux: + Host("^qux[.]foo[.]skipper[.]cluster[.]local$") && PathRegexp("^/") + -> consecutiveBreaker(15) + -> preserveHost("true") + -> ; diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-2filters.kube b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-2filters.kube new file mode 100644 index 0000000000..f132b7626b --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-2filters.kube @@ -0,0 +1 @@ +eastWest: true diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-2filters.yaml b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-2filters.yaml new file mode 100644 index 0000000000..d07f79c037 --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-2filters.yaml @@ -0,0 +1,48 @@ +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: qux + namespace: foo + annotations: + zalando.org/skipper-filter: consecutiveBreaker(15) -> preserveHost("true") +spec: + rules: + - host: www.example.org + http: + paths: + - path: "/" + backend: + serviceName: qux + servicePort: baz +--- +apiVersion: v1 +kind: Service +metadata: + name: qux + namespace: foo +spec: + clusterIP: 10.3.190.97 + ports: + - name: baz + port: 8181 + protocol: TCP + targetPort: 8080 + selector: + application: myapp + type: ClusterIP +--- +apiVersion: v1 +kind: Endpoints +metadata: + labels: + application: myapp + name: qux + namespace: foo +subsets: +- addresses: + - ip: 10.2.9.103 + - ip: 10.2.9.104 + ports: + - name: bar + port: 8080 + protocol: TCP diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-2predicates.eskip b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-2predicates.eskip new file mode 100644 index 0000000000..a1efd03afe --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-2predicates.eskip @@ -0,0 +1,6 @@ +kube_foo__qux__www_example_org_____qux: + Host("^www[.]example[.]org$") && PathRegexp("^/") && QueryParam("version", "^alpha$") && Header("Accept", "application/json") + -> ; +kubeew_foo__qux__www_example_org_____qux: + Host("^qux[.]foo[.]skipper[.]cluster[.]local$") && PathRegexp("^/") && QueryParam("version", "^alpha$") && Header("Accept", "application/json") + -> ; diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-2predicates.kube b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-2predicates.kube new file mode 100644 index 0000000000..f132b7626b --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-2predicates.kube @@ -0,0 +1 @@ +eastWest: true diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-2predicates.yaml b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-2predicates.yaml new file mode 100644 index 0000000000..aeb6b881c4 --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-2predicates.yaml @@ -0,0 +1,48 @@ +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: qux + namespace: foo + annotations: + zalando.org/skipper-predicate: QueryParam("version", "^alpha$") && Header("Accept", "application/json") +spec: + rules: + - host: www.example.org + http: + paths: + - path: "/" + backend: + serviceName: qux + servicePort: baz +--- +apiVersion: v1 +kind: Service +metadata: + name: qux + namespace: foo +spec: + clusterIP: 10.3.190.97 + ports: + - name: baz + port: 8181 + protocol: TCP + targetPort: 8080 + selector: + application: myapp + type: ClusterIP +--- +apiVersion: v1 +kind: Endpoints +metadata: + labels: + application: myapp + name: qux + namespace: foo +subsets: +- addresses: + - ip: 10.2.9.103 + - ip: 10.2.9.104 + ports: + - name: bar + port: 8080 + protocol: TCP diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-predicate.eskip b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-predicate.eskip new file mode 100644 index 0000000000..8af18ec9f3 --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-predicate.eskip @@ -0,0 +1,6 @@ +kube_foo__qux__www_example_org_____qux: + Host("^www[.]example[.]org$") && PathRegexp("^/") && QueryParam("version", "^alpha$") + -> ; +kubeew_foo__qux__www_example_org_____qux: + Host("^qux[.]foo[.]skipper[.]cluster[.]local$") && PathRegexp("^/") && QueryParam("version", "^alpha$") + -> ; diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-predicate.kube b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-predicate.kube new file mode 100644 index 0000000000..f132b7626b --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-predicate.kube @@ -0,0 +1 @@ +eastWest: true diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-predicate.yaml b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-predicate.yaml new file mode 100644 index 0000000000..bde51736c5 --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule-predicate.yaml @@ -0,0 +1,48 @@ +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: qux + namespace: foo + annotations: + zalando.org/skipper-predicate: QueryParam("version", "^alpha$") +spec: + rules: + - host: www.example.org + http: + paths: + - path: "/" + backend: + serviceName: qux + servicePort: baz +--- +apiVersion: v1 +kind: Service +metadata: + name: qux + namespace: foo +spec: + clusterIP: 10.3.190.97 + ports: + - name: baz + port: 8181 + protocol: TCP + targetPort: 8080 + selector: + application: myapp + type: ClusterIP +--- +apiVersion: v1 +kind: Endpoints +metadata: + labels: + application: myapp + name: qux + namespace: foo +subsets: +- addresses: + - ip: 10.2.9.103 + - ip: 10.2.9.104 + ports: + - name: bar + port: 8080 + protocol: TCP diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule.eskip b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule.eskip new file mode 100644 index 0000000000..a44be6a3a5 --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule.eskip @@ -0,0 +1,6 @@ +kube_foo__qux__www_example_org_____qux: + Host("^www[.]example[.]org$") && PathRegexp("^/") + -> ; +kubeew_foo__qux__www_example_org_____qux: + Host("^qux[.]foo[.]skipper[.]cluster[.]local$") && PathRegexp("^/") + -> ; diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule.kube b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule.kube new file mode 100644 index 0000000000..f132b7626b --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule.kube @@ -0,0 +1 @@ +eastWest: true diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule.yaml b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule.yaml new file mode 100644 index 0000000000..c8f0a16b90 --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-1host-1prule.yaml @@ -0,0 +1,46 @@ +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: qux + namespace: foo +spec: + rules: + - host: www.example.org + http: + paths: + - path: "/" + backend: + serviceName: qux + servicePort: baz +--- +apiVersion: v1 +kind: Service +metadata: + name: qux + namespace: foo +spec: + clusterIP: 10.3.190.97 + ports: + - name: baz + port: 8181 + protocol: TCP + targetPort: 8080 + selector: + application: myapp + type: ClusterIP +--- +apiVersion: v1 +kind: Endpoints +metadata: + labels: + application: myapp + name: qux + namespace: foo +subsets: +- addresses: + - ip: 10.2.9.103 + - ip: 10.2.9.104 + ports: + - name: bar + port: 8080 + protocol: TCP diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-2host-2prule-1customroute.eskip b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-2host-2prule-1customroute.eskip new file mode 100644 index 0000000000..69f549eddf --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-2host-2prule-1customroute.eskip @@ -0,0 +1,31 @@ +kube_foo__qux__0__www1_example_org_a_path____: + Host("^www1[.]example[.]org$") && PathRegexp("^(/a/path)") && Method("OPTIONS") -> ; +kube_foo__qux__www1_example_org___a_path__qux: + Host("^www1[.]example[.]org$") && PathRegexp("^(/a/path)") + -> ; +kube___catchall__www1_example_org____: + Host("^www1[.]example[.]org$") + -> ; +kubeew_foo__qux__0__www1_example_org_a_path____: + Host("^qux[.]foo[.]skipper[.]cluster[.]local$") && Method("OPTIONS") && PathRegexp("^(/a/path)") + -> ; +kube___catchall__qux_foo____skipper___cluster___local____: + Host("^qux[.]foo[.]skipper[.]cluster[.]local$") + -> ; +kubeew_foo__qux__www1_example_org___a_path__qux: + Host("^qux[.]foo[.]skipper[.]cluster[.]local$") && PathRegexp("^(/a/path)") + -> ; +kube_foo__qux__0__www2_example_org_another_path____: + Host("^www2[.]example[.]org$") && PathRegexp("^(/another/path)") && Method("OPTIONS") -> ; +kube_foo__qux__www2_example_org___another_path__qux: + Host("^www2[.]example[.]org$") && PathRegexp("^(/another/path)") + -> ; +kubeew_foo__qux__0__www2_example_org_another_path____: + Host("^qux[.]foo[.]skipper[.]cluster[.]local$") && Method("OPTIONS") && PathRegexp("^(/another/path)") + -> ; +kubeew_foo__qux__www2_example_org___another_path__qux: + Host("^qux[.]foo[.]skipper[.]cluster[.]local$") && PathRegexp("^(/another/path)") + -> ; +kube___catchall__www2_example_org____: + Host("^www2[.]example[.]org$") + -> ; diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-2host-2prule-1customroute.kube b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-2host-2prule-1customroute.kube new file mode 100644 index 0000000000..f132b7626b --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-2host-2prule-1customroute.kube @@ -0,0 +1 @@ +eastWest: true diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-2host-2prule-1customroute.yaml b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-2host-2prule-1customroute.yaml new file mode 100644 index 0000000000..4bf681c018 --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-2host-2prule-1customroute.yaml @@ -0,0 +1,55 @@ +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: qux + namespace: foo + annotations: + zalando.org/skipper-routes: Method("OPTIONS") -> +spec: + rules: + - host: www1.example.org + http: + paths: + - path: "/a/path" + backend: + serviceName: qux + servicePort: baz + - host: www2.example.org + http: + paths: + - path: "/another/path" + backend: + serviceName: qux + servicePort: baz +--- +apiVersion: v1 +kind: Service +metadata: + name: qux + namespace: foo +spec: + clusterIP: 10.3.190.97 + ports: + - name: baz + port: 8181 + protocol: TCP + targetPort: 8080 + selector: + application: myapp + type: ClusterIP +--- +apiVersion: v1 +kind: Endpoints +metadata: + labels: + application: myapp + name: qux + namespace: foo +subsets: +- addresses: + - ip: 10.2.9.103 + - ip: 10.2.9.104 + ports: + - name: bar + port: 8080 + protocol: TCP diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-2host-sameprule-1customroute.eskip b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-2host-sameprule-1customroute.eskip new file mode 100644 index 0000000000..c442e67335 --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-2host-sameprule-1customroute.eskip @@ -0,0 +1,23 @@ +kube_foo__qux__0__www1_example_org_____: + Host("^www1[.]example[.]org$") && PathRegexp("^/") && Method("OPTIONS") -> ; +kube_foo__qux__www1_example_org_____qux: + Host("^www1[.]example[.]org$") && PathRegexp("^/") + -> ; +kube_foo__qux__0__www2_example_org_____: + Host("^www2[.]example[.]org$") && PathRegexp("^/") && Method("OPTIONS") -> ; +kube_foo__qux__www2_example_org_____qux: + Host("^www2[.]example[.]org$") && PathRegexp("^/") + -> ; +kubeew_foo__qux__0__www1_example_org_____: + Host("^qux[.]foo[.]skipper[.]cluster[.]local$") && Method("OPTIONS") && PathRegexp("^/") + -> ; +kubeew_foo__qux__www1_example_org_____qux: + Host("^qux[.]foo[.]skipper[.]cluster[.]local$") && PathRegexp("^/") + -> ; +kubeew_foo__qux__0__www2_example_org_____: + Host("^qux[.]foo[.]skipper[.]cluster[.]local$") && Method("OPTIONS") && PathRegexp("^/") + -> ; +kubeew_foo__qux__www2_example_org_____qux: + Host("^qux[.]foo[.]skipper[.]cluster[.]local$") && PathRegexp("^/") + -> ; + diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-2host-sameprule-1customroute.kube b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-2host-sameprule-1customroute.kube new file mode 100644 index 0000000000..f132b7626b --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-2host-sameprule-1customroute.kube @@ -0,0 +1 @@ +eastWest: true diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-2host-sameprule-1customroute.yaml b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-2host-sameprule-1customroute.yaml new file mode 100644 index 0000000000..88490277d5 --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-2host-sameprule-1customroute.yaml @@ -0,0 +1,55 @@ +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: qux + namespace: foo + annotations: + zalando.org/skipper-routes: Method("OPTIONS") -> +spec: + rules: + - host: www1.example.org + http: + paths: + - path: "/" + backend: + serviceName: qux + servicePort: baz + - host: www2.example.org + http: + paths: + - path: "/" + backend: + serviceName: qux + servicePort: baz +--- +apiVersion: v1 +kind: Service +metadata: + name: qux + namespace: foo +spec: + clusterIP: 10.3.190.97 + ports: + - name: baz + port: 8181 + protocol: TCP + targetPort: 8080 + selector: + application: myapp + type: ClusterIP +--- +apiVersion: v1 +kind: Endpoints +metadata: + labels: + application: myapp + name: qux + namespace: foo +subsets: +- addresses: + - ip: 10.2.9.103 + - ip: 10.2.9.104 + ports: + - name: bar + port: 8080 + protocol: TCP diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-3host-1prule-3customroute.eskip b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-3host-1prule-3customroute.eskip new file mode 100644 index 0000000000..63bd620b95 --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-3host-1prule-3customroute.eskip @@ -0,0 +1,79 @@ +kube_foo__qux__www1_example_org_____qux: + Host(/^www1[.]example[.]org$/) && PathRegexp("^/") + -> ; +kube_foo__qux_a_0__www1_example_org_____: + Host(/^www1[.]example[.]org$/) && PathRegexp("^/") && Method("OPTIONS") + -> ; +kube_foo__qux_b_1__www1_example_org_____: + Host(/^www1[.]example[.]org$/) && PathRegexp("^/") && Cookie("alpha","^enabled$") + -> "http://1.1.2.0:8181"; +kube_foo__qux_c_2__www1_example_org_____: + Path("/a/path/somewhere") && Host(/^www1[.]example[.]org$/) && + PathRegexp("^/") + -> "https://some.other-url.org/a/path/somewhere"; +kube_foo__qux__www2_example_org_____qux: + Host(/^www2[.]example[.]org$/) && PathRegexp("^/") + -> ; +kube_foo__qux_a_0__www2_example_org_____: + Host(/^www2[.]example[.]org$/) && PathRegexp("^/") && Method("OPTIONS") + -> ; +kube_foo__qux_b_1__www2_example_org_____: + Host(/^www2[.]example[.]org$/) && PathRegexp("^/") && Cookie("alpha","^enabled$") + -> "http://1.1.2.0:8181"; +kube_foo__qux_c_2__www2_example_org_____: + Path("/a/path/somewhere") && Host(/^www2[.]example[.]org$/) && + PathRegexp("^/") + -> "https://some.other-url.org/a/path/somewhere"; +kube_foo__qux__www3_example_org___a_path__qux: + Host(/^www3[.]example[.]org$/) && PathRegexp(/^(\/a\/path)/) + -> ; +kube_foo__qux_a_0__www3_example_org_a_path____: + Host(/^www3[.]example[.]org$/) && PathRegexp(/^(\/a\/path)/) && Method("OPTIONS") + -> ; +kube_foo__qux_b_1__www3_example_org_a_path____: + Host(/^www3[.]example[.]org$/) && PathRegexp(/^(\/a\/path)/) && Cookie("alpha","^enabled$") + -> "http://1.1.2.0:8181"; +kube_foo__qux_c_2__www3_example_org_a_path____: + Path("/a/path/somewhere") && Host(/^www3[.]example[.]org$/) && PathRegexp(/^(\/a\/path)/) + -> "https://some.other-url.org/a/path/somewhere"; +kubeew_foo__qux__www1_example_org_____qux: + Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\//) + -> ; +kubeew_foo__qux_a_0__www1_example_org_____: + Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\//) && Method("OPTIONS") + -> ; +kubeew_foo__qux_b_1__www1_example_org_____: + Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\//) && Cookie("alpha","^enabled$") + -> "http://1.1.2.0:8181"; +kubeew_foo__qux__www2_example_org_____qux: + Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\//) + -> ; +kubeew_foo__qux_a_0__www2_example_org_____: + Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\//) && Method("OPTIONS") + -> ; +kubeew_foo__qux_b_1__www2_example_org_____: + Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\//) && Cookie("alpha","^enabled$") + -> "http://1.1.2.0:8181"; +kubeew_foo__qux__www3_example_org___a_path__qux: + Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && + PathRegexp("^(/a/path)") + -> ; +kubeew_foo__qux_a_0__www3_example_org_a_path____: + Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^(\/a\/path)/) && Method("OPTIONS") + -> ; +kubeew_foo__qux_b_1__www3_example_org_a_path____: + Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^(\/a\/path)/) && Cookie("alpha","^enabled$") + -> "http://1.1.2.0:8181"; +kubeew_foo__qux_c_2__www3_example_org_a_path____: + Path("/a/path/somewhere") && Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^(\/a\/path)/) + -> "https://some.other-url.org/a/path/somewhere"; +kubeew_foo__qux_c_2__www1_example_org_____: + Path("/a/path/somewhere") && Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\//) + -> "https://some.other-url.org/a/path/somewhere"; +kubeew_foo__qux_c_2__www2_example_org_____: + Path("/a/path/somewhere") && Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\//) + -> "https://some.other-url.org/a/path/somewhere"; +kube___catchall__www3_example_org____: + Host("^www3[.]example[.]org$") + -> ; + diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-3host-1prule-3customroute.kube b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-3host-1prule-3customroute.kube new file mode 100644 index 0000000000..f132b7626b --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-3host-1prule-3customroute.kube @@ -0,0 +1 @@ +eastWest: true diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-3host-1prule-3customroute.yaml b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-3host-1prule-3customroute.yaml new file mode 100644 index 0000000000..d1bf99e8a1 --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-3host-1prule-3customroute.yaml @@ -0,0 +1,65 @@ +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: qux + namespace: foo + annotations: + zalando.org/skipper-routes: | + a: Method("OPTIONS") -> ; + b: Cookie("alpha", /^enabled$/) -> "http://1.1.2.0:8181"; + c: Path("/a/path/somewhere") -> "https://some.other-url.org/a/path/somewhere"; +spec: + rules: + - host: www1.example.org + http: + paths: + - path: "/" + backend: + serviceName: qux + servicePort: baz + - host: www2.example.org + http: + paths: + - path: "/" + backend: + serviceName: qux + servicePort: baz + - host: www3.example.org + http: + paths: + - path: "/a/path" + backend: + serviceName: qux + servicePort: baz +--- +apiVersion: v1 +kind: Service +metadata: + name: qux + namespace: foo +spec: + clusterIP: 10.3.190.97 + ports: + - name: baz + port: 8181 + protocol: TCP + targetPort: 8080 + selector: + application: myapp + type: ClusterIP +--- +apiVersion: v1 +kind: Endpoints +metadata: + labels: + application: myapp + name: qux + namespace: foo +subsets: +- addresses: + - ip: 10.2.9.103 + - ip: 10.2.9.104 + ports: + - name: bar + port: 8080 + protocol: TCP diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-3host-1withoutprule-3customroute.eskip b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-3host-1withoutprule-3customroute.eskip new file mode 100644 index 0000000000..d6e8dccd79 --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-3host-1withoutprule-3customroute.eskip @@ -0,0 +1,78 @@ +kube_foo__qux__www1_example_org____qux: + Host(/^www1[.]example[.]org$/) + -> ; +kube_foo__qux_a_0__www1_example_org____: + Host(/^www1[.]example[.]org$/) && Method("OPTIONS") + -> ; +kube_foo__qux_b_1__www1_example_org____: + Host(/^www1[.]example[.]org$/) && Cookie("alpha","^enabled$") + -> "http://1.1.2.0:8181"; +kube_foo__qux_c_2__www1_example_org____: + Path("/a/path/somewhere") && Host(/^www1[.]example[.]org$/) + -> "https://some.other-url.org/a/path/somewhere"; +kube_foo__qux__www2_example_org_____qux: + Host(/^www2[.]example[.]org$/) && PathRegexp("^/") + -> ; +kube_foo__qux_a_0__www2_example_org_____: + Host(/^www2[.]example[.]org$/) && PathRegexp("^/") && Method("OPTIONS") + -> ; +kube_foo__qux_b_1__www2_example_org_____: + Host(/^www2[.]example[.]org$/) && PathRegexp("^/") && Cookie("alpha","^enabled$") + -> "http://1.1.2.0:8181"; +kube_foo__qux_c_2__www2_example_org_____: + Path("/a/path/somewhere") && Host(/^www2[.]example[.]org$/) && + PathRegexp("^/") + -> "https://some.other-url.org/a/path/somewhere"; +kube_foo__qux__www3_example_org___a_path__qux: + Host(/^www3[.]example[.]org$/) && PathRegexp(/^(\/a\/path)/) + -> ; +kube_foo__qux_a_0__www3_example_org_a_path____: + Host(/^www3[.]example[.]org$/) && PathRegexp(/^(\/a\/path)/) && Method("OPTIONS") + -> ; +kube_foo__qux_b_1__www3_example_org_a_path____: + Host(/^www3[.]example[.]org$/) && PathRegexp(/^(\/a\/path)/) && Cookie("alpha","^enabled$") + -> "http://1.1.2.0:8181"; +kube_foo__qux_c_2__www3_example_org_a_path____: + Path("/a/path/somewhere") && Host(/^www3[.]example[.]org$/) && PathRegexp(/^(\/a\/path)/) + -> "https://some.other-url.org/a/path/somewhere"; +kubeew_foo__qux__www1_example_org____qux: + Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) + -> ; +kubeew_foo__qux_a_0__www1_example_org____: + Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && Method("OPTIONS") + -> ; +kubeew_foo__qux_b_1__www1_example_org____: + Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && Cookie("alpha","^enabled$") + -> "http://1.1.2.0:8181"; +kubeew_foo__qux__www2_example_org_____qux: + Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\//) + -> ; +kubeew_foo__qux_a_0__www2_example_org_____: + Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\//) && Method("OPTIONS") + -> ; +kubeew_foo__qux_b_1__www2_example_org_____: + Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\//) && Cookie("alpha","^enabled$") + -> "http://1.1.2.0:8181"; +kubeew_foo__qux__www3_example_org___a_path__qux: + Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && + PathRegexp("^(/a/path)") + -> ; +kubeew_foo__qux_a_0__www3_example_org_a_path____: + Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^(\/a\/path)/) && Method("OPTIONS") + -> ; +kubeew_foo__qux_b_1__www3_example_org_a_path____: + Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^(\/a\/path)/) && Cookie("alpha","^enabled$") + -> "http://1.1.2.0:8181"; +kubeew_foo__qux_c_2__www3_example_org_a_path____: + Path("/a/path/somewhere") && Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^(\/a\/path)/) + -> "https://some.other-url.org/a/path/somewhere"; +kubeew_foo__qux_c_2__www1_example_org____: + Path("/a/path/somewhere") && Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) + -> "https://some.other-url.org/a/path/somewhere"; +kubeew_foo__qux_c_2__www2_example_org_____: + Path("/a/path/somewhere") && Host(/^qux[.]foo[.]skipper[.]cluster[.]local$/) && PathRegexp(/^\//) + -> "https://some.other-url.org/a/path/somewhere"; +kube___catchall__www3_example_org____: + Host("^www3[.]example[.]org$") + -> ; + diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-3host-1withoutprule-3customroute.kube b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-3host-1withoutprule-3customroute.kube new file mode 100644 index 0000000000..f132b7626b --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-3host-1withoutprule-3customroute.kube @@ -0,0 +1 @@ +eastWest: true diff --git a/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-3host-1withoutprule-3customroute.yaml b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-3host-1withoutprule-3customroute.yaml new file mode 100644 index 0000000000..bd9bef5097 --- /dev/null +++ b/dataclients/kubernetes/testdata/ingress/eastwest/ing-with-3host-1withoutprule-3customroute.yaml @@ -0,0 +1,64 @@ +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: qux + namespace: foo + annotations: + zalando.org/skipper-routes: | + a: Method("OPTIONS") -> ; + b: Cookie("alpha", /^enabled$/) -> "http://1.1.2.0:8181"; + c: Path("/a/path/somewhere") -> "https://some.other-url.org/a/path/somewhere"; +spec: + rules: + - host: www1.example.org + http: + paths: + - backend: + serviceName: qux + servicePort: baz + - host: www2.example.org + http: + paths: + - path: "/" + backend: + serviceName: qux + servicePort: baz + - host: www3.example.org + http: + paths: + - path: "/a/path" + backend: + serviceName: qux + servicePort: baz +--- +apiVersion: v1 +kind: Service +metadata: + name: qux + namespace: foo +spec: + clusterIP: 10.3.190.97 + ports: + - name: baz + port: 8181 + protocol: TCP + targetPort: 8080 + selector: + application: myapp + type: ClusterIP +--- +apiVersion: v1 +kind: Endpoints +metadata: + labels: + application: myapp + name: qux + namespace: foo +subsets: +- addresses: + - ip: 10.2.9.103 + - ip: 10.2.9.104 + ports: + - name: bar + port: 8080 + protocol: TCP