Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rhkp opened this issue Jul 22, 2024 · 0 comments
Open

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

rhkp opened this issue Jul 22, 2024 · 0 comments

Comments

@rhkp
Copy link

rhkp commented Jul 22, 2024

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;' ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant