-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTraefikIngressRoute.cs
52 lines (47 loc) · 1.9 KB
/
TraefikIngressRoute.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using JetBrains.Annotations;
using Pulumi;
using Pulumi.Kubernetes.Core.V1;
using Ubiquitous.AutoDevOps.Stack.Factories;
namespace Ubiquitous.AutoDevOps.Crds.Traefik;
[PublicAPI]
public class TraefikIngressRoute {
public TraefikIngressRoute(
ResourceName ingressRouteName,
Uri environmentUri,
Service service,
Output<string> namespaceName,
string endpoint,
bool tls
) {
InputList<string> endpoints = new() {endpoint};
InputList<IngressRouteRouteMiddlewaresArgs> middlewares = new();
if (tls) {
endpoints.Add($"{endpoint}-https");
middlewares.Add(new IngressRouteRouteMiddlewaresArgs {Name = "http-to-https", Namespace = "default"});
}
IngressRule = new IngressRoute(
ingressRouteName.AsPulumiName(),
new IngressRouteArgs {
Metadata = Meta.GetMeta(ingressRouteName, namespaceName),
Spec = new IngressRouteSpecArgs {
EntryPoints = endpoints,
Routes = new[] {
new IngressRouteRoutesArgs {
Match = $"Host(`{environmentUri.Host}`)",
Middlewares = middlewares,
Services = new[] {
new IngressRouteRouteServicesArgs {
Name = service.Metadata.Apply(x => x.Name),
Namespace = namespaceName,
Port = service.Spec.Apply(x => x.Ports.First().Port),
Scheme = "http"
}
}
}
}
}
}
);
}
public IngressRoute IngressRule { get; }
}