In the Red Hat Software Collections MySQL container, I see that you can set MYSQL_DEFAULTS_FILE
to indicate the path to a completely different my.cnf
file. When used in OpenShift, I don't understand how to get such a config file on disk, since their S2I scripts have already been run as part of the mysql-persistent
template. How do I go about injecting such a file into a pre-built image?
I'm able to deploy MySQL 5.7 using the template provided with OpenShift, and can set other environment variables, but am not sure how to put my own files into the image so I can reference them.
The trick is to store arbitrary config data (
my.cnf
sections and values) in a ConfigMap, mount that ConfigMap as a file usingvolumes
/volumeMounts
in themysql-persistent
DeploymentConfig, then adjust theMYSQL_DEFAULTS_FILE
environment variable to point MySQL at the newly mounted config file. Here's a guide that describes how to do that for Redis:https://kubernetes.io/docs/tutorials/configuration/configure-redis-using-configmap/