Skip to content

Example setup of Flink cluster on Kubernetes with service discovery on Prometheus.

Notifications You must be signed in to change notification settings

wzorgdrager/flink-k8s

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flink K8s setup with Prometheus service discovery

This repository hosts manifests to configure a Kubernetes cluster with Flink monitored by Prometheus and Grafana using service discovery. Flink instances are automatically recognized and scraped by Prometheus.

The Docker image used in this setup can be found here.

Prerequisites

  • Kubernetes setup with kubectl installed.

TL;DR

git clone https://github.com/wzorgdrager/flink-k8s
kubectl apply -R -f ./flink-k8s/
kubectl port-forward -n monitoring service/grafana 3000:3000

Access Grafana Flink Dashboard on localhost:3000. This might take a few minutes.

Grafana login details
username: flink
password: flink-awesome

Installation

Clone the repository and apply all configurations:

git clone https://github.com/wzorgdrager/flink-k8s
cd flink-k8s
kubectl apply -f ./01-prometheus/
kubectl apply -f ./02-flink/
kubectl apply -f ./03-grafana/

This deploys a prometheus instance, a grafana instance and a Flink cluster with one JobManager and two TaskManagers (consisting of 16 taskslots each). Flink is configured and deployed to expose (Prometheus) metrics on port 9999 for each Job and TaskManager. Prometheus scrapes Kubernetes endpoints based on a JobManager service and headless TaskManager service routing to the correct metric endpoints. See architecture for a global view. After deploying all the manifests:

  • The JobManager can be accessed by port-forwarding it:
    kubectl port-forward -n flink service/flink-jobmanager 8081:8081
    Now it runs on localhost.
  • The Grafana dashboard can be accessed by port-forwarding as well:
    kubectl port-forward -n monitoring service/grafana 3000:3000
    Now it runs on localhost.
    Username: flink, password: flink-awesome. A Flink dashboard has been imported already. It should look like this:
    grafana

To see the service discovery working scale the TM instances from two to four:
kubectl -n flink scale deployment flink-taskmanager --replicas=4:

You can see these instances pop-up on the Grafana dashboard:
after_scaling

Architecture

architecture

References

Most manifests in this repository are based on the following sources:

About

Example setup of Flink cluster on Kubernetes with service discovery on Prometheus.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published