apiVersion: batch/v1
kind: Job
metadata:
  name: create-db
  labels:
    app: bootstrap

spec:
  backoffLimit: 0
  
  template:
    metadata:
      labels:
        app: bootstrap
    spec:
      restartPolicy: Never
      containers:
      - name: create-db
        image: mariadb:10.2.22
        imagePullPolicy: IfNotPresent
        env:
          - name: MYSQL_ROOT_PASSWORD
        command: 
        - /bin/bash
        - -c
        - |
          set -ex
          while ! mysqladmin ping -h db --silent; do
              sleep 1
          done
          mysql -h db -p${MYSQL_ROOT_PASSWORD} -e "create database if not exists thingengine_dev;"
