我正在测试是否可以使用initContainer从S3装载数据。我的预期和期望是将相同的卷装入到initContainer和Container中。使用InitContainer将来自S3的数据下载到名为/ s3-data的mountPath上,并且由于Container在initContainer之后运行,因此可以从将卷安装到的路径中读取数据。
但是,Container不会显示任何日志,而只是显示“流已关闭”。 initContainer显示了从S3成功下载数据的日志。
我究竟做错了什么?提前致谢。
apiVersion: batch/v1
kind: Job
metadata:
name: train-job
spec:
template:
spec:
initContainers:
- name: data-download
image: <My AWS-CLI Image>
command: ["/bin/sh", "-c"]
args:
- aws s3 cp s3://<Kubeflow Bucket>/kubeflowdata.tar.gz /s3-data
volumeMounts:
- mountPath: /s3-data
name: s3-data
env:
- name: AWS_ACCESS_KEY_ID
valueFrom:
secretKeyRef: {key: AWS_ACCESS_KEY_ID, name: aws-secret}
- name: AWS_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef: {key: AWS_SECRET_ACCESS_KEY, name: aws-secret}
containers:
- name: check-proper-data-mount
image: <My Image>
command: ["/bin/sh", "-c"]
args:
- cd /s3-data
- echo "Just s3-data dir"
- ls
- echo "After making a sample file"
- touch sample.txt
- ls
volumeMounts:
- mountPath: /s3-data
name: s3-data
volumes:
- name: s3-data
emptyDir: {}
restartPolicy: OnFailure
backoffLimit: 6
最佳答案
You can try like the below mentioned the argument part
---
apiVersion: v1
kind: Pod
metadata:
labels:
purpose: demonstrate-command
name: command-demo
spec:
containers:
-
args:
- cd /s3-data;
echo "Just s3-data dir";
ls;
echo "After making a sample file";
touch sample.txt;
ls;
command:
- /bin/sh
- -c
image: "<My Image>"
name: containername
以供参考:How to set multiple commands in one yaml file with Kubernetes?
关于kubernetes - 如何检查K8s卷是否正确安装?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/63872539/