英文:
k8s pod completing even though I have an infinite loop in pod.yaml
问题
我有以下的pod.yaml文件,我希望这个Pod保持运行,但它却完成了。请问我做错了什么?
apiVersion: v1
kind: Pod
metadata:
name: app1
spec:
containers:
- name: base
image: "alpine:latest"
command: ["/bin/sh"]
args: ["-c", "while true; do echo app1:$(date -u) >> /data/test.log; sleep 5; done"]
volumeMounts:
- name: persistent-storage
mountPath: /data
volumes:
- name: persistent-storage
persistentVolumeClaim:
claimName: emy-claim
这是您的YAML文件,您希望Pod保持运行,但它却完成了。
英文:
I have below pod.yaml file and I am expecting the pod to keep running but it completes.
Can anyone please tell me what am I doing wrong ?
apiVersion: v1
kind: Pod
metadata:
name: app1
spec:
containers:
- name: base
image: "alpine:latest"
command: ["/bin/sh"]
args: ["-c", "while true; do echo app1:$(date -u) >> /data/test.log; sleep 5; done"]
volumeMounts:
- name: persistent-storage
mountPath: /data
volumes:
- name: persistent-storage
persistentVolumeClaim:
claimName: emy-claim
答案1
得分: 1
请使用以下信息更新pod.yaml
文件,以使用while
条件保持Pod运行,并在data
目录下的test
文件中每5秒
连续更新log entries
。
args: ["-c", "while true; do echo $(date -u) 'app1' >> /data/test.log; sleep 5; done"]
有关更多详细信息,请参阅文档。
英文:
Please update the pod.yaml
file with the below information to keep the pod running using the while
condition and to update the log entries
continuosly in the test
file under data
directory for every 5 seconds
.
args: ["-c", "while true; do echo echo $(date -u) 'app1' >> /data/test.log; sleep 5; done"]
Please see the documentation for more details.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论