Kubernetes / Monitoring / Sponsored / Contributed

Using Grafana to Monitor Cloud Foundry Objects and Apps Running on Kubernetes

5 Mar 2021 9:15am, by

Ram Iyengar
Ram is an engineer by practice and an educator at heart. He was (cf) pushed into technology evangelism along his journey as a developer and hasn’t looked back since! He enjoys helping engineering teams around the world discover new and creative ways to work.

Following up on our earlier tutorial about Cloud Foundry monitoring with Prometheus, this post is about taking the next step — after working with Prometheus — which is Grafana. A lot of engineers who responded to the earlier article mentioned that they wanted to know about the support that CF-for-k8s has for Grafana.

This tutorial will serve as a basis for making use of Grafana and Prometheus with your CF-for-k8s instances. You can customize the Grafana dashboards and employ as much telemetry as you’d like in your apps, and then send them to your Prometheus installation.

Generally speaking, application performance is a key component of delivering the best user experience to the end users of a software application. When using PaaS tools or Kubernetes-based infrastructure (or any other abstraction for that matter), there is scope for introducing “unknown unknowns” into software components running on production. So a robust monitoring stack is critical to help prevent and troubleshoot incidents in production.

Being data-driven and communicating visually are two core tenets of engineering teams — especially in relation to telemetry, monitoring and observability. Grafana helps thousands of engineering teams use data sources to build dashboards, which provide insight into how applications and infrastructure are performing.

The Cloud Foundry community has taken a batteries-included approach to making Grafana and Prometheus available to its developer users. When installing cf-for-k8s, including a couple of additional config files will deploy both Prometheus and Grafana to the Kubernetes cluster. Using kubectl and port-forwarding the connection from a local port to the pod allows users to access the Prometheus or Grafana instance.

Let’s quickly take a look at the install steps:

0. Prerequisites:

1. Connect your local kubectl context to the Google Cloud Kubernetes Cluster.

2. Clone the repo at cf-k8s-prometheus. This repo will have the config files needed for the deployment.

3. Clone the repo for the cf-for-k8s deployment. This repo contains all the files needed to deploy the application.

4. Make use of the auto-generate script included in the cf-for-k8s repo to generate the YAML template to be used.

./hack/generate-values.sh -d 35.192.46.62.xip.io > /home/ram/tempdir/cf-values.yml

Once generated, add credentials to an OCI-compliant container registry.

vi /home/ram/tempdir/cf-values.yml

5. Next, use ytt to generate the final declarative template that will be used for deploying CF_for-K8s on the Kubernetes infrastructure.

6. Deploy CF-for-K8s to your infrastructure using the YAML file generated.

7. Assign a static IP to the Kubernetes cluster so that it can be accessed from across the internet.

8. Run the following checks to ensure that the installation has completed successfully.

9. Copy the Grafana pod name and use it with the kubectl port forward command. This will allow you to access the Grafana server from your machine.

10. Copy the Prometheus pod name and use it with the kubectl port forward command. This will allow you to access Prometheus from your machine.

A final note: Support for Grafana within CF-for-k8s is currently in the experimental stage. There are a few rough edges the community is currently polishing. One of the most pertinent issues is a persistent Grafana instance. There are also some open queries about forwarding telemetry to existing Prometheus and Grafana instances, which the community is working on as well.

To join the conversation, you can use the CloudFoundry Slack — specifically, the #logging-and-metrics channel. We appreciate all levels of participation, but especially input from our users is extremely valuable to us. You can also reach us via our Twitter handle, @cloudfoundry.

Lead image via Pixabay.