Skip to content
This repository was archived by the owner on Feb 14, 2025. It is now read-only.

Create Data Index(DI)/ Jobs Service(JS) Database(DB) migration imageΒ #1785

Description

@rhkp

The Data Index(DI)/ Jobs Service(JS) Database(DB) migration image can be used by Kubernetes/OpenShift job to perform necessary database changes for DI/JS application, before they are started with SonataFlowPlatform.
An example could be along this line, assuming Postgres database is up and running on the cluster

Kubernetes DB Migration Job

apiVersion: batch/v1
kind: Job
metadata:
  name: flyway-image-job
spec:
  template:
    spec:
      containers:
        - name: flyway-image
          image: quay.io/rhkp/flyway-image:latest
          command: ["./migration.sh"]
          args:
            - "jdbc:postgresql://postgres:5432/sonataflow"
            - "$(db_username)"
            - "$(db_password)"
          env:
            - name: db_username
              valueFrom:
                secretKeyRef:
                  name: postgres-secrets
                  key: POSTGRES_USER
            - name: db_password
              valueFrom:
                secretKeyRef:
                  name: postgres-secrets
                  key: POSTGRES_PASSWORD
      restartPolicy: Never
  backoffLimit: 4

SonataFlowPlatform Deploying DI/JS Applications

apiVersion: sonataflow.org/v1alpha08
kind: SonataFlowPlatform
metadata:
  name: sonataflow-platform
spec:
  build:
    config:
      strategyOptions:
        KanikoBuildCacheEnabled: "true"
  services:
    dataIndex:
      enabled: true
      persistence:
        migrateDBOnStartUp: false
        postgresql:
          jdbcUrl: jdbc:postgresql://postgres:5432/sonataflow?currentSchema=data-index-service
          secretRef:
            name: postgres-secrets
            userKey: POSTGRES_USER
            passwordKey: POSTGRES_PASSWORD
      podTemplate:
        replicas: 1
        container:
        initContainers:
          - name: di-init-hello
            image: busybox:1.28
            command: ['sh', '-c', 'echo The DI will be deployed!']
          - name: init-postgres
            image: registry.access.redhat.com/ubi9/ubi-minimal:latest
            imagePullPolicy: IfNotPresent
            command: [ 'sh', '-c', 'until (echo 1 > /dev/tcp/postgres.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local/5432) >/dev/null 2>&1; do echo "Waiting for postgres server"; sleep 3; done;' ]
    jobService:
      enabled: true
      persistence:
        migrateDBOnStartUp: false
        postgresql:
          jdbcUrl: jdbc:postgresql://postgres:5432/sonataflow?currentSchema=jobs-service
          secretRef:
            name: postgres-secrets
            userKey: POSTGRES_USER
            passwordKey: POSTGRES_PASSWORD
      podTemplate:
        container:
        initContainers:
          - name: js-init-hello
            image: busybox:1.28
            command: ['sh', '-c', 'echo The JS will be deployed!']
          - name: init-postgres
            image: registry.access.redhat.com/ubi9/ubi-minimal:latest
            imagePullPolicy: IfNotPresent
            command: [ 'sh', '-c', 'until (echo 1 > /dev/tcp/postgres.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local/5432) >/dev/null 2>&1; do echo "Waiting for postgres server"; sleep 3; done;' ]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions