Hello, I am testing prefect setup using <KIND>. Ba...
# prefect-community
r
Hello, I am testing prefect setup using KIND. Basically there is no difference between kind and kubernetes. I am facing to connect to graphql api. Have anybody had similar problem?
n
Hi @Rafal - can you confirm the API is available at that address and port from elsewhere?
perhaps a cURL request or just visiting the URL in question
r
so, after visiting I can see statement
GET query missing
n
Ok great, that's what you'd expect if it was available
You visited that exact URL that's displayed in the UI, right?
r
That's right
n
Hm that's interesting. Are you able to remove the existing UI image and spin up server again? (or just the UI image at least)
r
ok. I deployed UI once again. The same result πŸ€”
n
That's very odd. Is that endpoint open to all external traffic? Or are there some VPC rules attached?
r
What do you mean by saying extarnal? There are no VPC rules behind it, in kind kubernetes nodes are simulated by containerds.
n
Ah I hadn't noticed that was a 172 IP, my fault. I think I see the issue though; try adding the protocol to your config (
<http://172.18.0.2:32000/graphql>
) and then removing the UI image and restarting
r
I've already added it in UI deployment
env:
- name: PREFECT_SERVER__GRAPHQL_URL
value: "172.18.0.2:32000/graphql"
n
Yes you're missing the protocol
http
r
@nicholas now all is green! Seems like working! But there is another question: how to register flow? I guess it comes to start agent... πŸ€”
n
To register a flow, you'll want to add this to your local Prefect `~/.prefect/config.toml`:
Copy code
[server]
endpoint = "172.18.0.2:32000/graphql"
Then you can call
prefect backend server
and any
prefect.register()
calls will send requests to your API container
r
Ok! I've added
- name: PREFECT_SERVER__ENDPOINT
value: "172.18.0.2:32000/graphql"
to prefecthq/server image. Error:
Copy code
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=4200): Max retries exceeded with url: /graphql/alpha (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7ff77c2d35b0>: Failed to establish a new connection: [Errno 111] Connection refused')
πŸ€”
n
When's that error happening @Rafal?
Are you registering flows (running your flow scripts) from within a docker container?
r
No, should I? When I am trying to register flow. Do I miss something? How to register flow when prefect is running on "local" cluster?
@nicholas should I run prefect agent as a docker container? No idea how to setup it correctly
n
No, just checking. The endpoint variable needs to be set in the environment you're registering flows from, i.e. your local machine. You can do so easily with the
~/.prefect/config.toml
configuration file.
No @Rafal, no need to run the agent in a container, but you do need to point your local prefect at your cluster
r
Ok, but all of prefect's components are running on cluster. What should run on my localhost excactly? I need some port forwarding? I do not use confi.toml, just notation from docs:
PREFECT__Β and two underscores (__)
n
Understood, when you're writing/registering flows on your computer, Prefect needs to know where your server is running, if it's not localhost or Cloud
r
So. maybe one of the solution is to add volume with flows to
prefecthq/server
image and register it directly from there as localhost? Is there another option besides Cloud solution?
n
There's no need for that, you just need to set the local config that I mentioned, then whenever you register a flow locally, it will register with your cluster
r
OK! So I needed to create
~/.prefect/config.toml
and after providing config which you suggested I've got:
Copy code
raise InvalidSchema("No connection adapters were found for {!r}".format(url))
requests.exceptions.InvalidSchema: No connection adapters were found for '172.18.0.2:32000/graphql/graphql/alpha'
n
Which version of Prefect Core do you have locally? I think updating your version should fix that
r
Copy code
0.11.5
I will try with update
n
Hm let me check then
πŸ‘ 1
@Rafal can you try adding the protocol (
http
) to that as well?
Ah nevermind, the config should look like this:
Copy code
[server]
endpoint = "172.18.0.2:32000"
sorry about that!
r
@nicholas next step closer to solution πŸ˜‰ It was registered, but two things wich I am worry about:
Flow: <http://localhost:8080/flow/18738ebf-fd53-4831-9157-fbb384cc6f3c>
- still localhost ? Second one: tasks can't run. Some strange monit about Late runs. Does it mean that scheduler is not working properly?
n
I think setting
Copy code
[server]
host = "<http://172.18.0.2>"
will fix that flow.register output but it's not impacting the registration at all. Do you have an agent running? That'll be needed to pick up runs.
r
@nicholas prefect works perfectly fine! Seems like agent need to run all the time to keep flows up to date. Should I keep agent running in container on cluster for example? Sometimes I need to turn off my local computer πŸ˜‰
n
Yes, an agent will need to be running to pick up any flow runs; I'd recommend taking a look at https://docs.prefect.io/orchestration/tutorial/multiple.html#install-a-supervised-agent for some supervised agent info