-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add a script to install Grafana on the EKS cluster * Add annotation to configmap to create folder structure
- Loading branch information
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# https://github.com/grafana/helm-charts/blob/main/charts/grafana/README.md#configuration | ||
datasources: | ||
datasources.yaml: | ||
apiVersion: 1 | ||
datasources: | ||
- name: InfluxDB | ||
type: influxdb | ||
access: proxy | ||
url: http://influxdb.default.svc.cluster.local:8086 | ||
database: testground | ||
uid: ds_influxdb | ||
isDefault: true | ||
grafana.ini: | ||
auth.anonymous: | ||
enabled: true | ||
org_role: Admin | ||
sidecar: | ||
dashboards: | ||
enabled: true | ||
folderAnnotation: grafana_dashboard_folder | ||
provider: | ||
foldersFromFilesStructure: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script deploys Grafana resources to the EKS cluster. | ||
# Our custom dashboards and datasource settings are preset to the deployed grafana instance. | ||
|
||
set -Eeuo pipefail | ||
|
||
create_configmap() { | ||
# The name of configmap must consist of lower case alphanumeric characters, '-' or '.' | ||
name="$1_$(basename -s ".json" "$2")" | ||
name=$(echo "$name" | tr "[:upper:]" "[:lower:]" | tr "_" "-") | ||
kubectl create configmap "dashboard-$name" --from-file="$2" | ||
kubectl label configmap "dashboard-$name" grafana_dashboard=1 | ||
kubectl annotate configmap "dashboard-$name" grafana_dashboard_folder="$1" | ||
} | ||
|
||
create_configmaps() { | ||
find "${project_root}/$1/dashboards/" -name "*.json" -type f | while read -r fname | ||
do | ||
create_configmap "$1" "${fname}" | ||
done | ||
} | ||
|
||
readonly script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P) | ||
readonly project_root=$(cd "${script_dir}/../../" &>/dev/null && pwd -P) | ||
|
||
# Create configmaps for dashboards | ||
# https://github.com/grafana/helm-charts/blob/main/charts/grafana/README.md#sidecar-for-dashboards | ||
create_configmaps "censoring" | ||
create_configmaps "eth_consensus" | ||
create_configmaps "scoring" | ||
|
||
# Install Grafana | ||
echo -e "Now obtaining the helm charts and installing Grafana. This might take a few minutes.\n" | ||
helm repo add grafana https://grafana.github.io/helm-charts | ||
helm repo update | ||
helm install gossipsub-grafana grafana/grafana -f "${script_dir}/grafana-variables.yaml" | ||
|
||
echo -e "\n=============================================================================================================" | ||
echo -e "You may run the following in order to obtain the grafana pod name:" | ||
echo -e 'export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=grafana,app.kubernetes.io/instance=gossipsub-grafana" -o jsonpath="{.items[0].metadata.name}")\n' | ||
echo -e "You may now run the following in order to port-forward and access the grafana dashboard from your laptop by opening 'localhost:3000' in your browser:" | ||
echo -e 'kubectl --namespace default port-forward $POD_NAME 3000' | ||
echo -e "============================================================================================================\n" |