Skip to content

Commit

Permalink
Add Influx Init container (#362)
Browse files Browse the repository at this point in the history
Create an init container on the UNS historian to create the bucket for
the UNS namespace because the init script didn't create the bucket on
helm upgrade.
  • Loading branch information
djnewbould authored Oct 17, 2024
2 parents 0457bfc + 4d1835e commit 6ea1269
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
22 changes: 21 additions & 1 deletion deploy/templates/historians/uns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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) }}"
Expand Down
4 changes: 0 additions & 4 deletions deploy/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 6ea1269

Please sign in to comment.