diff --git a/deploy/templates/historians/uns.yaml b/deploy/templates/historians/uns.yaml index 281d5c42..c99b0c78 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: "{{.Values.influxdb2.image.repository}}:{{.Values.influxdb2.image.tag}}" + 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