apiVersion: batch/v1
kind:       Job
metadata:
  name: apply-shard-specs
spec:
  template:
    spec:
      restartPolicy: OnFailure
      containers:
        - name:            apply-specs
          image:           gazette/broker
          imagePullPolicy: IfNotPresent
          command:
            - /bin/sh
            - "-ec"
            - |
              /config/generate-shards.sh | \
                gazctl shards apply
          env:
            - name:  BROKER_ADDRESS
              value: "http://gazette:8080"
            - name:  CONSUMER_ADDRESS
              value: "http://consumer-stream-sum:8080"
          volumeMounts:
            - name:      generate-shards
              mountPath: /config
      volumes:
        - name: generate-shards
          configMap:
            name: generate-shards
            items:
              - key:  generate-shards.sh
                path: generate-shards.sh
                mode: 0777
