NOTE: I'm working at Splunk, but this is not an official Splunk images. I build them in my free time when I'm not at work. I have some knowledge about Splunk, but you should think twice before putting them in production. I run these images on my own home server just for my personal needs. If you have any issues - feel free to open a bug.
Use for learning purposes.
This repository contains set of examples how to run Splunk Enterprise cluster in Docker, including Search Head Cluster and Indexing Cluster.
The main purpose of this repository is to show how to automate Splunk Cluster deployment. Below you can find examples how to setup Cluster on Docker, Swarm Mode (1.12-rc4 has issues), Kubernetes (TODO).
Based on outcoldman/splunk:6.4.2
.
- Version:
6.4.2
- Build:
00f5bb3fa822
These examples depend on the custom image, which you can build using ./images/splunk
folder.
This image is based on outcoldman/splunk
and includes several changes:
- Adds consul binary to the image. We use consul for service discovery.
- Adds Splunk
splunkcluster
index, which will be used to send here all internal logs about the cluster fromconsul
andload balancer
. - Adds deployment python scripts to
/opt/splunk-deployment
, which are executed only on first start by usingSPLUNK_CMD
ascmd python /opt/splunk-deployment/init.py
. - Register
consul
as scripted input, so it always will be launched withsplunkd
. All logs fromconsul
go to thesplunkcluster
index.
NOTE: do not override
SPLUNK_CMD
when you start this image, this will disable cluster initialization.
-
SPLUNK_ROLES
define the roles for the container. Use comma to define multiple roles (which are compatible).license_master
license_slave
cluster_master
cluster_searchhead
cluster_slave
shc_deployer
shc_member
shc_deployer_client
hw_forwarder
-
INIT_KVSTORE_ENABLED
- force to enable/disable KVStore. -
INIT_WEB_ENABLED
- force to enable/disable Web. -
INIT_INDEXING_ENABLED
- force to enable/disable Indexing. -
INIT_DMC
- force to enable/disable DMC app. -
INIT_WEB_SETTINGS_PREFIX
- set prefix for Web. -
INIT_INDEX_DISCOVERY_MASTER_URI
- sets uri to Cluster Master with enabled Index Discovery. When indexing is off. Defaults tohttps://cluster-master:8089
. -
INIT_INDEX_DISCOVERY_PASS_4_SYMM_KEY
- set index discoverypass4SymmKey
. When indexing is off. Defaults toindexdiscovery-changeme
.
Consul related variables
CONSUL_HOST
- which consul host to join. Defaults toconsul
.CONSUL_ADVERTISE_INTERFACE
- which interface IP to use for advertising.CONSUL_DC
- name of data center. Defaults todc
.CONSUL_DOMAIN
- consul default domain. Defaults tosplunk
.
-
Add licenses to the pool if it will find any
*.lic
files under/opt/splunk-deployment/
. -
Does not require KVStore.
-
Does not require Splunk Web.
-
Does not require Indexing.
-
Does not require DMC app.
-
INIT_GENERAL_PASS_4_SYMM_KEY
- setpass4SymmKey
for the License Cluster. Defaults togeneral-changeme
. -
INIT_WAIT_LICENSE
- wait for license files under/opt/splunk-deployment/licenses
. Defaults toFalse
.
-
Does not require KVStore.
-
Does not require Splunk Web.
-
Does not require Indexing.
-
Does not require DMC app.
-
INIT_GENERAL_PASS_4_SYMM_KEY
- setpass4SymmKey
for the License Cluster. Defaults togeneral-changeme
. -
INIT_LICENSE_MASTER
- uri to License Master. Defaults tohttps://license-master:8089
.
-
Does not require KVStore.
-
Does not require Splunk Web.
-
Does not require Indexing.
-
Does not require DMC app.
-
Sets
repFactor = auto
for all default indexes. This configuration will be deployed to indexers usingmaster-apps
folder. -
Sets up index discovery.
-
Sets clustering
mode = master
. -
INIT_CLUSTERING_PASS_4_SYMM_KEY
- setpass4SymmKey
for Indexing Cluster. Defaults toclustering-changeme
. -
INIT_CLUSTERING_REPLICATION_FACTOR
- set replication factor. Defaults to1
. -
INIT_CLUSTERING_SEARCH_FACTOR
- set search factor. Defaults to1
. -
INIT_CLUSTERING_CLUSTER_LABEL
- set cluster label. Defaults tocluster
. -
INIT_INDEX_DISCOVERY_PASS_4_SYMM_KEY
- set index discoverypass4SymmKey
. Defaults to "indexdiscovery-changeme".
-
Require KVStore.
-
Require Splunk Web.
-
Does not require Indexing.
-
Does not require DMC app.
-
Sets clustering
mode = searchhead
. -
INIT_CLUSTERING_PASS_4_SYMM_KEY
- setpass4SymmKey
for Indexing Cluster. Defaults toclustering-changeme
. -
INIT_CLUSTERING_CLUSTER_MASTER
- set cluster master uri. Defaults tohttps://cluster-master:8089
.
Before starting Splunk after applying configuration changes waits for the cluster_master
role in cluster master defined with INIT_CLUSTERING_CLUSTER_MASTER
.
-
Does not require KVStore.
-
Does not require Splunk Web.
-
Require Indexing.
-
Does not require DMC app.
-
Sets clustering
mode = slave
. -
Enables listening on
9997
for forwarded data. -
INIT_CLUSTERING_PASS_4_SYMM_KEY
- setpass4SymmKey
for Indexing Cluster. Defaults toclustering-changeme
. -
INIT_CLUSTERING_CLUSTER_MASTER
- set cluster master uri. Defaults tohttps://cluster-master:8089
.
Before starting Splunk after applying configuration changes waits for the cluster_master
role in cluster master defined with INIT_CLUSTERING_CLUSTER_MASTER
.
-
Does not require KVStore.
-
Does not require Splunk Web.
-
Does not require Indexing.
-
Does not require DMC app.
-
INIT_SHCLUSTERING_PASS_4_SYMM_KEY
- setpass4SymmKey
for Search Head Cluster. Defaults toshclustering-changeme
.
-
Require KVStore.
-
Require Splunk Web.
-
Does not require Indexing.
-
Does not require DMC app.
-
INIT_SHCLUSTERING_PASS_4_SYMM_KEY
- setpass4SymmKey
for Search Head Cluster. Defaults toshclustering-changeme
. -
INIT_SHCLUSTERING_MGMT_URI
- set management uri of current server. Defaults tohttps://$HOSTNAME:8089
. -
INIT_SHCLUSTERING_REPLICATION_FACTOR
- set replication factor. Defaults to3
. -
INIT_SHCLUSTERING_SHCLUSTER_LABEL
- set Search Head Cluster label. Defaults toshcluster
. -
INIT_SHCLUSTER_AUTOBOOTSTRAP
- auto bootstrap Search Head Cluster on this number of members. Defaults to3
.
After start this role also is trying to auto bootstrap Search Head Cluster or add itself
to existing Search Head Cluster. Using consul every SHC Member elects itself as a Consul Leader on the Consul Service
(not related to Search Head Cluster Captain), adds itself to the list of SHC Members. Checks the current list, if
number of members is less than INIT_SHCLUSTER_AUTOBOOTSTRAP
- just release leadership on Consul Service. If equal to -
does bootstrapping of SHC, if larger - adds itself to Search Head Cluster.
-
Does not require KVStore.
-
Does not require Splunk Web.
-
Does not require Indexing.
-
Does not require DMC app.
-
INIT_SHCLUSTERING_SHCDEPLOYER
- set uri to Search Head Cluster deployer. Defaults tohttps://shc-deployer:8089
.
Before starting Splunk after applying configuration changes waits for the
Search Head Cluster Deployer defined with INIT_SHCLUSTERING_SHCDEPLOYER
.
-
Does not require KVStore.
-
Does not require Splunk Web.
-
Does not require Indexing.
-
Does not require DMC app.
-
INIT_ADD_UDP_PORT
- add listening on port defined with this variable, setsconnection_host = dns
,index = splunkcluster
and register this as a service in consul with namesyslog
.
- Does not require KVStore.
- Require Splunk Web.
- Does not require Indexing.
- Require DMC app.
TODO: dashboards are not configured
consul.sh
- script for scripted input, rule how we launchconsul
. Important, that we persist consul data in"$SPLUNK_HOME/var/consul"
.consul_check.sh
- check script used by consul to verify thatsplunkd
is alive.indexes.conf
- definesplunkcluster
index, which will be used to send logs fromconsul
andload balancer
.inputs.conf
- definition of scripted input, which will allow us to launchconsul
withsplunkd
.
init.py
- startup script, which will be used to initialize the cluster. Invoked with cmd python /opt/splunk-deployment/init.py`.init_consul.py
- helper functions to work with local consul.init_helpers.py
- helper functions.init_<role>.py
- rules how to initialize the role._disable_<what>/
- set of default configuration files which allow to disable this feature. For example_disable_indexing
contains configuration files to forward events to the indexing cluster using index discovery.<ROLE>
- set of configurations rules which will be applied to defined role.
Folder lb
is building HTTP load balancing image. It is based on consul
, consul-template
and haproxy
. consul-template
listen for services updates in the consul and
regenerates the haproxy
configuration.
Ports:
8000
- load balances between SHC servers, using cookieSERVERID
.8100
- redirects to Cluster Master.8200
- redirects to DMC.8300
- redirects to License Master.8500
- redirects to consul.
NOTE: consul is not secured by default.
Image based on consul:v0.6.4
.
NOTE2: If you are using Docker for Mac - it allocates just 2Gb by default, not enough for this demo. Set more. Maybe 8Gb.
cd ./examples/docker
This folder has two docker-compose files. One which does not require License Master and Splunk Enterprise License
docker-compose.yml
and second is an extension for the first one, which adds License Master node. Makefile
in this folder
deals with how docker-compose
needs to be invoked.
Build images.
make build
Deploy instances.
make deploy
Watch for status of deployment:
- Open
http://<docker>:8500
to watch for all green services and hosts. - Watch for
docker-compose logs -f shc-member
for the lineSuccessfully bootstrapped this node as the captain with the given servers.
. This will mean that SHC is bootstrapped. - Open Cluster Master web on
http://<docker>:8100
and checkIndexer Clustering: Master Node
page that Indexes are replicated and ready for search. - Open SHC on
http://<docker>:8000
and check that you see logs from all instancesindex="_internal" | stats count by host
.
You can scale up later with
docker-compose -f docker-compose.yml scale cluster-slave=8 shc-member=5
To clean use
make clean
If you have Splunk Enterprise License copy it in this folder (make sure that license files have extension *.lic
).
Build images.
make build-lm
Deploy instances. This command copies license files to the license master node, deploys 3 SHC Members and 4 Indexer Cluster Slaves. Command will fail if you don't have license files in current folder.
make deploy-lm
Watch for status of deployment:
- Open
http://<docker>:8500
to watch for all green services and hosts. - Watch for
docker-compose logs -f shc-member
for the lineSuccessfully bootstrapped this node as the captain with the given servers.
. This will mean that SHC is bootstrapped. - Open Cluster Master web on
http://<docker>:8100
and checkIndexer Clustering: Master Node
page that Indexes are replicated and ready for search. - Open SHC on
http://<docker>:8000
and check that you see logs from all instancesindex="_internal" | stats count by host
.
You can scale up later with
docker-compose -f docker-compose.yml -f docker-compose.license-master.yml scale cluster-slave=8 shc-member=5
To clean use
make clean-lm
In progress TODO: seems like docker swarm mode in 1.12-rc4 has issue with network discovery. So example does not work. NOTE: Splunk Enterprise License is required
cd ./examples/docker-swarm-mode
Copy Splunk Enterprise license (if you have) in this folder (make sure that license files have extension *.lic
).
Prepare swarm. This command will create 4 docker-machine instances in VirtualBox. One instance is a docker registry. Another 3 will be part of Swarm cluster.
make setup
Do all steps from echoed from command above (two nodes need to join swarm cluster and create a network).
Build images. This command will build images and publish to local registry.
make build
Deploy cluster.
make deploy
To clean splunk cluster use
make clean
To kill all docker machines use
make setup-clean
TODO
docker cp ~/Downloads/splunk_app_aws shc-deployer:/opt/splunk/etc/shcluster/apps/
docker exec shc-deployer entrypoint.sh chown -R splunk:splunk /opt/splunk/etc/shcluster/apps/
docker exec shc-deployer entrypoint.sh splunk apply shcluster-bundle -restart true --answer-yes -target https://$(docker ps --filter=label=splunk.cluster=shc-member -q | head -1):8089 -auth admin:changeme
- Secret storage for getting secrets (currently everything is in plain text from env variables). Might use Vault from HashiCorp.
- DMC Server (with all configurations setup automatically)
- Deployment Server
- Forwarders
- Encrypt consul communication
- CA Authority. Do not skip certificate verification.
- Check if there are better way to configure SSO (including trustedIP)
- On SHC we should log IP addresses with "tools.proxy.on = True"
- Collecting logs from consul server
- Upgrade to consul-template 0.16.0 rtm.
- Secure by default
8500
. - Use
socket
to get fqdn. - SHC Autobootstrap should support removed members.
- Make all consul requests with retry.
- Possible issues with permissions.