apiVersion: batch/v1
kind: Job
metadata:
  generateName: solr-config-
  labels:
    stack: esgf-solr-cloud
    component: config
  
spec:
  backoffLimit: 2
  #activeDeadlineSeconds: 120
  template:
    spec:
    
      restartPolicy: Never
      
      # the init container downloads source code distribution to shared volume
      initContainers:
        - name: git
          image: alpine/git
          command:
            - git
            - clone
            - https://github.com/LucaCinquini/esgf-solr-cloud.git
          volumeMounts:
            - name: src
              mountPath: /git

    
      # this container configures a Solr Cloud cluster from up-to-date source code distribution (master branch)
      containers:
        - name: solr-config
          image: solr:7.4
          command:
            - /src/esgf-solr-cloud/scripts/solr_config.sh
          env:
            - name: SOLR_HOST
              value: solr-load-balancer
            - name: SOLR_PORT
              value: "8983"
            - name: SOLR_NUM_SHARDS
              value: "3"
            - name: SOLR_NUM_REPLICAS
              value: "3"
            - name: SOLR_MAX_SHARDS_PER_NODE
              value: "3"
            - name: ZOOKEEPER_HOST
              value: zookeeper
            - name: ZOOKEEPER_PORT
              value: "2181"
          volumeMounts:
            - name: src
              mountPath: /src
      
      volumes:
        - name: src
          emptyDir: {}
