Skip to content

Service Discovery: allow multiple schemes to be specified in request#2719

Merged
ReubenBond merged 7 commits intomainfrom
rebond/sd-config-format
Mar 9, 2024
Merged

Service Discovery: allow multiple schemes to be specified in request#2719
ReubenBond merged 7 commits intomainfrom
rebond/sd-config-format

Conversation

@ReubenBond
Copy link
Copy Markdown
Member

@ReubenBond ReubenBond commented Mar 7, 2024

This PR adds support in Service Discovery for specifying multiple schemes during resolution, separated by a + character. This allows developers to enforce HTTPS in production while falling back to HTTP during development and testing.
For example, a user can allow both HTTPS and HTTP like so:

builder.Services.AddHttpClient<CatalogServiceClient>(
  c => c.BaseAddress = new("https+http://catalogservice"));

The order of schemes is important: if endpoints are found matching the first scheme, no endpoints from subsequent schemes are allowed.

This PR also introduces configuration to specify an allow-list of acceptable schemes for service discovery:

For example, to allow only https://:

builder.Services.Configure<ServiceDiscoveryOptions>(options =>
{
    options.AllowedSchemes = ["https"];
});

To allow http:// or https://:

builder.Services.Configure<ServiceDiscoveryOptions>(options =>
{
    options.AllowedSchemes = ["https", "http"];
});

To allow any scheme (the default):

builder.Services.Configure<ServiceDiscoveryOptions>(options =>
{
    options.AllowedSchemes = ServiceDiscoveryOptions.AllSchemes;
});

This PR changes the format of Service Discovery configuration so that the endpoint name is included in the configuration path, if an endpoint name is set. If no endpoint name is specified, then the scheme is used (and again, schemes are checked in the specified order, with only the first present being selected). If no endpoint name or scheme is specified, "default" is used as the endpoint name.

Microsoft Reviewers: Open in CodeFlow

@ReubenBond ReubenBond force-pushed the rebond/sd-config-format branch from 533d3d5 to acf0398 Compare March 8, 2024 20:30
@ReubenBond ReubenBond marked this pull request as ready for review March 8, 2024 20:41
var a = new AllocatedEndpointAnnotation(
sp.EndpointAnnotation.Name,
PortProtocol.ToProtocolType(svc.Spec.Protocol),
sp.EndpointAnnotation.AllocatedEndpoint = new AllocatedEndpoint(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

clean

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.

3 participants