Sign inSign up

ververica/flink-statefun

By ververica

•Updated over 5 years ago
Archived

Apache Flink® Stateful Functions is an API for building distributed stateful applications.

Image
0

10K+

ververica/flink-statefun repository overview

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⁠.

Stateful Functions Logo

⁠How to use this Docker image

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.

⁠Packaging application images

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

⁠Deploying applications

With the image ready, you can now deploy the application. The instructions below assume that your built application image is called my-statefun-app.

⁠Running a master or a worker

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

⁠Running a cluster using Docker Compose

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>

⁠Full example

You can find here⁠ a full example of a Stateful Functions application based on Docker Compose.

⁠Configuration

⁠Command line arguments

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 application
⁠Important environment variables
  • ROLE: 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.

⁠Default ports

These are the default ports used by this base image:

  • The Flink Web Client runs on port 8081
  • Flink JobManager RPC port 6123 (when running a master for your application)
  • TaskManagers RPC port 6122 (when running a worker for your application)
  • TaskManagers Data port 6121 (when running a worker for your application)

⁠About this repository

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.

⁠License

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

Tag summary

Content type

Image

Digest

Size

526.2 MB

Last updated

over 5 years ago

docker pull ververica/flink-statefun