Subflow icon
ForEach icon
Parallel icon
Sequential icon
Request icon
PushNamespaceFiles icon
PushFlows icon
WorkingDirectory icon
UploadFiles icon
DeleteFiles icon
Schedule icon

Export All Kestra Namespaces to GitLab with Releases for GitOps Best Practices

Automatically export all Kestra namespaces, flows, files, and KV pairs to GitLab on a schedule, then cut releases and open merge requests for GitOps backup.

Categories
CoreInfrastructure

Treat Git as the single source of truth for your entire Kestra instance. This blueprint discovers every namespace, then exports its flows, namespace files, and key-value (KV) store entries into a GitLab repository on a recurring schedule. It solves a real operational gap: Kestra resources created or edited through the UI and API live in the platform's database, so without a versioned export you have no audit trail, no peer-reviewable history, and no clean disaster-recovery path. With this flow, every namespace lands in Git as structured, diffable files, and stable states can be promoted through GitLab releases and merge requests.

How it works

  1. The get_namespaces task runs a io.kestra.plugin.core.flow.Subflow (get-all-namespaces) to enumerate every namespace dynamically.
  2. for_each_namespace, a io.kestra.plugin.core.flow.ForEach with concurrencyLimit: 1, iterates over each namespace and runs a Parallel block per namespace.
  3. Inside it, the kv_storing branch calls the Kestra API via io.kestra.plugin.core.http.Request to list KV keys (get_keys) and fetch each value (retrieve_values).
  4. The pushes branch commits resources to GitLab: push_files (io.kestra.plugin.git.PushNamespaceFiles) under _files/<namespace> and push_flows (io.kestra.plugin.git.PushFlows) under _flows/<namespace>.
  5. set_wd (WorkingDirectory) assembles a kvStore.json from the retrieved KV pairs and stages it with io.kestra.plugin.core.namespace.UploadFiles.
  6. push_kv commits the KV export with another PushNamespaceFiles, then delete_stored_kv (DeleteFiles) cleans up the temporary namespace files.
  7. When make_new_release is set, make_release POSTs to the GitLab Releases API; when release_name equals Latest, create_pull_request opens a merge request from the kestra branch into main.
  8. The weekly_saves io.kestra.plugin.core.trigger.Schedule trigger runs the whole export on cron 0 0 7,14,21,28 * *.

What you get

  • A complete, versioned export of all namespaces: flows, files, and KV pairs.
  • GitLab as the canonical, diffable source of truth for your instance.
  • Optional tagged releases to snapshot known-good states.
  • Optional merge requests to promote the latest export into main.
  • A recurring schedule so backups happen without manual effort.

Who it's for

  • Platform administrators safeguarding a shared Kestra instance.
  • DevOps and infrastructure engineers building GitOps governance.
  • Teams needing disaster recovery and environment replication.

Why orchestrate this with Kestra

GitLab can store and review your exports, but its own CI scheduler cannot reach into Kestra to enumerate namespaces, read the KV store, and serialize flows. Kestra drives that export end to end: event-aware Schedule triggers, automatic retries on transient API or Git failures, full execution lineage across the parallel and per-namespace branches, and everything declared in version-controlled YAML. You get the backup orchestration GitLab pipelines cannot express on their own.

Prerequisites

  • A reachable Kestra instance (set kestra_local_uri).
  • A GitLab repository (your_git_repository) and project ID (your_project_id).
  • The get-all-namespaces subflow available in your namespace.

Secrets

  • GITLAB_API_TOKEN: authenticates the Git pushes, releases, and merge requests.
  • KESTRA_API_TOKEN: authorizes the Kestra API calls that list and read KV pairs.

Quick start

  1. Add the GITLAB_API_TOKEN and KESTRA_API_TOKEN secrets.
  2. Set the your_git_repository, kestra_local_uri, and your_project_id variables.
  3. Confirm the get-all-namespaces subflow exists.
  4. Run once with make_new_release set to false to validate the export.
  5. Let the weekly_saves schedule take over, or trigger releases as needed.

How to extend

  • Adjust the weekly_saves cron for daily or nightly backups.
  • Filter to specific namespaces by editing the ForEach values.
  • Add a Slack or email notification on completion or failure.
  • Pair with a restore flow to close the full backup and recovery loop.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.