<p>I am following <a href="https://ci.apache.org/projects/flink/flink-docs-stable/ops/deployment/kubernetes.html" rel="nofollow noreferrer">Flink Kubernetes Setup</a> to create a cluster, but it is unclear how can I provide <a href="https://ci.apache.org/projects/flink/flink-docs-stable/ops/config.html" rel="nofollow noreferrer">Flink configuration</a> to the cluster? e.g., I want to specify <code>jobmanager.heap.size=2048m</code>.</p>

Dagang
<p>According to the docs, all configuration has to be passed via a yaml configuration file.</p>

<p>It seems that <code>jobmanager.heap.size</code> is a common option that can be configured.  </p>

<p>That being said, the approach on kubernetes is a little different when it comes to providing this configuration file.</p>

<p>The next piece of the puzzle is figuring out what the current start command is for the container you are trying to launch.  I assumed you were using the <a href="https://hub.docker.com/_/flink" rel="nofollow noreferrer">official flink docker image</a> which is good because the Dockerfile is opensource (link to repo at the bottom).  They are using a complicated script to launch the flink container, but if you dig through that script you will see that it's reading the configuration yaml from <code>/opt/flink/conf/flink-conf.yaml</code>. Instead of trying to change this, it'll probably be easier to just mount a yaml file at that exact path in the pod with your configuration values.</p>

<p>Here's the <a href="https://github.com/docker-flink/docker-flink" rel="nofollow noreferrer">github repo that has these Dockerfiles for reference</a>.</p>

<p>Next question is what should the yaml file look like?
From their docs: </p>

<blockquote>
  <p>All configuration is done in conf/flink-conf.yaml, which is expected
  to be a flat collection of YAML key value pairs with format key: value.</p>
</blockquote>

<p>So, I'd imagine you'd create <code>flink-conf.yaml</code> with the following contents:</p>

<pre><code>jobmanager.heap.size: 2048m
</code></pre>

<p>And then mount it in your kubernetes pod at <code>/opt/flink/conf/flink-conf.yaml</code> and it should work.  </p>

<p>From a kubernetes perspective, it might make the most sense to make a configmap of that yaml file, and mount the config map in your pod as a file.  <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/" rel="nofollow noreferrer">See reference docs</a></p>

<p>Specifically, you are most interested in <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#create-configmaps-from-files" rel="nofollow noreferrer">creating a configmap from a file</a> and <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#add-configmap-data-to-a-volume" rel="nofollow noreferrer">Adding a config map as a volume</a></p>

<p>Lastly, I'll call this out but I won't recommend it because of the fact that the owners of flink have marked it as an incubating feature currently, they have started providing a <a href="https://github.com/docker-flink/examples" rel="nofollow noreferrer">helm chart for Flink</a>, and I can see that they are passing <code>flink-conf.yaml</code> as a config map in the <a href="https://github.com/docker-flink/examples/blob/master/helm/flink/templates/configmap-flink.yaml#L8-L17" rel="nofollow noreferrer">helm chart templates</a> (ignore values surrounded with <code>{{ }}</code> - that is helm template syntax). Here is where they <a href="https://github.com/docker-flink/examples/blob/master/helm/flink/templates/deployment-jobmanager.yaml#L42-L44" rel="nofollow noreferrer">mount their config map into a pod</a>.</p>
