Hi, how would I change the `PREFECT__CLOUD__AGENT_...
# ask-community
s
Hi, how would I change the
PREFECT__CLOUD__AGENT__AGENT_ADDRESS
field fo Kubernetes deployment without modifying the yaml file directly? Is there a command line argument that I can use? I was suspecting
--agent-address
, but that’s not available.
Copy code
- name: PREFECT__CLOUD__AGENT__AGENT_ADDRESS
          value: http://:8080
Below is the command I’m testing
Copy code
prefect agent kubernetes install --backend cloud --api "<https://api.prefect.io>" --namespace xxxxx --tenant-id xxxxx --service-account-name xxxx --key xxxx --rbac | kubectl apply --namespace=xxxxx -f -
k
Hey @Shaoyi Zhang, a bit confused. Why are you trying to change this if you are using Cloud?
s
Hey Kevin, thank you for the quick reply. I was getting following error
Copy code
The connection to the server localhost:8080 was refused - did you specify the right host or port?
Our prefect agent is deployed on a ec2 instance though. I didn’t set the agent up originally so I might have a knowledge gap here.
k
I think that agent address is not the issue. When I do the
prefect agent kubernetes install
, this is what I get
Copy code
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: prefect-agent
  name: prefect-agent
spec:
  replicas: 1
  selector:
    matchLabels:
      app: prefect-agent
  template:
    metadata:
      labels:
        app: prefect-agent
    spec:
      containers:
      - args:
        - prefect agent kubernetes start
        command:
        - /bin/bash
        - -c
        env:
        - name: PREFECT__CLOUD__AGENT__AUTH_TOKEN
          value: ''
        - name: PREFECT__CLOUD__API
          value: <https://api.prefect.io>
        - name: NAMESPACE
          value: default
        - name: IMAGE_PULL_SECRETS
          value: ''
        - name: PREFECT__CLOUD__AGENT__LABELS
          value: '[]'
        - name: JOB_MEM_REQUEST
          value: ''
        - name: JOB_MEM_LIMIT
          value: ''
        - name: JOB_CPU_REQUEST
          value: ''
        - name: JOB_CPU_LIMIT
          value: ''
        - name: IMAGE_PULL_POLICY
          value: ''
        - name: SERVICE_ACCOUNT_NAME
          value: ''
        - name: PREFECT__BACKEND
          value: cloud
        - name: PREFECT__CLOUD__AGENT__AGENT_ADDRESS
          value: http://:8080
        - name: PREFECT__CLOUD__API_KEY
          value: API_KEY
        - name: PREFECT__CLOUD__TENANT_ID
          value: ''
        image: prefecthq/prefect:0.15.5-python3.6
        imagePullPolicy: Always
        livenessProbe:
          failureThreshold: 2
          httpGet:
            path: /api/health
            port: 8080
          initialDelaySeconds: 40
          periodSeconds: 40
        name: agent
Do you know where that localhost is coming from?
Maybe try
prefect backend cloud
on your machine also?
s
localhost might be coming from kubernetes end. I tried
prefect backend cloud
, but got same error. Let me poke my Kubernetes configuration.
k
I have a gist here of a working agent setup on cloud. it’s pretty much the same as above but maybe you can compare
🙏 1
s
I figured it out. I was missing the
--context
flag in kubectl command. This is unrelated to Prefect. Thank you for pointing me to the right direction!
👍 1
A quick follow up on this: I was able to create the K8s deployment and the pod is running, what’s the next step so that the newly created k8s agent can become available in Prefect cloud UI?
This is from the console log of the K8s pod
Copy code
[2021-09-16 21:36:20,885] INFO - agent | Registering agent...
[2021-09-16 21:36:21,222] INFO - agent | Registration successful!

 ____            __           _        _                    _
|  _ \ _ __ ___ / _| ___  ___| |_     / \   __ _  ___ _ __ | |_
| |_) | '__/ _ \ |_ / _ \/ __| __|   / _ \ / _` |/ _ \ '_ \| __|
|  __/| | |  __/  _|  __/ (__| |_   / ___ \ (_| |  __/ | | | |_
|_|   |_|  \___|_|  \___|\___|\__| /_/   \_\__, |\___|_| |_|\__|
                                           |___/

[2021-09-16 21:36:21,536] INFO - agent | Starting KubernetesAgent with labels ['dev']
[2021-09-16 21:36:21,536] INFO - agent | Agent documentation can be found at <https://docs.prefect.io/orchestration/>
[2021-09-16 21:36:21,537] INFO - agent | Waiting for flow runs...
k
You should see that in the UI under the agents Tab. Do you not see anything?
s
I can see other agents except for the k8s agent that I created today
k
Do you have multiple tenants by chance?
s
Yes, we have like 9 tenants
Let me check other tenants
k
Wow! 9!? That’s a lot haha. Maybe the agent is in the wrong tenant?
s
oh, I can see it now. There might be some bug in the UI because when I was trying to create a project it crashed, and force refresh made the new kubernetes agent visible in UI
Thank you!
👍 1