-
Couldn't load subscription status.
- Fork 712
Add YARP container support #8856
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
Changes from all commits
16e8774
20421f3
f4dad75
928f461
e776f80
81c8853
a524d72
c23cba8
1e303f3
289499f
01b7e54
ad87b8d
685fda5
cec8dbb
632c960
7a11cf2
db654f7
a23dc9b
23f5c65
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "Logging": { | ||
| "LogLevel": { | ||
| "Default": "Information", | ||
| "Microsoft.AspNetCore": "Warning" | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| { | ||
| "Logging": { | ||
| "LogLevel": { | ||
| "Default": "Information", | ||
| "Microsoft.AspNetCore": "Information" | ||
| } | ||
| }, | ||
| "AllowedHosts": "*", | ||
| "ReverseProxy": { | ||
| "Routes": { | ||
| "catalog": { | ||
| "ClusterId": "catalog", | ||
| "Match": { | ||
| "Path": "/catalog/{**catch-all}" | ||
| }, | ||
| "Transforms": [ | ||
| { "PathRemovePrefix": "/catalog" } | ||
| ] | ||
| }, | ||
| "basket": { | ||
| "ClusterId": "basket", | ||
| "Match": { | ||
| "Path": "/basket/{**catch-all}" | ||
| }, | ||
| "Transforms": [ | ||
| { "PathRemovePrefix": "/basket" } | ||
| ] | ||
| } | ||
| }, | ||
| "Clusters": { | ||
| "catalog": { | ||
| "Destinations": { | ||
| "catalog": { | ||
| "Address": "http://catalogservice", | ||
| "Health": "http://catalogservice/readiness" | ||
| } | ||
| } | ||
| }, | ||
| "basket": { | ||
| "Destinations": { | ||
| "basket": { | ||
| "Address": "http://basketservice", | ||
| "Health": "http://basketservice/readiness" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,3 +65,4 @@ urls | |
| kubernetes | ||
| Pgweb | ||
| elasticsearch | ||
| Yarp | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>$(DefaultTargetFramework)</TargetFramework> | ||
| <IsPackable>true</IsPackable> | ||
| <PackageTags>aspire integration hosting yarp reverse-proxy</PackageTags> | ||
| <Description>YARP support for .NET Aspire.</Description> | ||
| <EnablePackageValidation>false</EnablePackageValidation> | ||
| <SuppressFinalPackageVersion>true</SuppressFinalPackageVersion> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup> | ||
| <MinCodeCoverage>0</MinCodeCoverage> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\Aspire.Hosting\Aspire.Hosting.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| # Aspire.Hosting.Yarp library | ||
|
|
||
| Provides extension methods and resource definitions for a .NET Aspire AppHost to configure a YARP instance. | ||
|
|
||
| ## Getting started | ||
|
|
||
| ### Install the package | ||
|
|
||
| In your AppHost project, install the .NET Aspire YARP Hosting library with [NuGet](https://www.nuget.org): | ||
|
|
||
| ```dotnetcli | ||
| dotnet add package Aspire.Hosting.Yarp | ||
| ``` | ||
|
|
||
| ## Usage example | ||
|
|
||
| Then, in the _Program.cs_ file of `AppHost`, add a YARP resource and provide the configuration file using the following methods: | ||
|
|
||
| ```csharp | ||
| var catalogService = builder.AddProject<Projects.CatalogService>("catalogservice") | ||
| [...]; | ||
| var basketService = builder.AddProject<Projects.BasketService>("basketservice") | ||
| [...]; | ||
|
|
||
| builder.AddYarp("apigateway") | ||
| .WithConfigFile("yarp.json") | ||
| .WithReference(basketService) | ||
| .WithReference(catalogService); | ||
| ``` | ||
|
|
||
| The `yarp.json` configuration file can use the referenced service like this: | ||
|
|
||
| ```json | ||
| { | ||
| "Logging": { | ||
| "LogLevel": { | ||
| "Default": "Information", | ||
| "Microsoft.AspNetCore": "Information" | ||
| } | ||
| }, | ||
| "AllowedHosts": "*", | ||
| "ReverseProxy": { | ||
| "Routes": { | ||
| "catalog": { | ||
| "ClusterId": "catalog", | ||
| "Match": { | ||
| "Path": "/catalog/{**catch-all}" | ||
| }, | ||
| "Transforms": [ | ||
| { "PathRemovePrefix": "/catalog" } | ||
| ] | ||
| }, | ||
| "basket": { | ||
| "ClusterId": "basket", | ||
| "Match": { | ||
| "Path": "/basket/{**catch-all}" | ||
| }, | ||
| "Transforms": [ | ||
| { "PathRemovePrefix": "/basket" } | ||
| ] | ||
| } | ||
| }, | ||
| "Clusters": { | ||
| "catalog": { | ||
| "Destinations": { | ||
| "catalog": { | ||
| "Address": "http://catalogservice", | ||
| } | ||
| } | ||
| }, | ||
| "basket": { | ||
| "Destinations": { | ||
| "basket": { | ||
| "Address": "http://basketservice", | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
benjaminpetit marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| ## Additional documentation | ||
|
|
||
| * https://learn.microsoft.com/dotnet/aspire/caching/stackexchange-redis-component | ||
| * https://learn.microsoft.com/dotnet/aspire/caching/stackexchange-redis-output-caching-component | ||
| * https://learn.microsoft.com/dotnet/aspire/caching/stackexchange-redis-distributed-caching-component | ||
|
|
||
| ## Feedback & contributing | ||
|
|
||
| https://github.com/dotnet/aspire | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace Aspire.Hosting.Yarp; | ||
|
|
||
| internal static class YarpContainerImageTags | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like the other ones all have tags for each of these. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure to understand? |
||
| { | ||
| public const string Registry = "mcr.microsoft.com"; | ||
|
|
||
| public const string Image = "dotnet/nightly/yarp"; | ||
|
|
||
| public const string Tag = "2-preview"; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using Aspire.Hosting.ApplicationModel; | ||
|
|
||
| namespace Aspire.Hosting.Yarp; | ||
|
|
||
| /// <summary> | ||
| /// A resource that represents a YARP resource independent of the hosting model. | ||
| /// </summary> | ||
| /// <param name="name">The name of the resource.</param> | ||
| public class YarpResource(string name) : ContainerResource(name) | ||
| { | ||
| /// <summary> | ||
| /// File path of the config file for this YARP resource. | ||
| /// </summary> | ||
| internal string? ConfigFilePath { get; set; } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.