André Dias
05/05/2022, 5:47 PMPrefect Agent
and a prefect server
on my local computer, everything residing inside of containers
. My Prefect Server
`container(s)`is based on the docker-compose
file retrieved from prefect server config > server-docker-compose.yaml
. When spinning up a container for an Agent and running prefect agent local start --api <http://host.docker.internal:4200>
, it says that I must be authenticated to communicate with the containerized server living in my local machine.
My first question is: Is authentication
mandatory in this kind of situation , for local run ?
When I authenticate by creating a new tenant using prefect server create-tenant -n default
outside the Agent container, I’m able to spin up the Agent Container
and run everything. The problem is that I wanted to run the create-tenant
inside the container too, but it’s not possible as I’m getting connection refused between containers.Kevin Kho
05/05/2022, 5:50 PMprefect backend server
Or is the authentication not related to Prefect? Is it more of a Docker thing?André Dias
05/05/2022, 5:53 PM❯ docker logs -f 280822429c41
Backend switched to server
[2022-05-05 17:52:29,688] INFO - agent | Registering agent...
Traceback (most recent call last):
File "/usr/local/bin/prefect", line 8, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.7/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/prefect/cli/agent.py", line 170, in start
start_agent(LocalAgent, import_paths=list(import_paths), **kwargs)
File "/usr/local/lib/python3.7/site-packages/prefect/cli/agent.py", line 128, in start_agent
agent.start()
File "/usr/local/lib/python3.7/site-packages/prefect/agent/agent.py", line 186, in start
self._setup_api_connection()
File "/usr/local/lib/python3.7/site-packages/prefect/agent/agent.py", line 870, in _setup_api_connection
self.client.attach_headers({"X-PREFECT-AGENT-ID": self._register_agent()})
File "/usr/local/lib/python3.7/site-packages/prefect/agent/agent.py", line 831, in _register_agent
agent_config_id=self.agent_config_id,
File "/usr/local/lib/python3.7/site-packages/prefect/client/client.py", line 1782, in register_agent
tenant_id=self.tenant_id,
File "/usr/local/lib/python3.7/site-packages/prefect/client/client.py", line 273, in tenant_id
self._tenant_id = self._get_default_server_tenant()
File "/usr/local/lib/python3.7/site-packages/prefect/client/client.py", line 194, in _get_default_server_tenant
"Your Prefect Server instance has no tenants. "
prefect.exceptions.ClientError: Your Prefect Server instance has no tenants. Create a tenant with `prefect server create-tenant`
docker-compose
:
prefect_agent:
image: "prefecthq/prefect:latest"
command: bash -c 'prefect backend server && prefect agent local start --api <http://host.docker.internal:4200>'
networks:
prefect-server: null
depends_on:
apollo:
condition: service_started
Kevin Kho
05/05/2022, 5:57 PMAndré Dias
05/05/2022, 6:03 PMprefect server config > server-docker-compose.yaml
. Can it be done in Apollo
, GraphQL
containers or somewhere else?Kevin Kho
05/05/2022, 6:17 PMcommand: bash -c 'prefect backend server && prefect server create-tenant && prefect agent local start --api <http://host.docker.internal:4200>'
André Dias
05/05/2022, 6:23 PM-n default
flag too but no luck also 😕 This is weird, sorry !
Docker-compose:
prefect_agent:
image: "prefecthq/prefect:0.15.7-python3.9"
command: bash -c "prefect backend server && prefect server create-tenant && prefect agent local start --api <http://host.docker.internal:4200>"
networks:
prefect-server: null
depends_on:
apollo:
condition: service_started
Kevin Kho
05/05/2022, 7:00 PMAndré Dias
05/05/2022, 10:26 PMnetwork_mode
to host
in the agent dockerfile part. Huge thanks for all the help and for sharing this project @Kevin KhoKevin Kho
05/05/2022, 10:29 PM