[Improvement] Support database schema migration via Kubernetes Job in Helm Chart
- Dominant language
- Java
- Stars
- 3.2k
- Forks
- 935
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 298
Description
### What would you like to be improved?
Currently, when deploying or upgrading Gravitino via Helm Chart, there is no built-in mechanism to handle database schema migrations safely. Running schema migrations inside application containers (e.g., as an init container or at startup) can lead to race conditions when multiple pods start simultaneously during a rolling update, potentially causing data corruption or failed migrations.
### How should we improve?
Introduce a Kubernetes Job resource in the Helm Chart to handle database schema upgrades, leveraging Helm Hooks to ensure the migration runs before any application pods are updated.
The Job should be annotated with Helm lifecycle hooks so it executes during pre-install and pre-upgrade phases:
```
apiVersion: batch/v1
kind: Job
metadata:
annotations:
"helm.sh/hook": pre-upgrade,pre-install # Run before upgrade/install
"helm.sh/hook-weight": "1"
"helm.sh/hook-delete-policy": before-hook-creation
Benefits of this approach:
```
The Job guarantees the migration runs exactly once per upgrade.
Rolling update of application Pods only begins after the Job completes successfully.
Prevents race conditions from concurrent schema migration attempts.
Aligns with Kubernetes-native patterns for database lifecycle management.
Contributor guide
Research direction
Start by inspecting the existing Gravitino Helm Chart and its application deployment resources to understand where a migration Job belongs. Add a batch/v1 Job using the requested pre-install and pre-upgrade Helm hooks, then verify that application pods wait for successful completion before updating.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- helm, kubernetes
- Domain
- database, devops
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100