【发布时间】:2022-02-21 18:51:44
【问题描述】:
我是 Prefect 的新手,想使用 Prefect 在 Azure Kubernetes 服务上部署 Kubernetes 作业。 我已经建立了一个 Linux 容器,包括 Prefect、kubectl。我可以建立到 AKS 集群的连接,并且通过使用 kubectl,我可以在 AKS 上部署 Kubernetes 作业。 但是它如何与 Prefect 一起工作? 在 Container 中,我存储了 .py 文件和一个 YAML 文件,它定义了 Kubernetes 作业。
--> kubectl apply -f deploytestcontainer.yaml --> 有效
运行附加的示例 Prefect 代码也可以工作(但作业未在 AKS 中部署)
这就是“firstk8sjob.py”的内容
import prefect
from prefect import task, Flow
from prefect.run_configs import KubernetesRun
@task
def hello_task():
flow.run_config = KubernetesRun(job_template_path="deploytestcontainer.yaml")
logger = prefect.context.get("logger")
logger.info("Hello world!")
with Flow("hello-flow") as flow:
hello_task()
flow.run()
非常感谢您的建议!
【问题讨论】:
-
那么,如果您对您的 AKS 运行
kubectl get jobs -A,输出是什么? -
@Hackerman :通过使用 kubectl,我能够按预期部署作业 - 所以 kubectl 的使用很好。但我需要使用 Prefect 来部署这项工作......
标签: python azure kubernetes prefect