From 76b2c0e57f5f65a6cde4b46be2e8bac4e78b48ef Mon Sep 17 00:00:00 2001 From: "Damon P. Cortesi" Date: Thu, 20 May 2021 16:12:02 -0700 Subject: [PATCH] Add Prometheus and Grafana charts to EKS --- cdk/big-data-stack/stacks/eks.py | 48 ++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/cdk/big-data-stack/stacks/eks.py b/cdk/big-data-stack/stacks/eks.py index 65a1cdd..c294727 100644 --- a/cdk/big-data-stack/stacks/eks.py +++ b/cdk/big-data-stack/stacks/eks.py @@ -69,6 +69,10 @@ def __init__( # TODO: Make this optional # self.enable_airflow() + # Let's do some monitoring! (but not by default...) + # self.enable_prometheus() + # self.enable_grafana() + # This is emr-specific, but we have to do it here to prevent circular dependencies self.map_iam_to_eks() @@ -157,6 +161,50 @@ def add_emr_containers_for_airflow(self) -> eks.ServiceAccount: return sa + def enable_grafana(self, namespace: str = "grafana"): + chart = self.cluster.add_helm_chart( + "grafana", + namespace=namespace, + chart="grafana", + repository="https://grafana.github.io/helm-charts", + version="6.9.1", + values={ + "fullnameOverride": "grafana-dashboard", + "adminPassword": "admin", + "persistence": {"storageClassName": "gp2", "enabled": "true"}, + "datasources": { + "datasources.yaml": { + "apiVersion": 1, + "datasources": [ + { + "name": "Prometheus", + "type": "prometheus", + "url": "http://prometheus-server.prometheus.svc.cluster.local", + "access": "proxy", + "isDefault": "true", + } + ], + } + }, + }, + ) + + def enable_prometheus(self, namespace: str = "prometheus"): + chart = self.cluster.add_helm_chart( + "prometheus", + namespace=namespace, + chart="prometheus", + repository="https://prometheus-community.github.io/helm-charts", + version="14.0.0", + values={ + "alertmanager": {"persistentVolume": {"storageClass": "gp2"}}, + "server": { + "fullnameOverride": "prometheus-server", + "persistentVolume": {"storageClass": "gp2"}, + }, + }, + ) + def enable_airflow(self, namespace: str = "airflow"): # While `add_helm_chart` will create the namespace for us if it doesn't exist, # we have to create it here because we need to create a service role for emr-containers.