k8s pod completing even though I have an infinite loop in pod.yaml

huangapple go评论122阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年3月7日 01:18:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/75653877.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定