<p>is it possible to pass a function as the value in a K8s' pod command for evaluation? I am passing in JVM arguments to set the MaxRAM parameter and  would like to read the cgroups memory to ascertain a value for the argument</p>

<p>This is an example of what I'm trying to do</p>

<pre><code>- command:
  - /opt/tools/Linux/jdk/openjdk1.8.0_181_x64/bin/java
  - -XX:MaxRAM=$(( $(cat /sys/fs/cgroup/memory/memory.limit_in_bytes) * 70/100 ))
</code></pre>

<p>Unfortunately the above doesn't work and fails with the following error:</p>

<pre><code>Improperly specified VM option 'MaxRAM=$(( $(cat /sys/fs/cgroup/memory/memory.limit_in_bytes) * 100 / 70 ))'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
</code></pre>

<p>Is this doable? If so, what's the right way to do it? Thanks!</p>

frpet
<p>That is shell syntax so you need to run a shell to interpret it.</p>

<pre><code>command:
- sh
- -c
- |
  exec /opt/tools/Linux/jdk/openjdk1.8.0_181_x64/bin/java -XX:MaxRAM=$(( $(cat /sys/fs/cgroup/memory/memory.limit_in_bytes) * 70/100 ))
</code></pre>
