diff --git a/helm/values/traefik.values.yaml b/helm/values/traefik.values.yaml new file mode 100644 index 0000000..cdc8c25 --- /dev/null +++ b/helm/values/traefik.values.yaml @@ -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 diff --git a/main.ts b/main.ts index 061a293..8b88821 100644 --- a/main.ts +++ b/main.ts @@ -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", { diff --git a/traefik/index.ts b/traefik/index.ts new file mode 100644 index 0000000..bc9db06 --- /dev/null +++ b/traefik/index.ts @@ -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", + }), + ], + }); + } +}