temporalio / helm-charts

Temporal Helm charts
MIT License
294 stars 321 forks source link

Fix postgresql schema #384

Closed medamineamara closed 1 year ago

medamineamara commented 1 year ago

What was changed

Add kubernetes job to support database schema migration and updates on PostgreSQL.

Why?

Current workplace uses a Bring Your Own PostgreSQL and having this change upstream would be simple for more people.

Checklist

  1. Closes https://github.com/temporalio/helm-charts/issues/349

  2. How was this tested:

Deployed Postgresql helm chart then deployed Temporal helm Complete logs :


amine@amine-Latitude-5420:~/Work/Temporal-helm-charts$ helm -n temporal ls
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /home/amine/.kube/config
NAME        NAMESPACE   REVISION    UPDATED                                 STATUS      CHART               APP VERSION
postgresql  temporal    1           2023-04-06 10:40:28.211826433 +0000 UTC deployed    postgresql-12.1.6   15.1.0     

amine@amine-Latitude-5420:~/Work/Temporal-helm-charts$ helm -n temporal install -f temporal-values.yml temporal .
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /home/amine/.kube/config
NAME: temporal
LAST DEPLOYED: Tue May 16 21:50:23 2023
NAMESPACE: temporal
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
To verify that Temporal has started, run:

  kubectl --namespace=temporal get pods -l "app.kubernetes.io/instance=temporal"

amine@amine-Latitude-5420:~/Work/Temporal-helm-charts$ k -n temporal get pods
NAME                                   READY   STATUS      RESTARTS   AGE
postgresql-0                           1/1     Running     0          40d
temporal-admintools-6ff979d5fb-z5dwr   1/1     Running     0          98s
temporal-frontend-79fc54b7db-mknsd     1/1     Running     0          98s
temporal-history-dd6467bb7-jpt62       1/1     Running     0          98s
temporal-matching-5689b4b4f9-j4bsm     1/1     Running     0          98s
temporal-schema-setup-lzh9n            0/2     Completed   0          2m14s
temporal-schema-update-rlcrm           0/2     Completed   0          108s
temporal-web-fcbfff8c6-cvktl           1/1     Running     0          98s
temporal-worker-7b47ff8568-2xtdk       1/1     Running     0          98s

amine@amine-Latitude-5420:~/Work/Temporal-helm-charts$ helm -n temporal get values temporal
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /home/amine/.kube/config
USER-SUPPLIED VALUES:
cassandra:
  enabled: false
debug: true
elasticsearch:
  enabled: false
grafana:
  enabled: false
postgresql:
  enabled: false
  image:
    pullPolicy: IfNotPresent
    repo: postgres
    tag: 15.1
prometheus:
  enabled: false
server:
  config:
    persistence:
      default:
        driver: sql
        sql:
          database: temporal
          driver: postgres
          host: postgresql.temporal.svc.cluster.local
          maxConnLifetime: 1h
          maxConns: 20
          password: ********** # Masked password
          port: 5432
          user: postgres
      visibility:
        driver: sql
        sql:
          database: temporal_visibility
          driver: postgres
          host: postgresql.temporal.svc.cluster.local
          maxConnLifetime: 1h
          maxConns: 20
          password: ********** # Masked password
          port: 5432
          user: postgres
  replicaCount: 1
web:
  image:
    tag: 2.12.0

amine@amine-Latitude-5420:~/Work/Temporal-helm-charts$ k logs temporal-schema-update-rlcrm -n temporal
Defaulted container "default-schema-update" out of: default-schema-update, visibility-schema-update, check-postgresql-service (init), check-postgresql (init)
2023-05-16T19:50:58.561Z    INFO    UpdateSchemeTask started    {"config": {"DBName":"","TargetVersion":"","SchemaDir":"./schema/postgresql/v96/temporal/versioned","IsDryRun":false}, "logging-call-at": "updatetask.go:98"}
2023-05-16T19:50:58.566Z    DEBUG   Schema Dirs: [] {"logging-call-at": "updatetask.go:187"}
2023-05-16T19:50:58.567Z    DEBUG   found zero updates from current version 1.9 {"logging-call-at": "updatetask.go:128"}
2023-05-16T19:50:58.567Z    INFO    UpdateSchemeTask done   {"logging-call-at": "updatetask.go:121"}
  1. Any docs updates needed?

    I think that in the readme the part where schema setup and update for postgresql should be removed https://github.com/temporalio/helm-charts#install-with-your-own-postgresql

It's an extension of this PL https://github.com/temporalio/helm-charts/pull/350

CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.

medamineamara commented 1 year ago

I found a far more better approach https://github.com/temporalio/helm-charts/pull/281

brandonros commented 1 year ago

similar to https://github.com/temporalio/helm-charts/pull/350 and https://github.com/temporalio/helm-charts/pull/281 i'm pretty sure, probably https://github.com/temporalio/helm-charts/pull/275 too