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

feat(kuma-cp) virtual host modifications #909

Merged
merged 6 commits into from
Jul 27, 2020

Conversation

jakubdyszkiewicz
Copy link
Contributor

Summary

Virtual Host modification

I think VirtualHost is enough for RDS modifications.

We can skip RouteConfiguration because VirtualHost offers all headers to add.
Most of the operations on Routes are possible from VirtualHost (you can remove VirtualHost and add another one with a different list of routes, most settings on routes like retries are available on VirtualHost)

Documentation

kumahq/kuma-website#238

@jakubdyszkiewicz jakubdyszkiewicz requested a review from a team as a code owner July 16, 2020 13:12
Base automatically changed from feat/proxy-template-modifications to master July 17, 2020 13:07
@jakubdyszkiewicz jakubdyszkiewicz force-pushed the feat/proxy-template-virtualhost branch from 7a63101 to e830db9 Compare July 17, 2020 13:15
Copy link
Contributor

@nickolaev nickolaev left a comment

Choose a reason for hiding this comment

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

Looks good.

default:
return errors.Errorf("invalid modification type %q", modification.Type)
return errors.Errorf("invalid modification type %T", modification.Type)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@lobkovilya
Copy link
Contributor

Probably even makes sense to skip VirtualHost as well and give an ability to modify only Routes of CommonVirtualHost created by Kuma. Because if you add new VirtualHost then traffic won't go through CommonVirtualHost and functionality will be broken.

@jakubdyszkiewicz
Copy link
Contributor Author

Probably even makes sense to skip VirtualHost as well and give an ability to modify only Routes of CommonVirtualHost created by Kuma. Because if you add new VirtualHost then traffic won't go through CommonVirtualHost and functionality will be broken.

But you can remove default virtual hosts and add new ones.

@lobkovilya
Copy link
Contributor

Yes, but in this case, you have to manually write all stuff that Kuma does automatically here:

func (c RouteConfigurer) routeAction() *envoy_route.RouteAction {
	routeAction := envoy_route.RouteAction{}
	if len(c.subsets) == 1 {
		routeAction.ClusterSpecifier = &envoy_route.RouteAction_Cluster{
			Cluster: c.subsets[0].ClusterName,
		}
		routeAction.MetadataMatch = envoy_common.LbMetadata(c.subsets[0].Tags)
	} else {
		var weightedClusters []*envoy_route.WeightedCluster_ClusterWeight
		var totalWeight uint32
		for _, subset := range c.subsets {
			weightedClusters = append(weightedClusters, &envoy_route.WeightedCluster_ClusterWeight{
				Name:          subset.ClusterName,
				Weight:        &wrappers.UInt32Value{Value: subset.Weight},
				MetadataMatch: envoy_common.LbMetadata(subset.Tags),
			})
			totalWeight += subset.Weight
		}
		routeAction.ClusterSpecifier = &envoy_route.RouteAction_WeightedClusters{
			WeightedClusters: &envoy_route.WeightedCluster{
				Clusters:    weightedClusters,
				TotalWeight: &wrappers.UInt32Value{Value: totalWeight},
			},
		}
	}
	return &routeAction
}

Is it correct?

@jakubdyszkiewicz
Copy link
Contributor Author

Sure, but if you are going with rewriting VirtualHosts you probably want that.

And if you want to patch routes fields - like I said in the description, most of the settings are available on VirtualHost object

Signed-off-by: Jakub Dyszkiewicz <[email protected]>
@jakubdyszkiewicz jakubdyszkiewicz force-pushed the feat/proxy-template-virtualhost branch from 0a5a444 to 25c130d Compare July 24, 2020 12:04
@jakubdyszkiewicz jakubdyszkiewicz merged commit 7b95184 into master Jul 27, 2020
@jakubdyszkiewicz jakubdyszkiewicz deleted the feat/proxy-template-virtualhost branch July 27, 2020 14:02
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.

3 participants