Hello dear community. I'm trying to deploy a k8s a...
# ask-community
d
Hello dear community. I'm trying to deploy a k8s agent inside a k8s cluster and I'm sstruggling with the manifest. First the manifest asks for
PREFECT__CLOUD__AGENT__AUTH_TOKEN
which is deprecated if I understand correctly. Is it correct to assume that I can remove that arg and keep only the
PREFECT__CLOUD__API_KEY
a
afaik it’s only there for backwards compatibility. You can ignore the TOKEN argument and only fill out the PREFECT__CLOUD__API_KEY
d
Thank you Anna, I appreciate it.
I feel thought that documentation on k8s agent could be improved. As I'm no expert to k8s, just 1 year of experience, I've struggled a lot
a
I see. What you can also do is to first generate the YAML file for your agent and apply it only after you manually cross-checked everything in the YAML looks good.
Copy code
prefect agent kubernetes install --rbac -k YOUR_API_KEY >> agent.yaml
Then you can adjust everything in the agent.yaml e.g. add your agent label (for instance “production” or “staging”), add env variables and then apply:
Copy code
kubectl apply -f agent.yaml
d
If I understand correctly only the API_KEY is required, the rest can be removed/left empty
a
the label is also super important
d
Only to be able to pick up flows? I'm still trying to deploy it correctly and check that it's ok
a
correct, you would assign label to your agent:
Copy code
- name: PREFECT__CLOUD__AGENT__LABELS
  value: '["prod-kubernetes"]'
and then on your flow:
Copy code
with Flow(
    FLOW_NAME, storage=STORAGE, run_config=KubernetesRun(labels=["prod-kubernetes"],),
) as flow:
d
I have created the manifest using the cmd above
Copy code
prefect agent kubernetes install --rbac -k YOUR_API_KEY >> agent.yaml
and then applied it using
Copy code
kubectl apply -f agent.yaml
The pod errors and after 3 restarts it backs off. Trying to figure out why. Have you encountered something like that before?
It pulls successfully the image
prefecthq/prefect:0.15.10-python3.6
a
also if you happen to see:
Copy code
apiVersion: <http://rbac.authorization.k8s.io/v1beta1|rbac.authorization.k8s.io/v1beta1>
replace it with:
Copy code
apiVersion: <http://rbac.authorization.k8s.io/v1|rbac.authorization.k8s.io/v1>
and you can probably replace the image with a higher python version e.g. prefecthq/prefect:0.15.10-python3.8