diff --git a/helm/helmfile.yaml b/helm/helmfile.yaml index a7fa786..556e0b0 100644 --- a/helm/helmfile.yaml +++ b/helm/helmfile.yaml @@ -1,8 +1,6 @@ repositories: - name: metallb url: https://metallb.github.io/metallb - - name: prometheus-community - url: https://prometheus-community.github.io/helm-charts --- releases: # Load Balancer @@ -10,11 +8,3 @@ releases: namespace: metallb-system chart: metallb/metallb version: 0.14.8 - - # Prometheus Operator - - name: prometheus-operator - namespace: prometheus-system - chart: prometheus-community/kube-prometheus-stack - version: 62.3.0 - values: - - ./values/prometheus.values.yaml diff --git a/main.ts b/main.ts index 55448fb..4e84c66 100644 --- a/main.ts +++ b/main.ts @@ -16,6 +16,7 @@ import { Manifest } from "@cdktf/provider-kubernetes/lib/manifest"; import { PiHole } from "./pihole"; import { MemcachedCluster } from "./memcached"; import { Nginx } from "./nginx"; +import { Prometheus } from "./prometheus"; dotenv.config(); @@ -81,6 +82,12 @@ class Homelab extends TerraformStack { name: "ingress-nginx-internal", }); + new Prometheus(this, "prometheus", { + provider: helm, + namespace: "prometheus-system", + name: "prometheus-operator", + }); + const certManagerApiVersion = "cert-manager.io/v1"; new CertManager(this, "cert-manager", { diff --git a/prometheus/index.ts b/prometheus/index.ts new file mode 100644 index 0000000..7b5f1da --- /dev/null +++ b/prometheus/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 PrometheusOptions = { + provider: HelmProvider; + name: string; + namespace: string; +}; + +export class Prometheus extends Construct { + constructor(scope: Construct, id: string, options: PrometheusOptions) { + super(scope, id); + + new Release(this, id, { + ...options, + repository: "https://prometheus-community.github.io/helm-charts", + chart: "kube-prometheus-stack", + createNamespace: true, + values: [ + fs.readFileSync("helm/values/prometheus.values.yaml", { + encoding: "utf8", + }), + ], + }); + } +}