apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: indexer
  labels:
    app: splunk
    role: splunk_indexer
    tier: indexer
spec:
  selector:
    matchLabels:
      app: splunk
      role: splunk_indexer
      tier: indexer
  replicas: 3
  serviceName: indexer
  volumeClaimTemplates:
  - metadata:
      name: splunk-idxcluster-data
      labels:
        app: splunk
        role: splunk_indexer
        tier: indexer
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 100Gi
  - metadata: 
      name: splunk-idxcluster-config
      labels:
        app: splunk
        role: splunk_indexer
        tier: indexer
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 10Gi
  template:
    metadata:
      labels:
        app: splunk
        role: splunk_indexer
        tier: indexer 
    spec:
      dnsPolicy: ClusterFirst
      dnsConfig:
        searches:
          - indexer.splunk.svc.cluster.local
      containers:
        - name: indexer
          image: splunk/splunk:latest
          env:    
            - name: SPLUNK_HOME
              value: /opt/splunk
            - name: SPLUNK_DEFAULTS_URL
              value: http://splunk-defaults/default.yml
            - name: SPLUNK_START_ARGS
              value: "--accept-license"
            - name: SPLUNK_ROLE
              value: splunk_indexer
            - 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
            - name: SPLUNK_PASSWORD
              value: helloworld
            - name: DEBUG
              value: "true"
          ports:
            - containerPort: 8088
            - containerPort: 8089
            - containerPort: 9997
            - containerPort: 4001 
          volumeMounts:
            - name: splunk-idxcluster-config  
              mountPath: /opt/splunk/etc
            - name: splunk-idxcluster-data
              mountPath: /opt/splunk/var
