Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Add DNSPolicy Routing Strategy #629

Merged

Conversation

mikenairn
Copy link
Member

@mikenairn mikenairn commented Oct 18, 2023

Adds a routing strategy field to the DNSPolicy spec that determines how the policy with generate endpoints for any created DNSRecords.

Two routing strategies are allowed, simple and loadbalanced. Simple will creates a single DNS record (A or CNAME) for each listener/hostname with all ip/hostnames as targets. LoadBalanced works as before by creating a more complex record structure with CNAMES and A records using Geo and Weighted routing strategies to achieve loadbalancing functionality.

The strategy field is currently marked as immutable and it should not be changed after initial DNSPolicy creation.

closes #655

@maleck13
Copy link
Contributor

want to merge this to single-cluster branch?
I almost have a pr now for a flag to turn off OCM integration

mikenairn added a commit that referenced this pull request Oct 19, 2023
mikenairn added a commit to mikenairn/multi-cluster-traffic-controller that referenced this pull request Oct 19, 2023
mikenairn added a commit that referenced this pull request Oct 19, 2023
@mikenairn mikenairn changed the title Add DNSPolicy Strategy Add DNSPolicy Routing Strategy Nov 6, 2023
@mikenairn mikenairn force-pushed the simple_dnspolicy_strategy branch from d53d848 to 66668bd Compare November 6, 2023 13:11
@mikenairn mikenairn force-pushed the simple_dnspolicy_strategy branch from 83916f0 to 69ff542 Compare November 6, 2023 18:16
@mikenairn mikenairn force-pushed the simple_dnspolicy_strategy branch from 0ccee81 to b00c61c Compare November 8, 2023 10:45
@mikenairn mikenairn force-pushed the simple_dnspolicy_strategy branch from b00c61c to 206a8ae Compare November 8, 2023 11:00
@mikenairn mikenairn force-pushed the simple_dnspolicy_strategy branch from 206a8ae to cee6e58 Compare November 8, 2023 14:20
@mikenairn mikenairn marked this pull request as ready for review November 8, 2023 14:23
@@ -205,11 +203,14 @@ func getClusterGatewayAddresses(gw *gatewayv1beta1.Gateway) map[string][]gateway
}
}

gatewayAddresses = append(gatewayAddresses, gatewayv1beta1.GatewayAddress{
if _, ok := clusterAddrs[cluster]; !ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

yeah this is what I expected nice!

@maleck13
Copy link
Contributor

maleck13 commented Nov 8, 2023

This is looking good to me, we need to wait on @makslion PR to allow setting things like geo and weight in a single cluster (IE to something custom like what we did with ManagedCLuster)?

@mikenairn
Copy link
Member Author

This is looking good to me, we need to wait on @makslion PR to allow setting things like geo and weight in a single cluster (IE to something custom like what we did with ManagedCLuster)?

It should already be possible to do this by adding the same labels to the gateway itself in a single cluster context . Admittedly there is no test for it, but would be fairly easy to add now.

@mikenairn mikenairn force-pushed the simple_dnspolicy_strategy branch from cee6e58 to db29367 Compare November 8, 2023 17:45
// +kubebuilder:validation:Enum=simple;loadbalanced
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="RoutingStrategy is immutable"
// +kubebuilder:default=loadbalanced
RoutingStrategy RoutingStrategy `json:"routingStrategy"`
Copy link
Member Author

Choose a reason for hiding this comment

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

routingStrategy is required, but having the default means you don't have to specify it and will default to "loadbalanced" (The current behaviour)


// getSimpleEndpoints returns the endpoints for the given MultiClusterGatewayTarget using the simple routing strategy

func (dh *dnsHelper) getSimpleEndpoints(mcgTarget *dns.MultiClusterGatewayTarget, hostname string, currentEndpoints map[string]*v1alpha1.Endpoint) []*v1alpha1.Endpoint {
Copy link
Contributor

Choose a reason for hiding this comment

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

might want to change the name of this type? Bit confusing when we are also working in single cluster

Copy link
Member Author

Choose a reason for hiding this comment

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

I assume you are talking about MultiClusterGatewayTarget and yes it needs renamed. Won't be in this PR though.

))
}, TestTimeoutMedium, TestRetryIntervalMedium, ctx).Should(Succeed())
})

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 a pretty great test, but there is a lot going on in this file now. Perhaps as a follow up we could think about whether we should split this test in someway to make it easier to read / mantain? IE single vs multi or something

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, its far too long now, and a lot more could be added so we need to look at how we want these to be separated out. Probably at the very least a separate test file for multi/single and simple/loadbalanced contexts.

Copy link
Contributor

@maleck13 maleck13 left a comment

Choose a reason for hiding this comment

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

Happy to merge this, some minor comments.

Adds a routingStrategy field to the DNSPolicy spec that determines how
the policy with generate endpoints for any created DNSRecords.

Two strategies are allowed, `simple` and `loadbalanced`. Simple will
create a single DNS record (A or CNAME) for each listener/hostname with
all ip/hostnames as targets. LoadBalanced works as before by creating a
more complex record structure with CNAMES and A records using Geo and
Weighted routing strategies to achieve loadbalancing functionality.

The routingStrategy field is currently marked as immutable and it should
not be changed after initial DNSPolicy creation.
Update DNSPolicy test to include contexts for routing strategy + single
and multi cluster status.
Rename builders to <ResourceName>Builder e.g. GatewayBuilder, TLSPolicyBuilder etc...
Remove references to "placed" where possible
Rename most constants to make them more consistent with what they are.
Copy link
Contributor

openshift-ci bot commented Nov 10, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: maleck13, mikenairn

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@maleck13
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Nov 10, 2023
@openshift-merge-bot openshift-merge-bot bot merged commit 910af6e into Kuadrant:main Nov 10, 2023
9 checks passed
@mikenairn mikenairn deleted the simple_dnspolicy_strategy branch November 10, 2023 10:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add simple routing strategy to DNSPolicy
2 participants