https://prefect.io logo
Title
l

Lon Nix

10/13/2021, 5:02 PM
noob question: how do I use the prefect cli with a remote server? I've got the server running in k8s but need to use the CLI to create a tenant
z

Zanie

10/13/2021, 5:04 PM
Hi! You can exec into one of the services that has
prefect
installed and run the CLI command there.
Or you can create a pod with
prefect
installed just for this task
l

Lon Nix

10/13/2021, 5:06 PM
which services have it? I went to the apollo pod and ran
prefect
and it said command not found
x

Xinchi He

10/13/2021, 5:09 PM
Maybe try this? Install
prefect
via
pip
And put
[server]
  host = "http://<apollo pod ip>"
in your local 
~/.prefect/config.toml
 file
z

Zanie

10/13/2021, 5:14 PM
graphql
pod has it installed
👍 1
You can also run some of the CLI commands against apollo remotely as described by Xinchi
l

Lon Nix

10/13/2021, 5:18 PM
ty
I'm not having luck here. I get the same error regardless of which of the above options. When I try to run
prefect get projects
I get this
prefect.exceptions.AuthorizationError: Malformed response received from Cloud - please ensure that you are authenticated. See `prefect auth login --help`.
I am running prefect server though, so there aren't api keys to use with
prefect auth login
I also can't find anything about what all options are allowed in the config.toml file
z

Zanie

10/13/2021, 8:11 PM
Switch to the server backend with
prefect backend server
l

Lon Nix

10/13/2021, 8:12 PM
ah, different error! thanks
z

Zanie

10/13/2021, 8:12 PM
You can create a config.toml at ~/.prefect/config.toml to override any of those keys
l

Lon Nix

10/13/2021, 8:13 PM
thanks
well things are progressing but now I'm having an https issue. I have the server available over http and this in my config.toml
backend = "server"

[server]
  host = "<http://my.domain>"
  port = "80"
however when I run prefect get projects I get this
prefect.exceptions.ClientError: 400 Client Error: Bad Request for url: <https://my.domain:443/>
This is likely caused by a poorly formatted GraphQL query or mutation but the response could not be parsed for more details
It looks like apollo redirects 80 to 443 and the cli doesn't handle that
z

Zanie

10/13/2021, 8:57 PM
I don't think there should be any https involved here.
What's the output of
prefect diagnostics
?
l

Lon Nix

10/13/2021, 8:59 PM
{
  "config_overrides": {
    "backend": true,
    "server": {
      "host": true,
      "port": true
    }
  },
  "env_vars": [],
  "system_information": {
    "platform": "Linux-5.10.16.3-microsoft-standard-WSL2-x86_64-with-glibc2.33",
    "prefect_backend": "server",
    "prefect_version": "0.15.6",
    "python_version": "3.9.6"
  }
}
you are right, there shouldn't be any https
the helm chart has nothing that I can see that would affect this
z

Zanie

10/13/2021, 9:04 PM
What happens if you instantiate a client directly?
❯ ipython               
Python 3.8.8 (default, Feb 24 2021, 13:46:16) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.25.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from prefect import Client

In [2]: client = Client()

In [3]: client.api_server
Out[3]: '<http://localhost:4200>'
l

Lon Nix

10/13/2021, 9:19 PM
~: cat test.py
from prefect import Client

client = Client()

print(client.api_server)
~: python test.py
<http://prefect-apollo.oh-aws-us-east-1-app-dev.ovhl.io:80>
x

Xinchi He

10/13/2021, 9:29 PM
@Zanie could that be a problem of the config file? I am using
backend.toml
that located at
~/.prefect/backend.toml
backend = "server"

[server]
host = "http://<my server ip>"
port = "4200"
host_port = "4200"
endpoint = "${server.host}:${server.port}"
l

Lon Nix

10/13/2021, 9:30 PM
same config overall though
z

Zanie

10/13/2021, 10:24 PM
The
backend.toml
is technically for internal use but it should not be causing this error. I'm a bit confused that you list 4200 there but you're connecting to 80 in your examples?
l

Lon Nix

10/14/2021, 2:20 PM
Xinche has the 4200, I have 80 in my config (or at least I did when I made the request I pasted above)
z

Zanie

10/14/2021, 3:38 PM
Ah sorry I missed that the message was from someone else 😄 @Xinchi He what issue are you encountering?
l

Lon Nix

10/14/2021, 3:47 PM
He's actually on my team 😛
x

Xinchi He

10/14/2021, 3:48 PM
@Zanie @Lon Nix 😁