Skip to content

Add helm-like hooks #1892

@lpriori-cell

Description

@lpriori-cell

Feature Request: Lifecycle Hooks (similar to Helm Hooks)

Tanka currently has no built-in mechanism to run Jobs at specific deployment lifecycle stages — something Helm solves with Helm Hooks.

Use Cases

Pre-deploy migrations: Database schema migrations must run before the new application version starts to prevent runtime errors. Without hooks, this has to be orchestrated externally via CI/CD scripts, undermining the value of a declarative tool.

Post-deploy test Jobs: Running smoke tests after deployment to verify connectivity and basic functionality is standard practice. Helm supports this via helm test. Tanka has no equivalent.

The majority of production Helm charts rely on hooks for these workflows. Teams migrating to Tanka lose this capability, creating a significant gap in deployment safety.

Proposed Solution

1. Native lifecycle hooks in Tanka — allow declaring Jobs that run at specific stages via annotations:

{
  migration: job.new('run-migrations') + job.metadata.withAnnotations({
    'tanka.dev/hook': 'pre-apply',
    'tanka.dev/hook-weight': '0',
  }),
  smoke_test: job.new('smoke-test') + job.metadata.withAnnotations({
    'tanka.dev/hook': 'post-apply',
  }),
}

Stages: pre-apply, post-apply, pre-delete, test (on-demand via tk test).
Tanka should wait for hook completion and abort on failure.

2. Helm hook support in helm-util — when importing Helm charts, helm.sh/hook annotations are currently ignored. Tanka should recognize and translate them into native hook semantics, preserving weight and delete policies. This would make Tanka viable for teams depending on charts with hooks without requiring chart modifications.

Capability Helm Tanka (current) Tanka (proposed)
Pre-deploy migrations pre-apply
Post-deploy tests post-apply / tk test
Helm chart hook support ❌ ignored ✅ translated

Happy to discuss or contribute.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions