From 07e5dc8c32d6dd8189c2a8ac2135e020054afd99 Mon Sep 17 00:00:00 2001 From: D J Newbould <132448197+djnewbould@users.noreply.github.com> Date: Thu, 17 Oct 2024 14:50:25 +0100 Subject: [PATCH 1/2] add influx init container --- deploy/templates/historians/uns.yaml | 22 +++++++++++++++++++++- deploy/values.yaml | 4 ---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/deploy/templates/historians/uns.yaml b/deploy/templates/historians/uns.yaml index 281d5c42..85176d87 100644 --- a/deploy/templates/historians/uns.yaml +++ b/deploy/templates/historians/uns.yaml @@ -30,7 +30,27 @@ spec: - name: keytabs secret: secretName: historian-uns-keytabs - + initContainers: + - name: create-bucket + image: "{{ include "amrc-connectivity-stack.image-name" (list . .Values.influxdb2) }}" + env: + - name: INFLUX_TOKEN + valueFrom: + secretKeyRef: + key: admin-token + name: influxdb-auth + - name: INFLUX_HOST + value: http://acs-influxdb2.{{ .Release.Namespace }}.svc.cluster.local + command: + - /bin/sh + - "-ec" + - |+ + if ! influx bucket list -o default -n uns + then + influx bucket create --name uns --retention 0 --org default + UNS_BUCKET_ID=$(influx bucket list --name uns --org default | awk 'NR==2 {print $1}') + influx v1 dbrp create --bucket-id $UNS_BUCKET_ID --db uns --rp uns --default --org default + fi containers: - name: historian-uns image: "{{ include "amrc-connectivity-stack.image-name" (list . .Values.historians.uns) }}" diff --git a/deploy/values.yaml b/deploy/values.yaml index 27fdab42..9cbe6691 100644 --- a/deploy/values.yaml +++ b/deploy/values.yaml @@ -439,10 +439,6 @@ influxdb2: #!/bin/bash echo "Creating mapping for bucket ${DOCKER_INFLUXDB_INIT_BUCKET_ID} in org ${DOCKER_INFLUXDB_INIT_ORG}" influx v1 dbrp create --bucket-id ${DOCKER_INFLUXDB_INIT_BUCKET_ID} --db default --rp default --default --org ${DOCKER_INFLUXDB_INIT_ORG} - # create UNS ducket and DB mapping - influx bucket create --name uns --retention 0 --org ${DOCKER_INFLUXDB_INIT_ORG} - UNS_BUCKET_ID=$(influx bucket list --name uns --org ${DOCKER_INFLUXDB_INIT_ORG} | awk 'NR==2 {print $1}') - influx v1 dbrp create --bucket-id $UNS_BUCKET_ID --db uns --rp uns --default --org ${DOCKER_INFLUXDB_INIT_ORG} pdb: create: false From 4d1835e4b77a7e7e3b59cd67723b9f91a60ed2c1 Mon Sep 17 00:00:00 2001 From: D J Newbould <132448197+djnewbould@users.noreply.github.com> Date: Thu, 17 Oct 2024 15:12:50 +0100 Subject: [PATCH 2/2] Define influx image name explicitly The image name from the values file doesn't resolve to the correct image name. --- deploy/templates/historians/uns.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/templates/historians/uns.yaml b/deploy/templates/historians/uns.yaml index 85176d87..c99b0c78 100644 --- a/deploy/templates/historians/uns.yaml +++ b/deploy/templates/historians/uns.yaml @@ -32,7 +32,7 @@ spec: secretName: historian-uns-keytabs initContainers: - name: create-bucket - image: "{{ include "amrc-connectivity-stack.image-name" (list . .Values.influxdb2) }}" + image: "{{.Values.influxdb2.image.repository}}:{{.Values.influxdb2.image.tag}}" env: - name: INFLUX_TOKEN valueFrom: