Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(*) TrafficRoute add Split #1149

Merged
merged 20 commits into from
Nov 16, 2020

Conversation

nickolaev
Copy link
Contributor

Summary

Adding default TrafficRoute, Move the Configuration destination list to a Split field and make it support wildcard services

Documentation

@nickolaev nickolaev force-pushed the feat/route_support_destination_wildcard branch from 974379d to 09b3ac6 Compare November 12, 2020 16:46
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
@nickolaev nickolaev force-pushed the feat/route_support_destination_wildcard branch from 09b3ac6 to e7ef54d Compare November 12, 2020 20:05
Nikolay Nikolaev added 6 commits November 12, 2020 23:22
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
…destination_wildcard

# Conflicts:
#	app/kumactl/pkg/install/k8s/control-plane/helmtemplates_vfsdata.go

Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
@nickolaev nickolaev force-pushed the feat/route_support_destination_wildcard branch from 328fed6 to 8857318 Compare November 15, 2020 22:12
Nikolay Nikolaev added 2 commits November 16, 2020 15:21
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
@nickolaev nickolaev marked this pull request as ready for review November 16, 2020 13:24
@nickolaev nickolaev requested a review from a team as a code owner November 16, 2020 13:24
// This will be dropped when TrafficRoute will be converted to Global Scope on K8S instead of Namespace Scope
// TrafficRoute needs to contain mesh name inside it. Otherwise if the name is the same (ex. "allow-all") creating new mesh would fail because there is already resource of name "allow-all" which is unique key on K8S
func defaultTrafficRouteName(meshName string) string {
return fmt.Sprintf("allow-all-%s.default", meshName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the .default is not required anymore

service, ok := destination.Destination[mesh_proto.ServiceTag]
if !ok {
// ignore destinations without a `service` tag
// TODO(yskopets): consider adding a metric for this
continue
}
destinations[service] = destinations[service].Add(mesh_proto.MatchTags(destination.Destination))
if service == mesh_proto.MatchAllTag {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be handled already. routes core_xds.RouteMap should not have * matches

Split: split,
},
},
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's the algorithm that we agreed on the call. The wildcard can be placed on many tags.

The idea was

  1. Take traffic route
  2. Remove all tag pairs with wildcard
  3. Add all tags from outbound to traffic route if they do not already exist in the list

Examples
1)
Traffic Route

conf:
  split:
  - weight: 100
    tags:
      kuma.io/service: '*'
  • Outbound
outbound:
- port: 1234
  tags:
    kuma.io/service: backend

=

conf:
  split:
  - weight: 100
    tags:
      kuma.io/service: 'backend'

Traffic Route

conf:
  split:
  - weight: 100
    tags:
      kuma.io/service: '*'
      kuma.io/zone: aws
  • Outbound
outbound:
- port: 1234
  tags:
    kuma.io/service: backend

=

conf:
  split:
  - weight: 100
    tags:
      kuma.io/service: 'backend'
      kuma.io/zone: aws

Traffic Route

conf:
  split:
  - weight: 100
    tags:
      kuma.io/service: '*'
      kuma.io/zone: '*'
  • Outbound
outbound:
- port: 1234
  tags:
    kuma.io/service: backend

=

conf:
  split:
  - weight: 100
    tags:
      kuma.io/service: 'backend'

Traffic Route

conf:
  split:
  - weight: 100
    tags:
      kuma.io/service: '*'
      kuma.io/zone: '*'
  • Outbound
outbound:
- port: 1234
  tags:
    kuma.io/service: backend
    kuma.io/zone: aws

=

conf:
  split:
  - weight: 100
    tags:
      kuma.io/service: 'backend'
      kuma.io/zone: aws

Traffic Route

conf:
  split:
  - weight: 100
    tags:
      kuma.io/service: '*'
  • Outbound
outbound:
- port: 1234
  tags:
    kuma.io/service: backend
    version: 1

=

conf:
  split:
  - weight: 100
    tags:
      kuma.io/service: 'backend'
      version: 1

Traffic Route

conf:
  split:
  - weight: 100
    tags:
      kuma.io/service: '*'
      version: 1
  • Outbound
outbound:
- port: 1234
  tags:
    kuma.io/service: backend
    version: 2

=

conf:
  split:
  - weight: 100
    tags:
      kuma.io/service: 'backend'
      version: 1

(Traffic Route should take precedence)

Nikolay Nikolaev added 5 commits November 16, 2020 16:26
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
…destination_wildcard

# Conflicts:
#	app/kumactl/pkg/install/k8s/control-plane/helmtemplates_vfsdata.go

Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
)

// Default traffic route needs to be stored with default suffix so on K8S it will be stored in the default namespace
// This will be dropped when TrafficRoute will be converted to Global Scope on K8S instead of Namespace Scope
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete those two lines of comments, we don't have a suffix anymore

@@ -224,6 +226,10 @@ func (_ OutboundProxyGenerator) determineSubsets(proxy *model.Proxy, outbound *k
// 0 assumes no traffic is passed there. Envoy doesn't support 0 weight, so instead of passing it to Envoy we just skip such cluster.
continue
}
if service == kuma_mesh.MatchAllTag {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should not happen, because we replace this on the upper level, right?

// This will be dropped when TrafficRoute will be converted to Global Scope on K8S instead of Namespace Scope
// TrafficRoute needs to contain mesh name inside it. Otherwise if the name is the same (ex. "allow-all") creating new mesh would fail because there is already resource of name "allow-all" which is unique key on K8S
func defaultTrafficRouteName(meshName string) string {
return fmt.Sprintf("allow-all-%s", meshName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think the name could be better. allow-all made sense in the context of traffic permissions. Here should be something like route-all-%? default-router-%s, router-%s?

}},
},
route := policy.(*mesh_core.TrafficRouteResource)
if route.Spec.GetConf().HasWildcard() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should rely on wildcard here. How about this case

Traffic Route

conf:
  split:
  - weight: 100
    tags:
      kuma.io/service: 'backend'
  • Outbound
outbound:
- port: 1234
  tags:
    kuma.io/service: backend
    version: 2

=

conf:
  split:
  - weight: 100
    tags:
      kuma.io/service: 'backend'
      version: 2

Nikolay Nikolaev added 4 commits November 16, 2020 18:11
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
…destination_wildcard

# Conflicts:
#	pkg/core/managers/apis/mesh/mesh_manager_test.go

Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
Copy link
Contributor

@jakubdyszkiewicz jakubdyszkiewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nit about HasWildcard, remove it, then it's 👍

@@ -0,0 +1,10 @@
package v1alpha1

func (c *TrafficRoute_Conf) HasWildcard() bool {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not needed anymore

Signed-off-by: Nikolay Nikolaev <nikolay.nikolaev@konghq.com>
@nickolaev nickolaev merged commit 8684b68 into master Nov 16, 2020
@nickolaev nickolaev deleted the feat/route_support_destination_wildcard branch November 16, 2020 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants