<p>We are deploying Cassandra docker image 3.10 via k8s as StatefullSet.</p>

<p>I tried to set GC to G1GC adding <code>-XX:+UseG1GC</code> to JAVA_OPTS environment variable, but Cassandra is using the default CMS GC as set in the jvm.opts file.</p>

<p>from running <code>ps aux</code> in the pod I'm getting Cassandra configuration:</p>

<pre><code>USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
cassand+       1 28.0 10.1 72547644 6248956 ?    Ssl  Jan28 418:43 
java -Xloggc:/var/log/cassandra/gc.log -ea -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -XX:+HeapDumpOnOutOfMemoryError -Xss256k -XX:StringTableSize=1000003 -XX:+AlwaysPreTouch -XX:-UseBiasedLocking -XX:+UseTLAB -XX:+ResizeTLAB -XX:+UseNUMA -XX:+PerfDisableSharedMem -Djava.net.preferIPv4Stack=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:SurvivorRatio=8 -XX:MaxTenuringThreshold=1 -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSWaitDuration=10000 -XX:+CMSParallelInitialMarkEnabled -XX:+CMSEdenChunksRecordAlways -XX:+CMSClassUnloadingEnabled -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -XX:+PrintPromotionFailure -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=10M -Xms2G -Xmx2G -Xmn1G -XX:CompileCommandFile=/etc/cassandra/hotspot_compiler -javaagent:/usr/share/cassandra/lib/jamm-0.3.0.jar -Dcassandra.jmx.remote.port=7199 -Dcom.sun.management.jmxremote.rmi.port=7199 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.password.file=/etc/cassandra/jmxremote.password -Djava.library.path=/usr/share/cassandra/lib/sigar-bin -javaagent:/usr/share/cassandra/jmx_prometheus_javaagent-0.10.jar=7070:/etc/cassandra/jmx_prometheus_cassandra.yaml 
</code></pre>

<p>there is no <code>-XX:+UseG1GC</code> property.</p>

<p>Is there a way to override the jvm.opts at runtime, so I don't have to build the image for every small change? or I must add the costume jvm.opts file to the docker image I'm building?</p>

<p>Best and ideal option is ConfigMap. You can create ConfigMap for that file so that jvm.opts file can be accessed and changed from outside of pod. So without recreating new pod or even touching pod, you can change configuration as many times as you want.</p>

<p>For more details refer :
 <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#create-configmaps-from-files" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#create-configmaps-from-files</a> </p>
