fix: Grafana | use IngressRoute instead of Ingress
This commit is contained in:
@@ -6,6 +6,7 @@ import { TerraformStack } from "cdktf";
|
|||||||
import { Construct } from "constructs";
|
import { Construct } from "constructs";
|
||||||
import { BarmanCloudPluginInstall } from "./barman";
|
import { BarmanCloudPluginInstall } from "./barman";
|
||||||
import { Prometheus } from "./prometheus";
|
import { Prometheus } from "./prometheus";
|
||||||
|
import { KubernetesProvider } from "@cdktf/provider-kubernetes/lib/provider";
|
||||||
|
|
||||||
export class K8SOperators extends TerraformStack {
|
export class K8SOperators extends TerraformStack {
|
||||||
constructor(scope: Construct, id: string) {
|
constructor(scope: Construct, id: string) {
|
||||||
@@ -17,8 +18,15 @@ export class K8SOperators extends TerraformStack {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const kubernetes = new KubernetesProvider(this, "kubernetes", {
|
||||||
|
configPath: "~/.kube/config",
|
||||||
|
});
|
||||||
|
|
||||||
new Prometheus(this, "prometheus", {
|
new Prometheus(this, "prometheus", {
|
||||||
provider: helm,
|
providers: {
|
||||||
|
helm,
|
||||||
|
kubernetes,
|
||||||
|
},
|
||||||
namespace: "monitoring",
|
namespace: "monitoring",
|
||||||
name: "prometheus-operator",
|
name: "prometheus-operator",
|
||||||
version: "75.10.0",
|
version: "75.10.0",
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { HelmProvider } from "@cdktf/provider-helm/lib/provider";
|
import * as path from "path";
|
||||||
import { Release } from "@cdktf/provider-helm/lib/release";
|
import { Release } from "@cdktf/provider-helm/lib/release";
|
||||||
import { Construct } from "constructs";
|
import { Construct } from "constructs";
|
||||||
|
import { CloudflareCertificate, IngressRoute } from "../../utils";
|
||||||
|
import { Providers } from "../../types";
|
||||||
|
|
||||||
type PrometheusOptions = {
|
type PrometheusOptions = {
|
||||||
provider: HelmProvider;
|
providers: Providers;
|
||||||
name: string;
|
name: string;
|
||||||
namespace: string;
|
namespace: string;
|
||||||
version: string;
|
version: string;
|
||||||
@@ -14,13 +16,35 @@ export class Prometheus extends Construct {
|
|||||||
constructor(scope: Construct, id: string, options: PrometheusOptions) {
|
constructor(scope: Construct, id: string, options: PrometheusOptions) {
|
||||||
super(scope, id);
|
super(scope, id);
|
||||||
|
|
||||||
|
const { helm, kubernetes } = options.providers;
|
||||||
|
|
||||||
|
new CloudflareCertificate(this, "certificate", {
|
||||||
|
provider: kubernetes,
|
||||||
|
name: "grafana",
|
||||||
|
namespace: options.namespace,
|
||||||
|
dnsNames: ["grafana.dogar.dev"],
|
||||||
|
secretName: "grafana-tls",
|
||||||
|
});
|
||||||
|
|
||||||
|
new IngressRoute(this, "ingress", {
|
||||||
|
provider: kubernetes,
|
||||||
|
name: "grafana",
|
||||||
|
namespace: options.namespace,
|
||||||
|
entryPoints: ["websecure"],
|
||||||
|
serviceName: "prometheus-operator-grafana",
|
||||||
|
servicePort: 80,
|
||||||
|
tlsSecretName: "grafana-tls",
|
||||||
|
host: "grafana.dogar.dev",
|
||||||
|
});
|
||||||
|
|
||||||
new Release(this, id, {
|
new Release(this, id, {
|
||||||
...options,
|
...options,
|
||||||
|
provider: helm,
|
||||||
repository: "https://prometheus-community.github.io/helm-charts",
|
repository: "https://prometheus-community.github.io/helm-charts",
|
||||||
chart: "kube-prometheus-stack",
|
chart: "kube-prometheus-stack",
|
||||||
createNamespace: true,
|
createNamespace: true,
|
||||||
values: [
|
values: [
|
||||||
fs.readFileSync("helm/values/prometheus.values.yaml", {
|
fs.readFileSync(path.join(__dirname, "values.yaml"), {
|
||||||
encoding: "utf8",
|
encoding: "utf8",
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|||||||
4
k8s-operators/prometheus/values.yaml
Normal file
4
k8s-operators/prometheus/values.yaml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
grafana:
|
||||||
|
enabled: true
|
||||||
|
ingress:
|
||||||
|
enabled: false
|
||||||
Reference in New Issue
Block a user