Prabin Mehta
06/15/2021, 12:00 PMMarko Herkaliuk
06/15/2021, 12:09 PMPrabin Mehta
06/15/2021, 12:24 PMKevin Kho
Mariia Kerimova
06/15/2021, 1:23 PMfrom prefect import task, Flow
from prefect.run_configs import KubernetesRun
from prefect.storage import Docker
@task
def say_hello(log_stdout=True):
print("Hello, world!")
with Flow("Test") as flow:
flow.add_task(say_hello())
flow.storage = Docker(registry_url="xxx", image_name="my-kube-testflow")
flow.run_config = KubernetesRun()
if __name__ == "__main__":
flow.register(project_name="Training")
Here you can find information about Kubernetes agent you need to run in order to deploy the flows in your cluster.Prabin Mehta
06/15/2021, 2:03 PMPrabin Mehta
06/15/2021, 2:06 PMPrabin Mehta
06/15/2021, 2:15 PM---
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: ddd---ddddddddddd
- name: PREFECT__CLOUD__API
value: <https://api.prefect.io>
- name: NAMESPACE
value: prefect
- 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: EXTRA_PIP_PACKAGES
value: 'chardet==3.0.2 prefect[snowflake]'
image: prefecthq/prefect:latest-python3.7
imagePullPolicy: Always
livenessProbe:
failureThreshold: 2
httpGet:
path: /api/health
port: 8080
initialDelaySeconds: 40
periodSeconds: 40
name: agent
---
apiVersion: <http://rbac.authorization.k8s.io/v1|rbac.authorization.k8s.io/v1>
kind: Role
metadata:
name: prefect-agent-rbac
namespace: prefect
rules:
- apiGroups:
- batch
- extensions
resources:
- jobs
verbs:
- '*'
- apiGroups:
- ''
resources:
- events
- pods
verbs:
- '*'
---
apiVersion: <http://rbac.authorization.k8s.io/v1beta1|rbac.authorization.k8s.io/v1beta1>
kind: RoleBinding
metadata:
name: prefect-agent-rbac
namespace: prefect
roleRef:
apiGroup: <http://rbac.authorization.k8s.io|rbac.authorization.k8s.io>
kind: Role
name: prefect-agent-rbac
subjects:
- kind: ServiceAccount
name: default
But still getting my pods having the msg,
Event: 'Started' on pod 'prefect-job-0460be1c-6p8v6'
Message: Started container flow-container
and still, the jobs are not executed. Let me know your thoughts. (edited)Mariia Kerimova
06/15/2021, 3:58 PM