-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Problem description
Each API service has an init container that check the PGSTACBootstrap job to be complete. This is not very efficient as it starts 4 init containers doing the same thing. It also requires specific role bindings for monitoring the job.
Proposed changed: Use Helm Hooks
We can replace this current behavior with Helm hooks to control the execution order. Here's the plan:
-
Add Helm hook annotations to the pgstacbootstrap job:
helm.sh/hook: post-install,post-upgrade- Ensures the job runs after the postgres dependency is installedhelm.sh/hook-weight: -5- Lower weight means it runs earlier in the hook sequencehelm.sh/hook-delete-policy: before-hook-creation,hook-succeeded- Cleans up the job after it succeeds
-
Remove the initContainer from the deployment that waits for the pgstacbootstrap job
-
Add a hook weight to the deployment to ensure it runs after the pgstacbootstrap job:
helm.sh/hook-weight: 0(higher than the pgstacbootstrap job's weight)
This approach will:
- Ensure the pgstacbootstrap job runs after the postgres dependency is installed
- Make the deployment wait for the pgstacbootstrap job to complete before starting
- Remove the need for the kubectl polling in the initContainer
Implementation Details
The modified pgstacbootstrap job would look like:
apiVersion: batch/v1
kind: Job
metadata:
name: pgstacbootstrap
labels:
app: pgstacbootstrap
annotations:
helm.sh/hook: post-install,post-upgrade
helm.sh/hook-weight: "-5"
helm.sh/hook-delete-policy: before-hook-creation,hook-succeededAnd we would remove the initContainer from the deployment.
Expected Behaviour
PGSTACBootstrap as pre-hook job shall be managed by Helm that will pursue the deployment once the job is complete