How To Setup Grafana On Kubernetes

How To Setup Grafana On Kubernetes

kubernetes-monitoring

 

Grafana is an open-source lightweight dashboard tool. It can be integrated with many data sources like Prometheus, AWS cloud watch, Stackdriver, etc.

This tutorial explains the Grafana setup on a Kubernetes cluster. You can create dashboards on Grafana for all the Kubernetes metrics through prometheus.

Lets get started with the setup.

Step 1: Create file named grafana-datasource-config.yaml

Copy the following contents.

Note: The following datasource configuration is for prometheus. If you have more data sources, you can add more data sources with different YAMLs under data section.

Step 2: Create the configmap using the following command.

Step 3: Create a file named deployment.yaml

Copy the following contents

Step 4: Create the deployment

Step 5: Create a service file named service.yaml

Copy the following contents. This will expose Grafana on NodePort 32000. You can also expose it using ingress or a Loadbalancer based on your requirement.

Step 6: Create the service.

Now you should be able to access the Grafana dashboard using any node IP on port 3200. Use the following default username and password to login. Once you login with default credentials, it will prompt to change the default password.

Setup Kubernetes Dashbaords

There are many prebuilt Grafana templates available for various data sources. You can check out the templates from here.

Setting up a dashboard from a template is pretty easy. Follow the steps given below to setup a dashboard to monitor kubernetes deployments.

Step 1: Get the template ID from grafana public template. as shown below.

Step 2: Head over to grafana and select the import option.

Step 3: Enter the dashboard ID you got it step 1

Step 4: Grafana will automatically fetch the template from Grafana website. You can change the values as shown in the image below and click import.

You should see the dashboard immediately.

Conclusion

Grafana is a very powerful tool when it comes to dashboards. It is used by many organisations to monitor their workloads.

Tech Chronicles