Helm, Kapacitor and Tick scripts

Hi Philbo,
It was unreliable. The problem I had was that the tasks didn’t load at all and I put this down to a timing issue; the tasks were being posted before kapacitor was ready.

We have since moved to Influx cloud and while I don’t remember the exact details, I can outline the solution.
It looks like I added the tasks as configmap.
I then had my own kubernetes job to post the tasks.
The crux of the job is an init container to wait for kapacitor to be ready:

initContainers:
      - name: wait-for-kapacitor
        image: darthcabs/tiny-tools:1
        imagePullPolicy: IfNotPresent
        args:
        - /bin/bash
        - -c
        - >
          set -x;
          while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://{{ .Release.Namespace }}-kapacitor/v1/tasks?fields=status)" != "200" ]]; do 
            echo '.'
            sleep 15;
          done

and then using the same image, curl each task to the api:

      containers:
      - name: kapacitor-alerts-job
        image: darthcabs/tiny-tools:1 
        imagePullPolicy: IfNotPresent
        command: ['/bin/bash']
        args: ['-c','for file in $(ls -1 files); do curl -X POST http://{{ .Release.Namespace }}-kapacitor:9092/kapacitor/v1/tasks -d @files/$file; sleep 1;done']
        volumeMounts:
        - name: kapacitor-alerts 
          mountPath: "/files"

We deploy using helm, hence the {{ .Release.Namespace }} to build the url.
Hope this helps!
Thanks,
Tom