New to Kestra?
Use blueprints to kickstart your first workflows.
Automatically purge expired key-value entries from Kestra's internal KV store across namespaces on a daily schedule using a declarative YAML flow.
id: kv-store-purge
namespace: system
tasks:
- id: purge_kv
type: io.kestra.plugin.core.kv.PurgeKV
description: Remove key-value (KV) entries from Kestra’s internal storage every
day at 12AM.
expiredOnly: true
namespaces:
- system
- company
includeChildNamespaces: true # Whether to include sub-namespaces of the matched namespace(s).
triggers:
- id: daily_midnight_schedule
type: io.kestra.plugin.core.trigger.Schedule
cron: "0 0 * * *"
Keep Kestra's internal key-value (KV) store clean by automatically removing expired entries across multiple namespaces every day. As flows write KV pairs for caching, state, tokens, and intermediate results, stale and expired keys accumulate and quietly bloat internal storage. This blueprint runs a scheduled cleanup that deletes only the entries you no longer need, so your KV store stays lean and predictable without any manual intervention.
A io.kestra.plugin.core.trigger.Schedule trigger fires every day at midnight using the cron expression 0 0 * * *. On each run, the purge_kv task of type io.kestra.plugin.core.kv.PurgeKV scans the targeted namespaces and removes matching KV entries. The task is configured with expiredOnly: true, so it deletes only entries whose TTL has lapsed and leaves active keys untouched. It targets the system and company namespaces via the namespaces property, and includeChildNamespaces: true extends the purge to every sub-namespace beneath them.
The KV store has no built-in janitor, so without orchestration expired keys linger until someone deletes them by hand. Kestra closes that gap: a declarative YAML Schedule trigger runs the purge on an event-driven cron, retries can be layered on for resilience, and every execution is captured with full logs and lineage for audit. You define the cleanup policy once in version-controlled YAML instead of wiring up external cron jobs or scripts.
system and company namespaces and their children.This blueprint references no secrets. It operates entirely against Kestra's internal KV store.
namespaces list to match the namespaces you want to clean.expiredOnly: true matches your intent, then save.Schedule trigger, or run the flow manually to verify.Schedule trigger to run hourly, weekly, or off-peak.expiredOnly: false to purge all keys, or add a key filter for surgical cleanup.namespaces list, or toggle includeChildNamespaces.