Search code examples
linuxkubernetesalpine-linuxdnsmasq

Redirect dnsmasq.conf file to some other file


How can I redirect dnsmasq.conf file from /etc/dnsmasq.conf to another file? Trying to configure a statefulset pod with dnsmasq on kubernetes using pvc through ceph-csi but cant mount the pvc to the config file, only folders available for mounting. If I try to mountthe pvc to/etc/ everything inside the folder goes away and naturally since all folders required for dnsmasq are there, I can't start the program. I thought of a solution to use another folder/file to be applied as the config file but I don't know where can i do that.


Solution

  • From the manual of dnsmasq, it seems it is possible to specify the directory where your dnsmasq.conf file will be. Ref: https://thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html

    -C, --conf-file= Specify a configuration file. The presence of this option stops dnsmasq from reading the default configuration file (normally /etc/dnsmasq.conf). Multiple files may be specified by repeating the option either on the command line or in configuration files. A filename of "-" causes dnsmasq to read configuration from stdin.

    So, you can mount the file any directory you want. Then, point that file using --conf-file argument of your container.