apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: search
  labels:
    app: splunk
    role: splunk_search_head
    tier: search
spec:
  selector:
    matchLabels:
      app: splunk
      role: splunk_search_head
      tier: search
  replicas: 2 
  serviceName: search 
  template:
    metadata:
      labels:
        app: splunk
        role: splunk_search_head
        tier: search 
    spec:
      dnsPolicy: ClusterFirst 
      dnsConfig:
        searches: 
          - indexer.splunk.svc.cluster.local
          - search.splunk.svc.cluster.local 
      containers:
        - name: search
          image: splunk/splunk:latest
          env:
            - name: SPLUNK_HOME
              value: /opt/splunk
            - name: SPLUNK_DEFAULTS_URL
              value: http://splunk-defaults/default.yml
            - name: SPLUNK_PASSWORD
              value: helloworld
            - name: SPLUNK_START_ARGS
              value: "--accept-license"
            - name: SPLUNK_ROLE
              value: splunk_search_head
            - name: SPLUNK_CLUSTER_MASTER_URL
              value: master
            - name: SPLUNK_INDEXER_URL
              value: indexer-0,indexer-1,indexer-2
            - name: SPLUNK_SEARCH_HEAD_URL
              value: search-0,search-1
            - name: SPLUNK_DEPLOYER_URL
              value: deployer
            - name: SPLUNK_SEARCH_HEAD_CAPTAIN_URL
              value: captain
            - name: DEBUG
              value: "true"
          ports:
            - containerPort: 8088
            - containerPort: 8089
            - containerPort: 8191 
            - containerPort: 4001
          volumeMounts:
            - name: splunk-search-config
              mountPath: /opt/splunk/etc
            - name: splunk-search-data
              mountPath: /opt/splunk/var
      volumes:
        - name: splunk-search-config
          emptyDir: {}
        - name: splunk-search-data
          emptyDir: {}
