Installing Grafana on your Kubernetes Cluster
Since Kubernetes has now been installed, we can continue to run a demonstration! For this demonstration we are going to deploy the following:
So let's get started!
Installing Dapr
To install Dapr we can utilize its install.sh
script which we execute:
wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash
Whereafter we can run dapr --version
to validate that it is installed:
# Output of dapr --version
CLI version: 1.2.0
Runtime version: n/a
Finally, we configure Dapr on our Kubernetes cluster by initializing it
dapr init -k
Which we again verify by running dapr status -k
# Output of dapr status -k
NAME NAMESPACE HEALTHY STATUS REPLICAS VERSION AGE CREATED
dapr-sentry dapr-system True Running 1 1.2.0 33s 2021-05-30 11:27.57
dapr-operator dapr-system True Running 1 1.2.0 33s 2021-05-30 11:27.57
dapr-dashboard dapr-system True Running 1 0.6.0 33s 2021-05-30 11:27.57
dapr-sidecar-injector dapr-system True Running 1 1.2.0 33s 2021-05-30 11:27.57
dapr-placement-server dapr-system True Running 1 1.2.0 32s 2021-05-30 11:27.58
Installing a Demo Application
kubectl create deployment kubernetes-bootcamp --image=gcr.io/google-samples/kubernetes-bootcamp:v1
Grafana Dashboard
Installing Grafana is a bit more complicated as it requires a store to gather our telemetry. For this we will be utilizing Prometheus.
Install Prometheus
For configuring Prometheus, we utilize the commands below that will set it up with a persistent volume.
💡 To disable persistent volumes, append--set alertmanager.persistentVolume.enable=false --set pushgateway.persistentVolume.enabled=false --set server.persistentVolume.enabled=false
to the end of thehelm install
command.
# Create a dedicated namespace
kubectl create namespace dapr-monitoring
# Install Prometheus
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm install dapr-prom prometheus-community/prometheus -n dapr-monitoring
# Verify that it is running
kubectl get pods -n dapr-monitoring -w
Install Grafana
Since we have our store set-up, we can now install our dashboard
💡 We can again disable persistent volumes by appending--set persistence.enabled=false
to thehelm install
command
# Install Grafana
helm repo add grafana https://grafana.github.io/helm-charts
helm install grafana grafana/grafana -n dapr-monitoring
# Verify that it is running
kubectl get pods -n dapr-monitoring -w
Grafana Admin Password
Once Grafana is up and running, gather its admin password by running the command below
kubectl get secret --namespace dapr-monitoring grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
Access Grafana
Now Grafana is up and running, we can access it by port forwarding its port ot our local system.
# Forward Grafana from our cluster to localhost
kubectl port-forward svc/grafana 8080:80 -n dapr-monitoring
# Open browser at:
# http://localhost:8080/
We can now login with:
- Username:
admin
- Password: See Grafana Admin Password (
kubectl get secret --namespace dapr-monitoring grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
)
Configure Grafana with Prometheus
Finally we need to set-up our Grafana Dashboard. Luckily for us, Dapr provides some out-of-the-box dashboards
To start, we load the dashboard and add our Prometheus Server
As a URL we fetch the Dapr Prometheus Server url by viewing the services and finding the name of the deployment. Which will become <DEPLOYMENT_NAME>.<NAMESPACE>
kubectl get svc -n dapr-monitoring
In our case this becomes http://dapr-prom-prometheus-server.dapr-monitoring
Now we can Save & Test
and go towads the import screen, where we import the dashboard that we copied from ]Dapr its GitHub page.](https://raw.githubusercontent.com/dapr/dapr/master/grafana/grafana-system-services-dashboard.json)
If everything is done correctly, we can now see our monitoring
Member discussion