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

Initial poc of initdb job #491

Merged
merged 20 commits into from
Apr 10, 2024
Merged

Initial poc of initdb job #491

merged 20 commits into from
Apr 10, 2024

Conversation

eberlep
Copy link
Collaborator

@eberlep eberlep commented Jun 6, 2023

Problem

From time to time, the need for custom SQL statements arises, but I haven't found a baked in way in the Spilo images to do so.

Proposed solution

A possible (and also image-independant) solution is a simple job: Created at the same time as the database, it restarts until it ran successfully. This job simply runs psql, connects to the master pod and executes the configured sql statements:

 ~  $ kgp
NAME                                 READY   STATUS      RESTARTS   AGE   SPILO-ROLE
pgfits-philippe1696f61449bc-0        3/3     Running     0          44s   master
postgres-initdb-5bwwn                0/1     Error       0          24s   
postgres-initdb-r2rr5                0/1     Completed   0          4s    
postgres-initdb-wsxbv                0/1     Error       0          51s   
postgres-initdb-x6jlh                0/1     Error       0          34s   
postgres-operator-67565dcbc6-fsbj4   1/1     Running     0          51s

TODOs

  • Migration: Should existing DBs also execute that statement? YES
  • Reconcile: Should updated statements be executed again? NO
  • Statements configurable per DB or per Partition? PER PARTITION
  • Move Statements to central ConfigMap in postgreslet-system namespace, similar to the Pod Environment Configmap
  • Pass along the Spilo image to use
  • Set ttlSecondsAfterFinished on job (K8s >= 1.23)?
  • Don't execute on clones / standbies

@eberlep
Copy link
Collaborator Author

eberlep commented Oct 16, 2023

Finish up and merge

@eberlep eberlep marked this pull request as ready for review April 10, 2024 10:05
@eberlep
Copy link
Collaborator Author

eberlep commented Apr 10, 2024

Reviewed with Tom.

@eberlep eberlep merged commit 40d560a into main Apr 10, 2024
1 check passed
@eberlep eberlep deleted the initdb-job branch April 10, 2024 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant