feat: Traefik | add traefik ingress class

This commit is contained in:
2025-11-19 18:09:53 +05:00
parent 6b1439dcd4
commit fabede0953
3 changed files with 53 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
ingress:
ingressClass:
enabled: true
isDefaultClass: false
name: traefik
deployment:
replicas: 3
podLabels:
app: traefik
nodeSelector:
nodepool: worker
topologySpreadConstraints:
- maxSkew: 1
topologyKey: "kubernetes.io/hostname"
whenUnsatisfiable: "ScheduleAnyway"
labelSelector:
matchLabels:
app: traefik

View File

@@ -14,6 +14,7 @@ import { AuthentikServer } from "./authentik";
import { ValkeyCluster } from "./valkey";
import { CertManager } from "./cert-manager";
import { Nginx } from "./nginx";
import { Traefik } from "./traefik";
import { Prometheus } from "./prometheus";
import { MetalLB } from "./metallb";
import { ExternalDNS } from "./external-dns";
@@ -74,6 +75,12 @@ class Homelab extends TerraformStack {
name: "nginx-ingress",
});
new Traefik(this, "traefik", {
provider: helm,
namespace,
name: "traefik",
});
const certManagerApiVersion = "cert-manager.io/v1";
const cm = new CertManager(this, "cert-manager", {

28
traefik/index.ts Normal file
View File

@@ -0,0 +1,28 @@
import * as fs from "fs";
import { HelmProvider } from "@cdktf/provider-helm/lib/provider";
import { Release } from "@cdktf/provider-helm/lib/release";
import { Construct } from "constructs";
type TraefikOptions = {
provider: HelmProvider;
name: string;
namespace: string;
};
export class Traefik extends Construct {
constructor(scope: Construct, id: string, options: TraefikOptions) {
super(scope, id);
new Release(this, id, {
...options,
repository: "https://traefik.github.io/charts",
chart: "traefik",
createNamespace: true,
values: [
fs.readFileSync("helm/values/traefik.values.yaml", {
encoding: "utf8",
}),
],
});
}
}