Closed henricook closed 4 years ago
Interesting use case! Before building your own image, maybe it's possible to get away with dropping the persistent storage on one of the mounts? If it's of any use:
/opt/splunk/etc
will contain all configuration files. If you're using some env vars or the default.yml to set things up, you may not need this/opt/splunk/var
will contain all the indexed data and other raw files. This is probably more important than the former, because Splunk is quite useless without persisting the metrics/logs :)If I had to choose I would elect to persist only /opt/splunk/var
. You can most likely get away with dropping persistent storage for /opt/splunk/etc
but it depends on the topology - if you're using indexer cluster, search head cluster, just forwarders or standalones, etc.
Most of the env vars that are available in the splunk/splunk
image should allow you to tweak Splunk so at boot, it's set up in a repeatable manner. However, if you have users use Splunk and change things via the UI (creating new dashboards, for instance) those get stored somewhere in /opt/splunk/etc
and would be lost upon container restart.
Thanks @nwang92 - it's a trade-off I'd considered, we're going to be setting up many custom dashboards though so it's something we'd like to keep!
In the end I've spent a day upskilling on what makes our infrastructure tick and then made a few minor tweaks that seem to have allowed me to attach 2xVolumes to my pod - so I've managed to remove the one volume requirement at our infrastructure level with some sweat and tears.
It'd be so much more flexible if Splunk could support this though, do you think? Even just moving etc
and var
under /opt/splunk/data or something would let people mount just the data directory. I don't know how that migration path might work though, what do you think of it in terms of a feature suggestion? :-D
I think I see what's preventing this from working - there's an /opt/splunk-etc
which stores the etc dir for the specific Splunk version used in the image itself. When $SPLUNK_HOME changes here, it messes this bit up - I'll see if I can fix it.
Thinking out loud, but I wonder if you could just add a PVC to /opt/splunk
? I recall there being some Docker issues where volumes at specific paths might get wiped when doing this, but I'm not sure if that was ever fixed or if you can even work around it in k8s with things like initContainers.
Additionally, this might be more effort, but maybe even dynamically fetching a Splunk build would allow you to add the PVC to /opt/splunk
and circumvent the existing filesystem contents within /opt/splunk
. Something like:
env:
- name: SPLUNK_BUILD_URL
value: https://download.splunk.com/products/splunk/releases/8.0.5/linux/splunk-8.0.5-a1a6394cc5ae-Linux-x86_64.tgz
I haven't had time to personally test these, but just throwing some ideas out :) I think moving etc
and var
is a bit of a larger, product change though. That would require some changes to the Splunk distribution, whereas this container is more-or-less just a packaging mechanism for those binaries.
Yeah I think that's the problem, when I add a PVC to /opt/splunk it wipes the whole folder (because a new blank volume is now mounted there)
Dynamically fetching a splunk build is :exploding_head: - could work. Those /opt/splunk-etc changes sound :muscle:
Should be available in the nightly splunk/splunk:edge
image - otherwise, should be fixed in 8.0.6 image tag release.
Amazing, thanks @nwang92 !
I'm in a company/infrastructure setup where my only option is to use only one persistent volume for Splunk. My dockerfile and entrypoint script are below.
I'm trying to bring up the container, use an entrypoint script to
cp
everything from /opt/splunk to /data/splunk (my mount point) and then start the normal ansible process with amendedSPLUNK_HOME
. The plan seemed sound but I'm hitting some barriers, can anyone help?Dockerfile:
docker-entrypoint.sh:
Currently with
docker build . -f build/Dockerfile -t foo && docker run -e SPLUNK_PASSWORD=h3ll0th3Ar3you foo
ansible starts and runs about ten steps before failing with: