-
Notifications
You must be signed in to change notification settings - Fork 2
/
copy-flows-to-new-tenant.yaml
81 lines (65 loc) · 2.61 KB
/
copy-flows-to-new-tenant.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
id: copy-flows-to-new-tenant
namespace: system
variables:
host: preview-ee-kafka.kestra.io
newTenant: staging
tasks:
- id: dev_flows
type: io.kestra.plugin.core.http.Download
uri: http://{{vars.host}}/api/v1/{{flow.tenantId}}/flows/export/by-query
method: GET
contentType: application/json
headers:
authorization: Bearer {{ secret('API_TOKEN') }}
- id: import_to_staging
type: io.kestra.plugin.core.http.Request
uri: https://{{ vars.host }}/api/v1/{{ vars.newTenant }}/flows/import
method: POST
contentType: multipart/form-data
formData:
fileUpload:
name: flows.zip
content: "{{ outputs.dev_flows.uri }}"
headers:
authorization: Bearer {{ secret('API_TOKEN') }}
pluginDefaults:
- type: io.kestra.plugin.core.http
forced: true
values:
retry:
type: constant
interval: PT1S
maxAttempt: 3
triggers:
- id: daily_at_5_pm
type: io.kestra.plugin.core.trigger.Schedule
cron: 0 17 * * *
extend:
title: Copy flows from development to QA and staging environments or tenants
description: >
This system flow copies flows from the current tenant to a new Kestra tenant
or environments. The pattern shown here is particularly useful if you want
to automatically promote flows from development to QA and staging
environments or tenants. Here, we release development flows to a staging
tenant every day at 5 PM.
The flow is composed of the following tasks:
1. Download flows from the source tenant using the `Download` plugin.
2. Import flows into the target tenant using the `Request` plugin.
To authenticate with the Kestra API, you need to provide an [API
token](https://kestra.io/docs/enterprise/api-tokens) with the necessary
permissions. You can generate a token from the UI by going to the `Service
Accounts` tab under the `IAM` page, creating a new service account and
generating a new token from the `API Tokens` section. We recommend adding
that token as a [secret](https://kestra.io/docs/concepts/secret) in the
`system` namespace. Here, we've named the secret `API_TOKEN`.
We've set up [retries](https://kestra.io/docs/workflow-components/retries)
via
[pluginDefaults](https://kestra.io/docs/workflow-components/plugin-defaults)
to handle any network issues or temporary failures.
Make sure to adjust the `host` and `newTenant` variables in the flow
configuration to match your environment and requirements.
tags:
- System
ee: false
demo: false
meta_description: Copy flows between tenants in Kestra using a system flow.