apiVersion: batch/v1
kind: Job
metadata:
  name: notification-db-init-job
  namespace: kubesphere-alerting-system
  labels:
    app: notification
    job: notification-db-init
    version: v0.1.0
spec:
  backoffLimit: 6
  completions: 1
  parallelism: 1
  template:
    metadata:
      labels:
        app: notification
        job: notification-db-init
        version: v0.1.0
      name: notification-db-init
    spec:
      initContainers:
        - name: wait-mysql
          image: busybox:1.28.4
          imagePullPolicy: IfNotPresent
          command: ['sh', '-c', 'until nc -z notification-db.kubesphere-alerting-system.svc 3306; do echo "waiting for mysql"; sleep 2; done;']
      containers:
        - command: ["/flyway/sql/ddl/ddl_init.sh", "-hnotification-db.kubesphere-alerting-system.svc", "-uroot", "--connect-timeout=5"]
          env:
            - name: PASSWORD
              valueFrom:
                secretKeyRef:
                  key: password
                  name: mysql-pass
          image: openpitrix/notification:flyway
          imagePullPolicy: Always
          name: notification-db-init
          resources: {}
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: OnFailure
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
