Quick Start

This document provides a quick introduction to using the Flink Kubernetes Operator. Readers of this document will be able to deploy the Flink operator itself and an example Flink job to a local Kubernetes installation.

Prerequisites

We assume that you have a local installations of the following:

  1. docker
  2. kubernetes
  3. helm

So that the kubectl and helm commands are available on your local system.

For docker we recommend that you have Docker Desktop installed and configured with at least 8GB of RAM. For kubernetes minikube is our choice, at the time of writing this we are using version v1.25.3 (end-to-end tests are using the same version). You can start a cluster with the following command:

  1. minikube start --kubernetes-version=v1.25.3
  2. 😄 minikube v1.28.0 on Darwin 13.0.1
  3. Automatically selected the docker driver. Other choices: hyperkit, ssh
  4. 📌 Using Docker Desktop driver with root privileges
  5. 👍 Starting control plane node minikube in cluster minikube
  6. 🚜 Pulling base image ...
  7. 🔥 Creating docker container (CPUs=2, Memory=4000MB) ...
  8. 🐳 Preparing Kubernetes v1.25.3 on Docker 20.10.20 ...
  9. Generating certificates and keys ...
  10. Booting up control plane ...
  11. Configuring RBAC rules ...
  12. 🔎 Verifying Kubernetes components...
  13. Using image gcr.io/k8s-minikube/storage-provisioner:v5
  14. 🌟 Enabled addons: default-storageclass, storage-provisioner
  15. 🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

We also recommend k9s as GUI for kubernetes, but it is optional for this quickstart guide.

Deploying the operator

Install the certificate manager on your Kubernetes cluster to enable adding the webhook component (only needed once per Kubernetes cluster):

  1. kubectl create -f https://github.com/jetstack/cert-manager/releases/download/v1.8.2/cert-manager.yaml

In case the cert manager installation failed for any reason you can disable the webhook by passing --set webhook.create=false to the helm install command for the operator.

Now you can deploy the selected stable Flink Kubernetes Operator version using the included Helm chart:

  1. helm repo add flink-operator-repo https://downloads.apache.org/flink/flink-kubernetes-operator-1.8.0/
  2. helm install flink-kubernetes-operator flink-operator-repo/flink-kubernetes-operator

To find the list of stable versions please visit https://flink.apache.org/downloads.html

The Helm chart by default points to the ghcr.io/apache/flink-kubernetes-operator image repository. If you have connectivity issues or prefer to use Dockerhub instead you can use --set image.repository=apache/flink-kubernetes-operator during installation.

You may verify your installation via kubectl and helm:

  1. kubectl get pods
  2. NAME READY STATUS RESTARTS AGE
  3. flink-kubernetes-operator-fb5d46f94-ghd8b 2/2 Running 0 4m21s
  4. helm list
  5. NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
  6. flink-kubernetes-operator default 1 2022-03-09 17 (tel:12022030917):39:55.461359 +0100 CET deployed flink-kubernetes-operator-1.8.0 1.8.0

Once the operator is running as seen in the previous step you are ready to submit a Flink job:

  1. kubectl create -f https://raw.githubusercontent.com/apache/flink-kubernetes-operator/release-1.8/examples/basic.yaml

You may follow the logs of your job, after a successful startup (which can take on the order of a minute in a fresh environment, seconds afterwards) you can:

  1. kubectl logs -f deploy/basic-example
  2. 2022-03-11 21:46:04,458 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Triggering checkpoint 206 (type=CHECKPOINT) @ 1647035164458 for job a12c04ac7f5d8418d8ab27931bf517b7.
  3. 2022-03-11 21:46:04,465 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Completed checkpoint 206 for job a12c04ac7f5d8418d8ab27931bf517b7 (28509 bytes, checkpointDuration=7 ms, finalizationTime=0 ms).
  4. 2022-03-11 21:46:06,458 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Triggering checkpoint 207 (type=CHECKPOINT) @ 1647035166458 for job a12c04ac7f5d8418d8ab27931bf517b7.
  5. 2022-03-11 21:46:06,483 INFO org.apache.flink.runtime.checkpoint.CheckpointCoordinator [] - Completed checkpoint 207 for job a12c04ac7f5d8418d8ab27931bf517b7 (28725 bytes, checkpointDuration=25 ms, finalizationTime=0 ms).

To expose the Flink Dashboard you may add a port-forward rule or look the ingress configuration options:

  1. kubectl port-forward svc/basic-example-rest 8081

Now the Flink Dashboard is accessible at localhost:8081.

In order to stop your job and delete your FlinkDeployment you can:

  1. kubectl delete flinkdeployment/basic-example