如何在 Azure Kubernetes 上 运行 批处理作业
How to run batch job on azure kubernetes
在 Azure Kubernetes 服务上 运行 用 C# 编写的容器化批处理作业的最简单方法是什么?
这个问题专门针对 AKS。所以,我不是在寻找它 运行 作为 Azure 容器实例,也不是在 Azure 中以无服务器方式寻找它。
您可以使用 kubernetes job.
A Job creates one or more Pods and ensures that a specified number of
them successfully terminate. As pods successfully complete, the Job
tracks the successful completions. When a specified number of
successful completions is reached, the task (ie, Job) is complete.
Deleting a Job will clean up the Pods it created.
A simple case is to create one Job object in order to reliably run one
Pod to completion. The Job object will start a new Pod if the first
Pod fails or is deleted (for example due to a node hardware failure or
a node reboot).
You can also use a Job to run multiple Pods in parallel.
这是一个作业配置示例。它计算 π 到 2000 位并将其打印出来。大约需要 10 秒才能完成。
apiVersion: batch/v1
kind: Job
metadata:
name: pi
spec:
template:
spec:
containers:
- name: pi
image: perl
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
restartPolicy: Never
backoffLimit: 4
如果您想 运行 重复计划批处理作业,请使用 kubernetes cronjob
在 Azure Kubernetes 服务上 运行 用 C# 编写的容器化批处理作业的最简单方法是什么?
这个问题专门针对 AKS。所以,我不是在寻找它 运行 作为 Azure 容器实例,也不是在 Azure 中以无服务器方式寻找它。
您可以使用 kubernetes job.
A Job creates one or more Pods and ensures that a specified number of them successfully terminate. As pods successfully complete, the Job tracks the successful completions. When a specified number of successful completions is reached, the task (ie, Job) is complete. Deleting a Job will clean up the Pods it created.
A simple case is to create one Job object in order to reliably run one Pod to completion. The Job object will start a new Pod if the first Pod fails or is deleted (for example due to a node hardware failure or a node reboot).
You can also use a Job to run multiple Pods in parallel.
这是一个作业配置示例。它计算 π 到 2000 位并将其打印出来。大约需要 10 秒才能完成。
apiVersion: batch/v1
kind: Job
metadata:
name: pi
spec:
template:
spec:
containers:
- name: pi
image: perl
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
restartPolicy: Never
backoffLimit: 4
如果您想 运行 重复计划批处理作业,请使用 kubernetes cronjob