apiVersion: v1
kind: Pod
metadata:
name: pv-pod
namespace: auth
spec:
containers:
- name: busybox
image: busybox
#************** HERE is the command!
command: ['sh', '-c', 'while true; do echo date > /output/output.log; sleep 5; done']
volumeMounts:
- name: pv-storage
mountPath: /output
volumes:
- name: pv-storage
persistentVolumeClaim:
claimName: host-storage-pvc
這個命令是我需要插入檔案“成功!Wed Jun 8 20:28:01 WAST 2022”的地方,即當前時間戳。
command: ['sh', '-c', 'while true; do echo success! $date >> /output/output.log; sleep 5; done']
但它一直在寫“成功日期”
uj5u.com熱心網友回復:
您可以為此使用命令替換。那將在 shell 或 bash 中,相同。
此外,您可能需要轉義美元符號,因為在 Kubernetes manifests 中$()具有特殊含義。
echo "success $$(date)" >> ...
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/489267.html
標籤:linux Kubernetes Kubernetes-pod
上一篇:使用不同的值創建相同的pod
