【问题标题】:Data puller and data pusher in pod or jobpod 或作业中的数据拉取器和数据推送器
【发布时间】:2021-01-04 02:12:56
【问题描述】:

我正在尝试在 kubernetes 中编写一个数据处理单元。

因为每个流程单元都有一个非常相似的工作流程:

  1. Puller 从对象存储中拉取数据并将/input 卷挂载到容器中
  2. 处理器运行代码处理volume中的数据并将数据输出到/outputvolume
  3. 再次将/output 卷中的数据推送到对象存储中

因此,每个 pod 或作业都必须有一个容器作为数据推送器和数据拉取器,共享卷在 here 中提到了这一点。但是我怎样才能使这个过程成为拉 -> 过程 -> 推序列?

现在我可以使用volume share的方式进行通信使其工作:首先我可以让puller开始工作,让数据处理器等待它找到一个pull-finished.txt创建。然后让推送器在找到创建的 process-finished.txt 时开始工作。但这可能不得不从某些图像中强制数据处理容器或使用某些不是我想要的特定入口点。有没有更优雅的方式来完成这项工作?

【问题讨论】:

标签: kubernetes pipeline


【解决方案1】:

正如Suresh VishnoiJanos Lenart 在 cmets 中已经提到的,最好的方法是使用Jobs 处理来自队列或输入卷的数据,并使用init-containers 有顺序的步骤来处理数据。

这是一个使用 Kubernetes 文档中的 init-containers 的好例子:

apiVersion: v1
kind: Pod
metadata:
  name: myapp-pod
  labels:
    app: myapp
spec:
  containers:
  - name: myapp-container
    image: busybox
    command: ['sh', '-c', 'echo The app is running! && sleep 3600']
  initContainers:
  - name: init-myservice
    image: busybox
    command: ['sh', '-c', 'until nslookup myservice; do echo waiting for myservice; sleep 2; done;']
  - name: init-mydb
    image: busybox
    command: ['sh', '-c', 'until nslookup mydb; do echo waiting for mydb; sleep 2; done;']

另一个很好的例子可以在Janos Lenart提供的answer中找到

【讨论】:

  • 所以容器部分只是一个通知器,表示所有工作都已完成。我必须使用 initContainers 来确保所有作业按顺序运行?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-11-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多