Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Prometheus and Grafana charts to EKS #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions cdk/big-data-stack/stacks/eks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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.
Expand Down