Keith
08/04/2022, 6:54 AMTraceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/prefect/cli/_utilities.py", line 41, in wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/prefect/utilities/asyncutils.py", line 193, in wrapper
return run_async_in_new_loop(async_fn, *args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/prefect/utilities/asyncutils.py", line 140, in run_async_in_new_loop
return anyio.run(partial(__fn, *args, **kwargs))
File "/usr/local/lib/python3.10/site-packages/anyio/_core/_eventloop.py", line 70, in run
return asynclib.run(func, *args, **backend_options)
File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 292, in run
return native_run(wrapper(), debug=debug)
File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
return future.result()
File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 287, in wrapper
return await func(*args)
File "/usr/local/lib/python3.10/site-packages/prefect/cli/agent.py", line 93, in start
async with OrionAgent(
File "/usr/local/lib/python3.10/site-packages/prefect/agent.py", line 249, in __aenter__
await self.start()
File "/usr/local/lib/python3.10/site-packages/prefect/agent.py", line 237, in start
await self.default_infrastructure._save(is_anonymous=True)
File "/usr/local/lib/python3.10/site-packages/prefect/blocks/core.py", line 618, in _save
await self.register_type_and_schema(client=client)
File "/usr/local/lib/python3.10/site-packages/prefect/blocks/core.py", line 560, in register_type_and_schema
block_type = await client.read_block_type_by_slug(
File "/usr/local/lib/python3.10/site-packages/prefect/client.py", line 1093, in read_block_type_by_slug
return BlockType.parse_obj(response.json())
File "/usr/local/lib/python3.10/site-packages/httpx/_models.py", line 743, in json
return jsonlib.loads(self.text, **kwargs)
File "/usr/local/lib/python3.10/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.10/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.10/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Mason Menges
08/04/2022, 3:51 PMChristopher Boyd
08/04/2022, 3:56 PMjson.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Where does this error come up specifically ? when you run the kubectl apply?
if so, what does your manifest look like?Keith
08/04/2022, 4:32 PMkubectl apply ...
the pod tries to start up and read the Prefect Cloud API secret setup with this command `kubectl create secret generic api-key --from-literal='prefect_cloud_api_key=<Prefect Cloud API Key>' -n prefect2`: kubectl apply
I suspect it is trying to read the secret as a JSON but it fails at doing so. I have tried many different combinations of defining the kubectl secret and always get the same JSON issue on deployment of the pod.apiVersion: apps/v1
kind: Deployment
metadata:
name: prefect-2-agent
namespace: prefect2
spec:
selector:
matchLabels:
app: prefect-2
replicas: 1 # We're using SQLite, so we should only run 1 pod
template:
metadata:
labels:
app: prefect-2
spec:
containers:
- name: api
image: prefecthq/prefect:2.0.2-python3.10
command: ["prefect", "orion", "start", "--host", "0.0.0.0", "--log-level", "WARNING"]
imagePullPolicy: "IfNotPresent"
ports:
- containerPort: 4200
- name: agent
image: prefecthq/prefect:2.0.2-python3.10
command: ["prefect", "agent", "start", "kubernetes"]
imagePullPolicy: "IfNotPresent"
env:
- name: PREFECT_API_URL
value: <https://app.prefect.cloud/account/><Account ID>/workspace/<Workspace ID>
- name: PREFECT_API_KEY
valueFrom:
secretKeyRef:
name: api-key
key: prefect_cloud_api_key
---
apiVersion: v1
kind: Service
metadata:
name: prefect-2-agent
namespace: prefect2
labels:
app: prefect-2
spec:
ports:
- port: 4200
protocol: TCP
selector:
app: prefect-2
---
apiVersion: <http://rbac.authorization.k8s.io/v1|rbac.authorization.k8s.io/v1>
kind: Role
metadata:
namespace: prefect2
name: flow-runner
rules:
- apiGroups: [""]
resources: ["pods", "pods/log", "pods/status"]
verbs: ["get", "watch", "list"]
- apiGroups: ["batch"]
resources: ["jobs"]
verbs: [ "get", "list", "watch", "create", "update", "patch", "delete" ]
---
apiVersion: <http://rbac.authorization.k8s.io/v1|rbac.authorization.k8s.io/v1>
kind: RoleBinding
metadata:
name: flow-runner-role-binding
namespace: prefect2
subjects:
- kind: ServiceAccount
name: default
namespace: prefect2
roleRef:
kind: Role
name: flow-runner
apiGroup: <http://rbac.authorization.k8s.io|rbac.authorization.k8s.io>
Christopher Boyd
08/04/2022, 4:36 PM- name: PREFECT_API_KEY
valueFrom:
secretKeyRef:
name: api-key
key: prefect_cloud_api_key
kubectl create secret generic api-key --from-literal=‘prefect_cloud_api_key=<your raw api key here>’Keith
08/04/2022, 4:37 PMkubectl create secret generic api-key --from-literal='prefect_cloud_api_key=<Prefect Cloud API Key>' -n prefect2
Christopher Boyd
08/04/2022, 4:38 PMKeith
08/04/2022, 4:41 PMChristopher Boyd
08/04/2022, 4:41 PMKeith
08/04/2022, 4:47 PMChristopher Boyd
08/04/2022, 4:48 PMKeith
08/04/2022, 4:48 PMChristopher Boyd
08/04/2022, 4:49 PM<https://app.prefect.cloud/account/><Account ID>/workspace/<Workspace ID>
Keith
08/04/2022, 4:50 PMChristopher Boyd
08/04/2022, 4:50 PM___ ___ ___ ___ ___ ___ _____ ___ ___ ___ ___ _ _
| _ \ _ \ __| __| __/ __|_ _| / _ \| _ \_ _/ _ \| \| |
| _/ / _|| _|| _| (__ | | | (_) | /| | (_) | .` |
|_| |_|_\___|_| |___\___| |_| \___/|_|_\___\___/|_|\_|
Configure Prefect to communicate with the server with:
prefect config set PREFECT_API_URL=<http://0.0.0.0:4200/api>
View the API reference documentation at <http://0.0.0.0:4200/docs>
Check out the dashboard at <http://0.0.0.0:4200>
INFO: Started server process [8]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on <http://0.0.0.0:4200> (Press CTRL+C to quit)
Starting agent connected to
<https://api.prefect.cloud/api/accounts/><replaced>/work
spaces/<replaced>...
___ ___ ___ ___ ___ ___ _____ _ ___ ___ _ _ _____
| _ \ _ \ __| __| __/ __|_ _| /_\ / __| __| \| |_ _|
| _/ / _|| _|| _| (__ | | / _ \ (_ | _|| .` | | |
|_| |_|_\___|_| |___\___| |_| /_/ \_\___|___|_|\_| |_|
Agent started! Looking for work from queue 'kubernetes'...
Keith
08/04/2022, 4:54 PMChristopher Boyd
08/04/2022, 4:54 PM<https://app.prefect.cloud>
<https://api.prefect.cloud>
Keith
08/04/2022, 4:54 PM2.0.2-python3.9
& 2.0.1-python3.9
Christopher Boyd
08/04/2022, 4:55 PMKeith
08/04/2022, 4:55 PMChristopher Boyd
08/04/2022, 4:59 PMFile "/usr/local/lib/python3.10/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.10/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
An exception occurred.
Keith
08/04/2022, 4:59 PMChristopher Boyd
08/04/2022, 5:00 PMprefect cloud workspace set --workspace "<workspace>"
When executed locally, that sets your API url, and can be displayed :
prefect config view
Keith
08/04/2022, 5:07 PMwhat I can correct in that videoIn the video I saw this:
env:
- name: PREFECT_API_URL
value: <https://app.prefect.cloud/account/><>/workspace/<>
- name: PREFECT_API_KEY
valueFrom:
secretKeyRef:
name: api-key
key: prefect_cloud_api_key
And missed that there was a API URL at the bottom, which is of the form <https://api.prefect.cloud/api/account/><>/workspace/<>
, I think I was just working on typing that template as you were talking and thats how I ended up with the API URL the way it is. I like your suggestion about the prefect config view