This repo is very similar to dittybopper, this will be used to help users visualize their krkn runs as well as general data and performance of their clusters
cd krkn-visualize
export ES_URL=<elasticsearch url>
export ES_USERNAME=<elasticsearch username>
export ES_PASSWORD=<elasticsearch password>
NOTE: The deploy with the elastic search variables set will create the elasticsearch data sources but the index patterns
On Kubernetes Cluster
./deploy.sh
On OpenShift Cluster
./deploy.sh -c oc
Deploys a mutable Grafana pod with default dashboards for monitoring system submetrics during workload/benchmark runs.
Options:
-c <kubectl_cmd>: The command to use for k8s admin (defaults tokubectl).-n <namespace>: The namespace in which to deploy the Grafana instance (defaults tokrkn-visualize).-p <grafana_pass>: The password to configure for the Grafana admin user (defaults toadmin).-i <dash_path>: Import dashboard from given path. Using this flag will bypass the deployment process and only do the import to an already-running Grafana pod. Can be a local path or a remote URL beginning with http.-d: Delete an existing deployment (namespace and Grafana).-t: The (t)prometheus url to use for the Prometheus datasource (if openshift will use https://prometheus-k8s.openshift-monitoring.svc.cluster.local:9091, if kuberenetes will use prometheus url in pod: prometheus-operated inmonitoringnamespace)b: The (b)earer token to use for the Prometheus datasource (if openshift will auto create a new token, don't need for prometheus in kubernetes )-h: Show help message and exit.
Example Usage:
./deploy.sh # Deploy Grafana in 'krkn-visualize' namespace with default password
./deploy.sh -n myns -p secret # Deploy in 'myns' namespace with custom password
./deploy.sh -i dashboard.json # Import dashboard to running Grafana
./deploy.sh -d # Delete deployment and namespaceTo manually set up a Prometheus datasource in Grafana using a Prometheus URL and bearer token from OpenShift:
-
Retrieve Prometheus URL and Bearer Token from OpenShift:
- Get the Prometheus route URL (for OpenShift monitoring, often called
prometheus-k8s):oc get route prometheus-k8s -n openshift-monitoring -o jsonpath="https://{.spec.host}{'\n'}" - Get the token for a user or service account with permission to access Prometheus:
Alternatively, log in as a user with sufficient rights and run:
oc sa get-token prometheus-k8s -n openshift-monitoring
oc whoami --show-token
- Get the Prometheus route URL (for OpenShift monitoring, often called
-
Add Prometheus Data Source in Grafana:
- Log into Grafana as an admin user.
- In the sidebar, hover over the gear icon (⚙️) and select Data Sources.
- Click Add data source.
- Select Prometheus as the data source type.
- In the HTTP section, set the URL to your OpenShift Prometheus URL (from step 1, including
https://). - In Auth section:
- Enable With Credentials.
- Set Auth Type to Bearer Token (if shown).
- If no dedicated field:
- Expand the HTTP Headers section.
- Add a custom header:
- Name:
Authorization - Value:
Bearer <PASTE-YOUR-TOKEN-HERE>
- Name:
- (Optional, but recommended) Set Skip TLS Verify to
trueif using self-signed OpenShift certs, or add the OpenShift CA cert. - Click Save & Test at the bottom of the page to verify the connection.
Tip:
If Grafana is running as a pod in your OpenShift cluster, you can mount a service account token file into the container for automated rotation (advanced; see OpenShift docs).
References:
After the grafana dashboard has been created, you'll need to add in data sources to connect to your local elasic search
You'll need to create 3 data sources connecting to krkn-telemetry, krkn-metrics and krkn-alerts indexes or the indexes you defined here
- Log in as admin user
- Find Configuration tab and click Data Sources
- Click new data source
- Add a name for the data source, be sure the name contains "Telemetry", "Metrics", and "Alerts" for the corresponding indexes so our dashboards can properly find them
- Add the URL of your elasticsearch
- Add authentication into elastic search
- Give the corresponding index name you're configuring under Elasticsearch details
- Remove the @ from before the timestamp field (Alerts needs created_at)
- Save & test
- Repeat for each index
- Create folder under assets
- Create panels.libsonnet, queries.libsonnet, and variables.libsonnet under the newly created folder
- Create jsonnet file under General or if its specific to kubernetes, k8s
- Run
make
Dockerfile.deploy packages deploy.sh into a container image, letting you deploy Grafana without installing any local dependencies. All deploy.sh CLI options are exposed as environment variables.
# Run `make build` first to generate the rendered dashboards, then build the image
make build
make build-deploy-image| Variable | deploy.sh flag | Default |
|---|---|---|
K8S_CMD |
-c |
kubectl |
GRAFANA_PASSWORD |
-p |
admin |
NAMESPACE |
-n |
krkn-visualize |
DELETE |
-d |
false |
PROMETHEUS_URL |
— | auto-detected |
PROMETHEUS_BEARER |
— | auto-fetched via oc |
ES_URL |
— | empty |
ES_USERNAME |
— | empty |
ES_PASSWORD |
— | empty |
KUBECONFIG |
— | /root/.kube/config |
Pick whichever approach fits your setup:
1. Mount to the default path (no extra env var needed):
docker run --rm -e K8S_CMD=oc \
-v ~/.kube/config:/root/.kube/config:ro \
krkn-visualize2. Mount a single kubeconfig file to a custom path:
docker run --rm -e K8S_CMD=oc \
-e KUBECONFIG=/kubeconfig \
-v /path/to/my/kubeconfig:/kubeconfig:ro \
krkn-visualize3. Mount your entire .kube directory (useful for multiple contexts):
docker run --rm -e K8S_CMD=oc \
-v ~/.kube:/root/.kube:ro \
krkn-visualize# Deploy on OpenShift, passing ES credentials from your local environment
# (-e VARNAME without a value reads the variable from your shell)
docker run --rm \
-e K8S_CMD=oc \
-e ES_URL \
-e ES_USERNAME \
-e ES_PASSWORD \
-v ~/.kube/config:/root/.kube/config:ro \
krkn-visualize
# Deploy on OpenShift with a custom password
docker run --rm \
-e K8S_CMD=oc \
-e GRAFANA_PASSWORD=secret \
-v ~/.kube/config:/root/.kube/config:ro \
krkn-visualize
# Delete an existing deployment
docker run --rm \
-e K8S_CMD=oc \
-e DELETE=true \
-v ~/.kube/config:/root/.kube/config:ro \
krkn-visualize
# Deploy on vanilla Kubernetes with a custom Prometheus URL
docker run --rm \
-e PROMETHEUS_URL=http://prometheus.monitoring.svc:9090 \
-v ~/.kube/config:/root/.kube/config:ro \
krkn-visualizeEdit import file to point to newly created rendered json. Note the grafana version needs to match the grafannot listed here, will hit loading errors if not
cd krkn-visualize
./import.sh -i ../rendered/<folder>/<dashboard_name>.json
Options:
-c <kubectl_cmd>: The command to use for k8s admin (defaults tokubectl).-n <namespace>: The namespace in which to deploy the Grafana instance (defaults tokrkn-visualize).-p <grafana_pass>: The password to configure for the Grafana admin user (defaults toadmin).-i <dash_path>: Import dashboard from given path. Using this flag will bypass the deployment process and only do the import to an already-running Grafana pod.-l <grafana_url>: Local grafana url to use when importing the dashboards, won't execute kubernetes commands-h: Show help message and exit.