Info This page describes deploying a standalone Flink cluster on top of Kubernetes.
You can find more information on native Kubernetes deployments here.
Setup Kubernetes
Please follow Kubernetes’ setup guide in order to deploy a Kubernetes cluster.
If you want to run Kubernetes locally, we recommend using MiniKube.
Note: If using MiniKube please make sure to execute minikube ssh 'sudo ip link set docker0 promisc on' before deploying a Flink cluster.
Otherwise Flink components are not able to self reference themselves through a Kubernetes service.
Moreover, you could use the following command below to submit jobs to the cluster:
Create a NodePort service on the rest service of jobmanager:
Run kubectl create -f jobmanager-rest-service.yaml to create the NodePort service on jobmanager. The example of jobmanager-rest-service.yaml can be found in appendix.
Run kubectl get svc flink-jobmanager-rest to know the node-port of this service and navigate to http://<public-node-ip>:<node-port> in your browser.
If you use minikube, you can get its public ip by running minikube ip.
Similarly to the port-forward solution, you could also use the following command below to submit jobs to the cluster:
You can also access the queryable state of TaskManager if you create a NodePort service for it:
Run kubectl create -f taskmanager-query-state-service.yaml to create the NodePort service on taskmanager. The example of taskmanager-query-state-service.yaml can be found in appendix.
In order to terminate the Flink cluster, delete the specific Session or Job cluster components
and use kubectl to terminate the common components:
kubectl delete -f jobmanager-service.yaml
kubectl delete -f flink-configuration-configmap.yaml
# if created then also the rest service
kubectl delete -f jobmanager-rest-service.yaml
# if created then also the queryable state service
kubectl delete -f taskmanager-query-state-service.yaml
Deploy Session Cluster
A Flink Session cluster is executed as a long-running Kubernetes Deployment.
Note that you can run multiple Flink jobs on a Session cluster.
Each job needs to be submitted to the cluster after the cluster has been deployed.
A Flink Session cluster deployment in Kubernetes has at least three components:
The args attribute in the jobmanager-job.yaml has to specify the main class of the user job.
See also how to specify the JobManager arguments to understand
how to pass other args to the Flink image in the jobmanager-job.yaml.
The job artifacts should be available from the job-artifacts-volume in the resource definition examples.
The definition examples mount the volume as a local directory of the host assuming that you create the components in a minikube cluster.
If you do not use a minikube cluster, you can use any other type of volume, available in your Kubernetes cluster, to supply the job artifacts.
Alternatively, you can build a custom image which already contains the artifacts instead.
jobmanager-rest-service.yaml. Optional service, that exposes the jobmanager rest port as public Kubernetes node’s port.
taskmanager-query-state-service.yaml. Optional service, that exposes the TaskManager port to access the queryable state as a public Kubernetes node’s port.