Apache Flink® Stateful Functions is an API for building distributed stateful applications.
10K+
Stateful Functions is an API that simplifies building distributed stateful applications, powered by Apache Flink®. It’s based on functions with persistent state that can interact dynamically with strong consistency guarantees.
Learn more about Stateful Functions at https://flink.apache.org/stateful-functions.html.
The recommended deployment mode for Stateful Functions applications is to build a Docker image on top of this base image. This way, user code does not need to package any Apache Flink or Stateful Functions components.
This base image allows you to package your applications with all the necessary runtime dependencies quickly.
Below is an example Dockerfile for building a Stateful Functions application image with both an embedded module and a remote module for an application called my-statefun-app:
FROM flink-statefun
RUN mkdir -p /opt/statefun/modules/my-statefun-app
RUN mkdir -p /opt/statefun/modules/remote
COPY my-statefun-app*jar /opt/statefun/modules/my-statefun-app/
COPY module.yaml /opt/statefun/modules/remote/module.yaml
With the image ready, you can now deploy the application. The instructions below assume that your built application image is called my-statefun-app.
You can run a master for your application by doing:
$ docker run -e "ROLE=master" -e "MASTER_HOST=localhost" -d -t my-statefun-app
Afterwards, you can also run a worker:
$ docker run -e "ROLE=worker" -e "MASTER_HOST=localhost" -d -t my-statefun-app
With Docker Compose, you can also create a full Stateful Functions application deployment:
version: "2.1"
services:
master:
image: my-statefun-app
expose:
- "6123"
ports:
- "8081:8081"
environment:
- ROLE=master
- MASTER_HOST=master
worker:
image: my-statefun-app
expose:
- "6121"
- "6122"
depends_on:
- master
links:
- "master:master"
environment:
- ROLE=worker
- MASTER_HOST=master
and just run docker-compose up.
To scale the cluster up or down to N workers, do:
$ docker-compose scale worker=<N>
You can find here a full example of a Stateful Functions application based on Docker Compose.
These command line arguments are often used when running a master:
-s, --fromSavepoint: Path to a savepoint to restore the application from-p, --parallelism: The parallelism with which to run the applicationROLE: The role to run with, either master or worker (default: worker)MASTER_HOST: The hostname of the application master (default: localhost)Since Stateful Functions applications are executed by an Apache Flink cluster, you can configure the Flink processes (JobManagers and TaskManagers) by bundling a Flink configuration flink-conf.yaml file in your application image, at $FLINK_HOME/conf/flink-conf.yaml.
See the full list of Apache Flink configurations for all available settings.
These are the default ports used by this base image:
80816123 (when running a master for your application)6122 (when running a worker for your application)6121 (when running a worker for your application)This repository is available on github.com/apache/flink-statefun-docker, and the official build is on Docker Hub.
This repository is maintained by members of the Apache Flink community.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Content type
Image
Digest
Size
526.2 MB
Last updated
over 5 years ago
docker pull ververica/flink-statefun