Hey there folks :wave: I was using Flink with my ...
# troubleshooting
p
Hey there folks 👋 I was using Flink with my custom helm templating and I decided to migrate to the Flink K8s Operator. I’m building my own docker image and publishing it. I override the image following this example. I’m using the mode standalone mode (
mode: standalone
) to be able to use Flink in the reactive mode (
scheduler-mode: reactive
). My task manager pod has my modifications (
/opt/flink/usrlib/
jars) but my job manager pod seems to have the same content as the default flink image. Do you know what could lead to this? My deployment is
Copy code
apiVersion: <http://flink.apache.org/v1beta1|flink.apache.org/v1beta1>
kind: FlinkDeployment
metadata:
  name: {{ template "flink-application-mode.name" . }}
spec:
  image: "{{ .Values.imageRepository }}/{{ .Values.imageName }}:{{ .Values.imageTag }}"
  imagePullPolicy: IfNotPresent
  serviceAccount: {{ .Values.serviceAccountName }}
  flinkVersion: v1_16
  podTemplate:
    spec:
      containers:
        - name: flink-main-container
          env:
            - name: APPLICATION_CREDENTIALS
              value: /secrets/credentials.json
          volumeMounts:
            ...
      volumes:
        ...
  flinkConfiguration:
    scheduler-mode: reactive
  jobManager:
    replicas: 1
    resource:
      {{- toYaml .Values.resources.jobmanager.requests | nindent 6 }}
  taskManager:
    replicas: {{ .Values.replicaCount }}
    resource:
      {{- toYaml .Values.resources.taskmanager.requests | nindent 6 }}
  mode: standalone
  job:
    jarURI: local:///opt/flink/usrlib/custom.jar
    entryClass: {{ required "A valid .Values.jobmanager.entryClass entry required!" .Values.jobmanager.entryClass }}
    parallelism: 2
    upgradeMode: savepoint # last-state OR stateless
g
Do you get the same problem with
native
mode?
By the way you might want to check out the Autoscaler , that is an excellent alternative to the reactive mode and it actually provides real scaling capabilities 🙂
The autoscaler works in
native
mode currently (due to the limitations of standalone setup) , and in general I recommend that for prod over standalone + reactive
The current (yet to be released) version on the main branch has some excellent features
p
Hey @Gyula Fóra Thank you for the reply. I did not know about the
native
mode. What is the difference between it and
standalone
? I’m sticking to
standalone
because it is what I had before. But if it does sort my issues I’m happy to move 😛 Does the
native
mode enables manual replica changes as well? I’m sticking with
reactive
to be sure if I upscale/downscale taskmanagers, they do rebalance without a partition reattribution (I’m mainly using Kafka).
and in general I recommend that for prod over standalone + reactive
it means they works “the same”, am I getting this right?
due to the limitations of standalone setup
Which limitations are we talking about? Thnak you again for the support 🤝
I noticed when using
native
a single flink pod is created. Is this the expected behaviour?
g
Native is the default mode for the operator. It uses the Flink native Kubernetes integration which automatically creates taskmanager pods individually on-demand.
I don’t really understand why you want to use the standalone mode 🙂 I think in general native is more flexible and also works with the autoscaler built into the operator
p
In my case I was setting the replicas manually. and the instruction on the docs is to use standalone when using Flink in application mode. And reactive to be able to upscale/downscale tasknmanagers on demand (manually tho)
g
What docs are you referring to?
p
Here and
reactive
is only supported by
standalone
(otherwise the deployment breaks saying it only is supported by it)
g
okay, let me put it this way. I am 99% sure that you don’t need the reactive mode
especially if you are using the Flink Kubernetes Operator
✅ 1
p
Fair. I’ll try with the
native
mode. Do you mind if I ping you in this thread later on? Thank you for chiming in
g
The reactive mode was created at a time before the Flink Kubernetes Operator. It allowed the job to adjust to the cluster available resources. But this is not needed with the operator. You change you deployment yaml (
spec.job.parallelism
) and the entire purpose of the operator that it knows how to create more reasources and upgrade your job
🙌 1
this makes the reactive mode an unnecessary complication and it’s much better to use the simpler and I believe more robust native deployment mode
We also have the Job Autoscaler component which actually monitors kafka lag and utilization metrics and automatically changes job parallelism as the load changes.
🙌 1
p
So the
native
mode made the trick indeed. I’m setting
taskManager.replicas
to
1
and
job.parallelism
to
32
(the kafka topic I’m reading has 32 partitions). I was expecting the operator to spin up a single task manager, but it is spinning 16 instances don’t matter how I change the
job.parallelism
or
taskManager.replicas
. Do you guys know if this is the expected behaviour indeed? And if not
taskManager.replicas
, how should I limit the replicas of the task manager using Flink k8s operator? PS: I’m also posting outside of the thread because it is another problem 😄
s
This may be due to the scheduler-mode: reactive setting you have specified: https://nightlies.apache.org/flink/flink-docs-master/docs/deployment/elastic_scaling/#configuration
g
Task manager replicas takes no effect in native mode because it's automatically computed based on parallelism and number of task slots config of the tm
The default num slots is 1 so for 32 parallelism you get 32 tms
You can configure the slots in the flink configuration
p
I changed back to
standalone
mode. The trick with the JM was this piece of code here. To prevent this behaviour, I mounted a configmap volume using a
subpath
inside
$FLINK_HOME/usrlib/
to prevent a new volume to be mounted there. Thank you @Gyula Fóra for the support on the
native
mode.