From 58631a68b63bdb9a75abdac4f8961db19b97587e Mon Sep 17 00:00:00 2001 From: Cameron Delano Date: Tue, 17 Jan 2023 07:29:23 -0800 Subject: [PATCH] Workflow fix + Monitoring --- .github/workflows/xc-nap-destroy.yml | 2 +- nap/charts/grafana/values.yaml | 50 ++++++++++++++++++++++++++++ nap/charts/prometheus/Chart.yaml | 10 ------ nap/grafana.tf | 8 +++++ nap/locals.tf | 1 + nap/namespace.tf | 5 +++ nap/nap.tf | 2 +- nap/prometheus.tf | 8 +++++ 8 files changed, 74 insertions(+), 12 deletions(-) create mode 100644 nap/charts/grafana/values.yaml delete mode 100644 nap/charts/prometheus/Chart.yaml create mode 100644 nap/grafana.tf create mode 100644 nap/prometheus.tf diff --git a/.github/workflows/xc-nap-destroy.yml b/.github/workflows/xc-nap-destroy.yml index 90dcf5e60..7e42e56ba 100644 --- a/.github/workflows/xc-nap-destroy.yml +++ b/.github/workflows/xc-nap-destroy.yml @@ -84,7 +84,7 @@ jobs: terraform_arcadia: name: "arcadia" runs-on: ubuntu-latest - needs: terraform_nap + needs: terraform_xc defaults: run: working-directory: ./arcadia diff --git a/nap/charts/grafana/values.yaml b/nap/charts/grafana/values.yaml new file mode 100644 index 000000000..1c4d2b31c --- /dev/null +++ b/nap/charts/grafana/values.yaml @@ -0,0 +1,50 @@ +--- +grafana: + rbac: + pspEnabled: false + testFramework: + enabled: false + persistence: + enabled: true + type: pvc + accessModes: + - ReadWriteOnce + size: 4Gi + finalizers: + - kubernetes.io/pvc-protection + datasources: + datasources.yaml: + apiVersion: 1 + datasources: + - name: Prometheus + type: prometheus + url: http://prometheus-server + dashboardProviders: + dashboardproviders.yaml: + apiVersion: 1 + providers: + - name: "default" + orgId: 1 + folder: "" + type: file + disableDeletion: false + editable: true + options: + path: /var/lib/grafana/dashboards/default + dashboards: + default: + nginx: + url: https://raw.githubusercontent.com/nginxinc/kubernetes-ingress/main/grafana/NGINXPlusICDashboard.json + datasource: Prometheus + service: + type: ClusterIP + port: 8080 + targetPort: 3000 + portName: service + ingress: + enabled: true + annotations: + kubernetes.io/ingress.class: nginx + hosts: + - chart-example.local + path: /grafana diff --git a/nap/charts/prometheus/Chart.yaml b/nap/charts/prometheus/Chart.yaml deleted file mode 100644 index 134fdcd9f..000000000 --- a/nap/charts/prometheus/Chart.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- -apiVersion: v2 -name: prometheus -type: application -version: 1.0.0 -appVersion: "1.0.0" -dependencies: - - name: prometheus - version: 15.10.2 - repository: https://prometheus-community.github.io/helm-charts \ No newline at end of file diff --git a/nap/grafana.tf b/nap/grafana.tf new file mode 100644 index 000000000..6d965caf2 --- /dev/null +++ b/nap/grafana.tf @@ -0,0 +1,8 @@ +resource "helm_release" "grafana" { + name = format("%s-gfa-%s", local.project_prefix, local.build_suffix) + repository = "https://grafana.github.io/helm-charts" + chart = "grafana" + version = "6.31.1" + namespace = kubernetes_namespace.monitoring.metadata[0].name + values = [templatefile("./charts/grafana/values.yaml", { external_name = "${data.kubernetes_service_v1.nginx-service.status.0.load_balancer.0.ingress.0.hostname}"})] +} \ No newline at end of file diff --git a/nap/locals.tf b/nap/locals.tf index b140a5a53..ab5dde1d4 100644 --- a/nap/locals.tf +++ b/nap/locals.tf @@ -1,5 +1,6 @@ locals { project_prefix = data.tfe_outputs.infra.values.project_prefix + build_suffix = data.tfe_outputs.infra.values.build_suffix aws_region = data.tfe_outputs.infra.values.aws_region host = data.tfe_outputs.eks.values.cluster_endpoint cluster_ca_certificate = data.tfe_outputs.eks.values.kubeconfig-certificate-authority-data diff --git a/nap/namespace.tf b/nap/namespace.tf index 095f15a06..8bd8637aa 100644 --- a/nap/namespace.tf +++ b/nap/namespace.tf @@ -3,3 +3,8 @@ resource "kubernetes_namespace" "nginx-ingress" { name = "nginx-ingress" } } +resource "kubernetes_namespace" "monitoring" { + metadata { + name = "monitoring" + } +} \ No newline at end of file diff --git a/nap/nap.tf b/nap/nap.tf index dba0b5e1f..2924d53bc 100644 --- a/nap/nap.tf +++ b/nap/nap.tf @@ -1,5 +1,5 @@ resource "helm_release" "nginx-plus-ingress" { - name = local.project_prefix + name = format("%s-nap-%s", local.project_prefix, local.build_suffix) repository = "https://helm.nginx.com/stable" chart = "nginx-ingress" namespace = kubernetes_namespace.nginx-ingress.metadata[0].name diff --git a/nap/prometheus.tf b/nap/prometheus.tf new file mode 100644 index 000000000..663a84dd5 --- /dev/null +++ b/nap/prometheus.tf @@ -0,0 +1,8 @@ +resource "helm_release" "prometheus" { + name = format("%s-pro-%s", local.project_prefix, local.build_suffix) + repository = "https://prometheus-community.github.io/helm-charts" + chart = "prometheus" + #version = "15.10.2" + namespace = kubernetes_namespace.monitoring.metadata[0].name + values = [file("./charts/prometheus/values.yaml")] +} \ No newline at end of file