现在我有一个下载数据的 cronjob,我想将它共享到另一个容器,该容器在上传新数据时对数据进行处理。我想知道是否有没有任何外部服务的方法可以在 cronjob pod 和我的主 pod 之间共享这些数据?
我已经尝试创建一个持久卷和持久卷声明来共享数据,但是当 cronjob 下载数据时,即使该卷已安装,它也不会出现在另一个 pod 中。
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: download
spec:
concurrencyPolicy: Forbid
suspend: false
schedule: "* * * * *"
jobTemplate:
spec:
template:
spec:
volumes:
- name: downloaded-data-claim
persistentVolumeClaim:
claimName: downloaded-data-claim
#container and image is here where it downloads
kind: PersistentVolume
metadata:
name: downloaded-data
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
claimRef:
name: downloaded-data-claim
namespace: default
hostPath:
path: "/tmp/"
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: downloaded-data-claim
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
volumeName: downloaded-data
然后 pod 安装卷
volumes:
- name: downloaded-data-claim
presistentVolumeClaim:
claimName: downloaded-data-claim
- name: output
emptyDir: {}
containers:
- name: "rand"
image: <filler>
imagePullPolicy: <filler>
volumeMounts:
- name: downloaded-data-claim
mountPath: /input
- name: output
mountPath: /output
resources: