Teams question If you have several teams, how do ...
# ask-community
y
Teams question If you have several teams, how do you register flows from the same server to a different team? I do not see a
team
option in
flow.register
. is it when you create the project in the cloud UI? what happens if one team create a project with the same name as a different team ?
n
Hi @YD - are you on Server or Cloud?
y
if we will be on the cloud… I do not think we can do teams on our own server, right?
n
Teams aren't really a distinction in Server, no, but the
tenant
object does exist. For Cloud you can register them by using an API key from that Team. When you do that, you can create projects in different teams that have the same name.
y
isn’t the API key used by the agent running to the machine in our environment ? if both teams are using the same machine to connect to Prefect Cloud, how would this work? (both teams are using some shared code and tools, but have different projects)
n
Your teams would need to specify different API keys when registering flows and agents can only query for runs from a single team, meaning agents will need to be started for each team with the proper API keys, if I understand your meaning
y
Not sure I understand what you mean… Are you saying that we can’t have two teams using the same server? Since only one agent can run on a server. Or are you saying that there is a way to run two different agents on the same server? if you can run two agent on the same server, can you please provide an example of how to set the
config.toml
and how to register the flows to the different teams? Even in the same team, how do I register flows to different users ?
does every user needs to run a separate agent, when running jobs on a single server ?
n
Yes you can run as many agents as your server can handle on the same server. When you start an agent you're able to provide an API key like such:
Copy code
prefect agent start -k <<API_KEY>>
which would authenticate it with whatever team is using it. When registering flows, you would call
prefect auth login -k <<API_KEY>>
(for users belong to multiple teams they would want to use a user api key which would allow them to access whichever team they need) and switch/list teams with
prefect auth list-tenants
and
prefect-auth switch-tenants --slug/--id <<slug or id>>
For more information on agents, take a look at the agent docs
y
OK… I generally prefer not to type API_KEYs in the command line (to avoid having it show in the history) If I switch tenants, does it mean that the other tenant jobs will not run, or is it only effects the registration of new flows?
n
that would only impact the registration of new flows. you can of course also set temporary environment variables to do this but i'm a little unclear why registration would be happening all on the same machine without some CI process involved
y
@Darren
d
Thanks for looping me in. I think this may help clear things up.
YD has two teams that he wants to be able to use Prefect Cloud (separate tenant/team) Both teams are using the same Hadoop node to execute jobs. So the Prefect agent runs on this one node He does not want users to have to continuously need to use the API_KEY when registering flows. (Prefer having the API_KEYs in the config.toml file or other secrets file) • Does he need to run one or more agents ? (multiple agents from my understanding) • How should the config.toml should look like ? • How does he register flows for the different teams ? (API key from my understanding)
Let me know if this helps or if I misinterpreted
n
Ok that's helpful: • Yes, multiple agents are needed, at least 1 per team • For configuration, if you want to put API keys or other information in config.toml you can use custom configuration to do so, referencing the correct config.toml file for each team/environment as you need it through temporary environment variables. This can happen on either user machines or in your agent job • Similar to the above, user machines can have different config.toml files locally that have keys for whatever team they're registering flows to. These different configs can be referenced by path like this:
export PREFECT__USER_CONFIG_PATH="path to team-specific config containing keys"