Prefect Server:Tenant 的作用是什么?

Prefect Server: What is the role of a Tenant?

在尝试使用 prefect server config 生成的 Docker Compose 文件设置 Prefect 0.14.15 以跨多个代理执行 Flow 时,我惊讶地发现 Prefect 的服务器需要租户命令代理连接。我调查发现 Prefect 的文档提供了有关其 create-tenant and list-tenants CLI operations. However, I've looked extensively through the linked pages — along with the rest of Prefect's documentation and accompanying tutorials — for any mention of Tenants, and only found the following 简短提及的用法语法的信息:

Once authenticated, user-based API keys can be used to generate short-lived JWT auth tokens for any tenant the user belongs to. These API keys inherit any permissions the user has in that tenant, allowing full API access.

Prefect 中的 Tenant 到底是什么?它似乎并不特定于 Prefect 的 Hybrid Execution model。那么,在执行 Prefect Flow 之前和期间,它如何适应服务器、代理和客户端之间的交互?说用户“属于”或“属于”租户是什么意思?要求它向Server注册一个Agent是为了什么?

租户在 Prefect Server 中的意义远不如 Prefect Cloud,但由于 Cloud 是建立在开源服务器代码之上的,所以这个想法仍然存在。

租户是所有其他对象所在的顶级对象。租户中的用户无法访问其他租户中的任何内容。在 Cloud 中,严格执行此权限以限制用户访问的范围。在服务器中,您只需要一个租户就可以开始使用该系统,因为大多数对象都将链接回一个租户。通常,如果您使用 Prefect CLI prefect server start,或者您可以在 Prefect Server Helm 图表中切换自动创建,则会在启动期间为您创建一个默认租户。

当代理在服务器上注册时,我们会在数据库的 'agents' table 中存储有关该代理的详细信息。在 Server 中,您的代理与默认租户相关联。在 Cloud 中,您的代理与用于启动代理的 API 密钥所属的租户相关联。

当您 运行 流时,客户端必须与服务器对话以报告流的状态。与代理一样,此流 运行 与租户相关联。在 Cloud 中,它继承了代理的 API Key。 Server中,我们继续使用默认租户。

tldr;租户是用户所属的 Prefect Cloud Teams 的基础,用于许可。在Prefect Server,你只需要有一个;创建它并忘记它(或使用我们为您创建它的标准工具)。