How to create a new API Key in Prefect Cloud 1.0

We have installed Prefect v1.0 on EKS. I am trying to figure out how to generate the API Key.

And the menus are greyed out - when you click on Team in the Prefect UI

Tried this in the Playground -

mutation { create_api_key(input: { user_id: prefect_dev, name: "Dev API key" }) { key } }

Got this response - { "error": { "errors": [ { "message": "Cannot query field \"create_api_key\" on type \"Mutation\". Did you mean \"create_project\", \"create_flow\", \"create_flow_run\", or \"create_tenant\"?", "locations": [ { "line": 2, "column": 3 } ], "extensions": { "code": "GRAPHQL_VALIDATION_FAILED" } } ] } }

1 Like

You should do that from the Prefect Cloud UI - https://cloud.prefect.io/user/keys

GraphQL is difficult because you would need to be already authenticated to create an API key - it’s easiest to just log into the UI and create the key from there.

Hi Anna,

That suggestion was useful!

https://{our-prefect-server-k8-url}/user/keys)

Able to see the interface.

Thanks!

Ravi

1 Like

Note that API keys are only when you are on Prefect Cloud.

Prefect Server doesn’t have that feature - just to be transparent

Thanks Anna!

What do we need to do with a Prefect Kubernetes/EKS install that is managed by us?

How do we make it work?

Or is that even an option?

Thanks,

Ravi

Not sure I understand the question. What do you try to accomplish? Are you getting started with Prefect right now? if so, did you already 100% decide that you want to self-host or is Prefect Cloud an option?

You could sign up for Prefect Cloud for free and then you can use your Kubernetes cluster as your execution layer for your flows. To do that, you spin up a Kubernetes agent.

Check those docs for more details:

Hi Anna,

Thanks for the questions -

  1. We have decided to self-host Prefect on our Kubernetes cluster (EKS).
    Your suggestion is to “Sign up Prefect Cloud for free and then you can use your Kubernetes cluster”.

Will try that route.

Thanks,

Ravi

If you want to self-host, check this helm chart, including the detailed README on how to do that:

But Prefect Cloud is easier to manage and scale.

Hi Anna,

We went through the helm chart - and created the Prefect cluster on EKS in different namespace. No issues. We are able to kubectl around the namespace. All the pods are up and running (towel,hasura,apollo, etc …) for the last 8 days!

Now we would like to use the Prefect cluster. And for that we need the API Key to get started.

We are stuck there.

Thanks,

Ravi

what do you mean by a Prefect cluster - do you mean the Kubernetes agent? we don’t host any infrastructure other than the orchestration layer backend

Hi Anna,

We have installed Prefect on EKS. That is what I referred to as ‘cluster’. Prefect works based on a set of pods in Kubernetes (EKS).

Prefect has been running for 11 days now. We can access the UI and GraphQL.

We are not able to create an API Key.

What should the next steps be?

Thanks,

Ravi

You don’t need API keys for Prefect Server - can you explain more the problem you are trying to solve now?

Removing this as we seem to be still figuring this issue out.

So what do we need to get the Kubernetes Agent working with the Kubernetes install we already have?

We want to run flows - all on-prem. Using the opensource Kubernetes install of Prefect.

Is that possible?

Thanks,

Ravi

It’s absolutely possible! Check this topic to see how you can configure the Server endpoint on your Kubernetes agent:

Thanks Anna!

Will test that out and get back.

Ravi

1 Like

Hi Anna,

Here is the prefect command and exception stack trace. The trace is less than before …

(env) ********:~/prefect-installation-yaml-eks-notes/getting-started/examples/eksconfig $ prefect agent kubernetes start --namespace prefect-server --service-account-name default
[2022-04-25 16:43:52-0400] WARNING - prefect.kubernetes | Service host/port is not set. Using out of cluster configuration option.
[2022-04-25 16:43:54-0400] WARNING - prefect.kubernetes | Service host/port is not set. Using out of cluster configuration option.
[2022-04-25 20:43:55,640] ERROR - agent | Failed to verify authentication.
Traceback (most recent call last):
  File "/home/*******/prefect-installation-yaml-eks-notes/getting-started/env/lib/python3.6/site-packages/prefect/agent/agent.py", line 901, in _setup_api_connection
    self._verify_token(self.client.get_auth_token())
  File "/home/*******/prefect-installation-yaml-eks-notes/getting-started/env/lib/python3.6/site-packages/prefect/agent/agent.py", line 831, in _verify_token
    raise AuthorizationError("No agent API token provided.")
prefect.exceptions.AuthorizationError: No agent API token provided.

The above exception was the direct cause of the following exception:

...
...
...

RuntimeError: Error while contacting API at https://api.prefect.io

Thanks,

Ravi

perhaps you can deploy an agent as part of the helm chart setup then? You would need to add this flag to your helm chart startup command:

--set agent.enabled=true

full command:

NAME=prefect-server

helm upgrade \
    $NAME \
    prefecthq/prefect-server \
    --set agent.enabled=true \
    --set jobs.createTenant.enabled=true

Hi Anna,

On the first install - we were able to create an Agent - as suggested by you. That was 12 days back. We were able to add labels to the Agent.

We are trying to invoke the Agent from the Prefect CLI. That is where we run into the exceptions mentioned earlier.

Thanks,

Ravi

Can you explain why? Did the agent deployed as part of the Helm chart stop working? You only need one agent - the actual execution takes place in separate processes. Check this discourse topic for more info about that: