apache / apache/gravitino

[FEATURE] Add Helm Job to automate DB schema initialization for external databases

Open
#9,013 1 comment 0 reactions 1 assignee Claimed by @HaJunYoo View on GitHub
feature
Dominant language
Java
Stars
3.2k
Forks
935
Avg merge
1d 15h
Merged PRs (30d)
315

Description

### Describe the feature

When deploying Gravitino with the [Helm chart](https://github.com/apache/gravitino/blob/main/dev/charts/gravitino/values.yaml) using an external database (PostgreSQL or MySQL), users must manually initialize the database schema by connecting to the database and executing the appropriate `schema-x.x.x-[db].sql` script before starting the server.

This manual step is inconvenient, error-prone, and conflicts with the automated deployment experience users expect from Helm charts.

Suggests adding a Helm Job to automate database schema initialization.

### Motivation

Current Pain Points
- Manual database initialization is required for external database connection while using helm chart.
- This kinds of error-prone process that can lead to deployment failures

Benefits of This Improvement
- Reduces deployment friction and potential errors

### Describe the solution

Add a Helm Job that runs as a pre-install and pre-upgrade hook to automatically initialize the entity store schema.

**Implementation Details**
1. Job Resource
- Create a new Job template in helm-chart/templates/gravitino-db-init-job.yaml
2. Container Configuration
- Use lightweight database client images like postgres:16-alpine, mysql:8-client
- Mount SQL scripts from the /scripts directory
- Use db credentials from values.yaml

values.yaml will be as below.
```yaml
# for example
entity:
store:
jdbc:
initializeSchema:
enabled: true # Enable/disable the init job
image:
repository: postgres
tag: 16-alpine
```

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.