Accessing Flink’s Web UI
The Flink Kubernetes Operator, by default, does not change the way the native kubernetes integration exposes the Flink Web UI.
Ingress
Beyond the native options, the Operator also supports creating Ingress entries for external UI access. Ingress generation can be turned on by defining the ingress
field in the FlinkDeployment
:
metadata:
namespace: default
name: advanced-ingress
spec:
image: flink:1.17
flinkVersion: v1_17
ingress:
template: "flink.k8s.io/{{namespace}}/{{name}}(/|$)(.*)"
className: "nginx"
annotations:
nginx.ingress.kubernetes.io/rewrite-target: "/$2"
The ingress
specification defines a mandatory template
field and two optional fields className
and annotations
. When the CR is submitted, the Operator substitutes the template variables from metadata and creates an Ingress entry on the Kubernetes cluster.
Given the example above the Flink UI could be accessed at https://flink.k8s.io/default/advanced-ingress/ and the generated Ingress entry would be:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$2
name: advanced-ingress
namespace: default
spec:
ingressClassName: nginx
rules:
- host: flink.k8s.io
- http:
paths:
- backend:
service:
name: advanced-ingress-rest
port:
number: 8081
path: /default/advanced-ingress(/|$)(.*)
pathType: ImplementationSpecific
Note: Flink Web UI is built with the popular Angular framework and uses relative path to load static resources, hence the endpoint URL must end with trailing a
/
when accessing it from browsers through a proxy otherwise the main page appears as blank. In order to support accessing base URLs without a trailing/
the URLs can be redirected. When using NGINX as ingress-controller this can be achieved by adding an extra annotation to the Ingress definition:
nginx.ingress.kubernetes.io/configuration-snippet: |
if ($uri = "/default/advanced-ingress") {rewrite .* $1/default/advanced-ingress/ permanent;}
Beyond the example above the Operator understands other template formats too:
Simple domain based routing:
ingress:
template: "{{name}}.{{namespace}}.flink.k8s.io"
This example requires that anything *.flink.k8s.io
must be routed to the Ingress Controller with a wildcard DNS entry:
kubectl get ingress -A
NAMESPACE NAME CLASS HOSTS ADDRESS PORTS AGE
default sample-job nginx sample-job.default.flink.k8s.io 192.168.49.2 80 30m
The Flink Web UI can be accessed at https://sample-job.default.flink.k8s.io
Simple path based routing:
ingress:
template: "/{{namespace}}/{{name}}(/|$)(.*)"
annotations:
nginx.ingress.kubernetes.io/rewrite-target: "/$2"
This example requires no DNS entries.
kubectl get ingress -A
NAMESPACE NAME CLASS HOSTS ADDRESS PORTS AGE
default sample-job nginx * localhost 80 54m
The Flink Web UI can be accessed at https://localhost/default/sample-job/
Note: All the examples were created on a minikube cluster. Check the description for enabling the NGINX Ingress Controller on minikube.