kuma icon indicating copy to clipboard operation
kuma copied to clipboard

For policy plugins, consider adding internal structure for config modification

Open lukidzi opened this issue 2 years ago • 8 comments

Description

Currently, we find ourselves heavily engaged in reverse engineering to modify certain resources. For instance, when creating a separate 'ClusterLoadAssignment' for the dataplane, we must either create a 'CLACache' entry or create the configuration by ourselves. However, in the latter case, we encounter challenges as we need to provide the internal 'Cluster' and 'Endpoint' structures. Unfortunately, we cannot always use EndpointMap from the context because it might not have all the data provided by other plugins in ResourceSet. It may be beneficial to explore the possibility of propagating internal objects such as 'Cluster,' 'Endpoint,' 'Route,' 'Listener,' together with the 'ResourceSet.' This approach could significantly streamline the configuration generation process.

This is more idea and we should probably rethink if that makes sense. https://github.com/kumahq/kuma/issues/8124

lukidzi avatar Oct 24 '23 10:10 lukidzi

:+1: This is definitely something we discussed before I think

A little bit in https://github.com/kumahq/kuma/issues/6417 and definitely in PRs where we introduced the plugin structure.

We should ideally be working with intermediate objects until the last second where we serialize the config to the DP. At the moment in many places, we are forced to hackily link Envoy resources back to Kuma resources and parts of resources, by parsing the Name string for example.

michaelbeaumont avatar Oct 24 '23 10:10 michaelbeaumont

This issue was inactive for 90 days. It will be reviewed in the next triage meeting and might be closed. If you think this issue is still relevant, please comment on it or attend the next triage meeting.

github-actions[bot] avatar Jan 29 '24 07:01 github-actions[bot]

This issue was inactive for 90 days. It will be reviewed in the next triage meeting and might be closed. If you think this issue is still relevant, please comment on it or attend the next triage meeting.

github-actions[bot] avatar Apr 29 '24 07:04 github-actions[bot]

This issue was inactive for 90 days. It will be reviewed in the next triage meeting and might be closed. If you think this issue is still relevant, please comment on it or attend the next triage meeting.

github-actions[bot] avatar Jul 29 '24 07:07 github-actions[bot]

Discussed this today, came up with a code snippet of the usage of such internal structure:

// rs.AppOutbounds()
// rs.AppOutbounds().Routes() 
// rs.AppInbounds()
// rs.SystemInbounds()
// rs.SystemOutbounds() ???
for _, appOutbound := range rs.AppOutbounds() {
	for _, port := range appOutbound.Ports() {
		configurer := plugin_xds.ListenerConfigurer{
			Rules:    rules.ResourceRules.Compute(appOutbound.MeshService, meshCtx, core_rules.WithSectionName(port.Name)),
			Protocol: port.AppProtocol,
		}
		if err := configurer.ConfigureListener(port.Listener); err != nil {
			return err
		}
	}
}

CC @Automaat it appears we already have an issue for this!

lobkovilya avatar Aug 02 '24 14:08 lobkovilya