Skip to content

Commit

Permalink
microsoft#1640 Combine Kubernetes ingress controller into a single de…
Browse files Browse the repository at this point in the history
…ployable
  • Loading branch information
dpbevin committed Apr 21, 2022
1 parent e684ba5 commit e5fc506
Show file tree
Hide file tree
Showing 33 changed files with 123 additions and 764 deletions.
11 changes: 0 additions & 11 deletions reverse-proxy.sln
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReverseProxy.Direct", "test
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yarp.Kubernetes.Controller", "src\Kubernetes.Controller\Yarp.Kubernetes.Controller.csproj", "{5C8E9658-39DA-4C27-A939-68F94B62110B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yarp.Kubernetes.Protocol", "src\Kubernetes.Protocol\Yarp.Kubernetes.Protocol.csproj", "{4188D742-AC87-4CF4-86A0-3AB7AF034764}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "OperatorFramework", "OperatorFramework", "{3A8C7CF8-1F32-474E-B68A-B548A3384BB4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E96BB4D7-EECC-4A78-BC7D-E167663FD6F2}"
Expand Down Expand Up @@ -282,14 +280,6 @@ Global
{5C8E9658-39DA-4C27-A939-68F94B62110B}.Release|Any CPU.Build.0 = Release|Any CPU
{5C8E9658-39DA-4C27-A939-68F94B62110B}.Release|x64.ActiveCfg = Release|Any CPU
{5C8E9658-39DA-4C27-A939-68F94B62110B}.Release|x64.Build.0 = Release|Any CPU
{4188D742-AC87-4CF4-86A0-3AB7AF034764}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4188D742-AC87-4CF4-86A0-3AB7AF034764}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4188D742-AC87-4CF4-86A0-3AB7AF034764}.Debug|x64.ActiveCfg = Debug|Any CPU
{4188D742-AC87-4CF4-86A0-3AB7AF034764}.Debug|x64.Build.0 = Debug|Any CPU
{4188D742-AC87-4CF4-86A0-3AB7AF034764}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4188D742-AC87-4CF4-86A0-3AB7AF034764}.Release|Any CPU.Build.0 = Release|Any CPU
{4188D742-AC87-4CF4-86A0-3AB7AF034764}.Release|x64.ActiveCfg = Release|Any CPU
{4188D742-AC87-4CF4-86A0-3AB7AF034764}.Release|x64.Build.0 = Release|Any CPU
{EC716F93-C710-4D0E-BEB2-EB29BBD5F426}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EC716F93-C710-4D0E-BEB2-EB29BBD5F426}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC716F93-C710-4D0E-BEB2-EB29BBD5F426}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -467,7 +457,6 @@ Global
{AE06F9BE-0B8D-4D02-9DC6-FE5A41FA4B5D} = {CDB73246-0A7E-4116-81E0-828228ECADDD}
{6FE9874A-87B9-42C6-B19C-065A97CC6360} = {CDB73246-0A7E-4116-81E0-828228ECADDD}
{5C8E9658-39DA-4C27-A939-68F94B62110B} = {6CBE18D4-64E9-492B-BB02-58CD57126C10}
{4188D742-AC87-4CF4-86A0-3AB7AF034764} = {6CBE18D4-64E9-492B-BB02-58CD57126C10}
{3A8C7CF8-1F32-474E-B68A-B548A3384BB4} = {6CBE18D4-64E9-492B-BB02-58CD57126C10}
{E96BB4D7-EECC-4A78-BC7D-E167663FD6F2} = {3A8C7CF8-1F32-474E-B68A-B548A3384BB4}
{EC716F93-C710-4D0E-BEB2-EB29BBD5F426} = {E96BB4D7-EECC-4A78-BC7D-E167663FD6F2}
Expand Down
2 changes: 1 addition & 1 deletion samples/KuberenetesIngress.Sample/Ingress/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ COPY ["samples/KuberenetesIngress.Sample/Ingress/Yarp.Kubernetes.Ingress.csproj"
COPY ["src/OperatorFramework/src/Controller/Microsoft.Kubernetes.Controller.csproj", "src/OperatorFramework/src/Controller/"]
COPY ["src/OperatorFramework/src/Core/Microsoft.Kubernetes.Core.csproj", "src/OperatorFramework/src/Core/"]
COPY ["src/ReverseProxy/Yarp.ReverseProxy.csproj", "src/ReverseProxy/"]
COPY ["src/Kubernetes.Protocol/Yarp.Kubernetes.Protocol.csproj", "src/Kubernetes.Protocol/"]
COPY ["src/Kubernetes.Controller/Yarp.Kubernetes.Controller.csproj", "src/Kubernetes.Controller/"]
COPY ["src/Directory.Build.props", "src/"]
COPY ["Directory.Build.*", "./"]
COPY ["global.json", ""]
Expand Down
5 changes: 5 additions & 0 deletions samples/KuberenetesIngress.Sample/Ingress/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Serilog;
Expand All @@ -20,6 +21,10 @@ public static void Main(string[] args)
.CreateLogger();

Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration(config =>
{
config.AddJsonFile("/app/config/yarp.json", optional: true);
})
.ConfigureLogging(logging =>
{
logging.ClearProviders();
Expand Down
22 changes: 20 additions & 2 deletions samples/KuberenetesIngress.Sample/Ingress/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# Yarp Ingress and Ingress Controller
# Yarp Ingress Controller

This directory contains a sample ingress as well as the definition for the Kubernetes manifests for the ingress and ingress controller.
This directory contains a sample ingress as well as the definition for the Kubernetes manifests for the ingress controller.

The sample ingress controller is a single deployable (previously this was two separate deployables).

## Building the Docker Image

From the base directory for this repo (where the .sln file is), run the command:

```
docker build -t yarp:latest -f .\samples\KuberenetesIngress.Sample\Ingress\Dockerfile .
```

## Deploying the Sample Ingress Controller

1. Open the [ingress-controller.yaml](.\ingress-controller.yaml) file
2. Modify the container image to match the name used when building the image, e.g. change `<REGISTRY_NAME>/yarp:<TAG>` to `yarp:latest`
3. Run the command `kubectl apply -f .\samples\KuberenetesIngress.Sample\Ingress\ingress-controller.yaml`

To undeploy the ingress controller, run the command `kubectl delete -f .\samples\KuberenetesIngress.Sample\Ingress\ingress-controller.yaml`
6 changes: 1 addition & 5 deletions samples/KuberenetesIngress.Sample/Ingress/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Yarp.Kubernetes.Protocol;

namespace Yarp.Kubernetes.Ingress
{
Expand All @@ -22,10 +21,7 @@ public Startup(IConfiguration configuration)
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.Configure<ReceiverOptions>(_configuration.Bind);
services.AddHostedService<Receiver>();
services.AddReverseProxy()
.LoadFromMessages();
services.AddKubernetesReverseProxy(_configuration);
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\OperatorFramework\src\Controller\Microsoft.Kubernetes.Controller.csproj" />
<ProjectReference Include="..\..\..\src\Kubernetes.Protocol\Yarp.Kubernetes.Protocol.csproj" />
<ProjectReference Include="..\..\..\src\ReverseProxy\Yarp.ReverseProxy.csproj" />
<ProjectReference Include="..\..\..\src\Kubernetes.Controller\Yarp.Kubernetes.Controller.csproj" />
</ItemGroup>

</Project>
4 changes: 3 additions & 1 deletion samples/KuberenetesIngress.Sample/Ingress/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
}
},
"AllowedHosts": "*",
"ControllerUrl": "http://yarp-controller.yarp.svc.cluster.local:8000/api/dispatch"
"Yarp": {
"ControllerClass": "microsoft.com/ingress-yarp"
}
}
21 changes: 14 additions & 7 deletions samples/KuberenetesIngress.Sample/Ingress/ingress-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,24 +105,28 @@ annotations:
apiVersion: v1
kind: Service
metadata:
name: yarp-controller
name: ingress-yarp-controller
namespace: yarp
spec:
ports:
- name: api
port: 8000
- name: proxy
port: 80
protocol: TCP
targetPort: 8000
- name: proxy-ssl
port: 443
protocol: TCP
targetPort: 8443
selector:
app: ingress-yarp-controller
type: ClusterIP
type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: ingress-yarp-controller
name: yarp-controller
name: ingress-yarp
namespace: yarp
spec:
replicas: 1
Expand All @@ -137,10 +141,13 @@ spec:
containers:
- name: yarp-controller
imagePullPolicy: IfNotPresent
image: <REGISTRY_NAME>/yarp-controller:<TAG>
image: <REGISTRY_NAME>/yarp:<TAG>
ports:
- containerPort: 8000
name: api
name: proxy
protocol: TCP
- containerPort: 8443
name: proxy-ssl
protocol: TCP
env:
- name: ASPNETCORE_URLS
Expand Down
58 changes: 0 additions & 58 deletions samples/KuberenetesIngress.Sample/Ingress/ingress.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System.Collections.Generic;
using Yarp.ReverseProxy.Configuration;

namespace Yarp.Kubernetes.Protocol;
namespace Yarp.Kubernetes.Controller.Configuration;

public interface IUpdateConfig
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
using Microsoft.Extensions.Primitives;
using Yarp.ReverseProxy.Configuration;

namespace Yarp.Kubernetes.Protocol;
namespace Yarp.Kubernetes.Controller.Configuration;

public class MessageConfigProvider : IProxyConfigProvider, IUpdateConfig
internal class KubernetesConfigProvider : IProxyConfigProvider, IUpdateConfig
{
private volatile MessageConfig _config;

public MessageConfigProvider()
public KubernetesConfigProvider()
{
_config = new MessageConfig(null, null);
}
Expand Down
30 changes: 0 additions & 30 deletions src/Kubernetes.Controller/Controllers/DispatchController.cs

This file was deleted.

106 changes: 0 additions & 106 deletions src/Kubernetes.Controller/Dispatching/DispatchActionResult.cs

This file was deleted.

Loading

0 comments on commit e5fc506

Please sign in to comment.