From 733ed348eb8c8c8aafb59c9216e96001dedfc191 Mon Sep 17 00:00:00 2001 From: Timam Date: Tue, 24 Oct 2023 11:56:32 +0600 Subject: [PATCH] added prometheus and helm dependency with terraform --- sandbox/.gitignore | 6 ++++++ sandbox/grafana.tf | 22 ++++++++++++++++++++++ sandbox/namespace.tf | 5 +++++ sandbox/prometheus.tf | 35 +++++++++++++++++++++++++++++++++++ sandbox/providers.tf | 11 +++++++++++ 5 files changed, 79 insertions(+) create mode 100644 sandbox/.gitignore create mode 100644 sandbox/grafana.tf create mode 100644 sandbox/namespace.tf create mode 100644 sandbox/prometheus.tf create mode 100644 sandbox/providers.tf diff --git a/sandbox/.gitignore b/sandbox/.gitignore new file mode 100644 index 0000000..bf156ab --- /dev/null +++ b/sandbox/.gitignore @@ -0,0 +1,6 @@ +# Terraform Files +.terraform +terraform.tfstate.d +.terraform.lock.hcl +terraform.tfstate +terraform.tfstate.backup diff --git a/sandbox/grafana.tf b/sandbox/grafana.tf new file mode 100644 index 0000000..cca1818 --- /dev/null +++ b/sandbox/grafana.tf @@ -0,0 +1,22 @@ +resource "helm_release" "grafana" { + namespace = kubernetes_namespace_v1.statuz.id + repository = "https://grafana.github.io/helm-charts" + chart = "grafana" + name = "grafana" + version = "6.61.1" + values = [ + <<-EOT + grafana.ini: + auth.anonymous: + enabled: true + org_role: Admin + datasources: + datasources.yaml: + apiVersion: 1 + datasources: + - name: Prometheus + type: prometheus + url: http://prometheus-server:80 + EOT + ] +} \ No newline at end of file diff --git a/sandbox/namespace.tf b/sandbox/namespace.tf new file mode 100644 index 0000000..569b017 --- /dev/null +++ b/sandbox/namespace.tf @@ -0,0 +1,5 @@ +resource "kubernetes_namespace_v1" "statuz" { + metadata { + name = "statuz" + } +} \ No newline at end of file diff --git a/sandbox/prometheus.tf b/sandbox/prometheus.tf new file mode 100644 index 0000000..dd3f6bd --- /dev/null +++ b/sandbox/prometheus.tf @@ -0,0 +1,35 @@ +resource "helm_release" "prometheus" { + namespace = kubernetes_namespace_v1.statuz.id + repository = "https://prometheus-community.github.io/helm-charts" + chart = "prometheus" + name = "prometheus" + version = "25.2.0" + values = [ + <<-EOT + serverFiles: + rule_files: + - /etc/config/recording_rules.yml + - /etc/config/alerting_rules.yml + prometheus.yml: + scrape_configs: + - job_name: prometheus + honor_timestamps: true + scrape_interval: 15s + scrape_timeout: 10s + metrics_path: /metrics + scheme: http + static_configs: + - targets: + - localhost:9090 + - job_name: watcher + honor_timestamps: true + scrape_interval: 15s + scrape_timeout: 10s + metrics_path: /metrics + scheme: http + static_configs: + - targets: + - watcher:8080 + EOT + ] +} \ No newline at end of file diff --git a/sandbox/providers.tf b/sandbox/providers.tf new file mode 100644 index 0000000..689d1ff --- /dev/null +++ b/sandbox/providers.tf @@ -0,0 +1,11 @@ +provider "kubernetes" { + config_path = "~/.kube/config" + config_context = "minikube" +} + +provider "helm" { + kubernetes { + config_path = "~/.kube/config" + config_context = "minikube" + } +} \ No newline at end of file