我正在尝试使用 init pod。我想使用init 容器来创建文件和默认容器来检查文件是否存在并休眠一段时间。
我的 yaml:
apiVersion: v1
kind: Pod
metadata:
name: init-test-pod
spec:
containers:
- name: myapp-container
image: alpine
command: ['sh', '-c', 'if [ -e /workdir/test.txt ]; then sleep 99999; fi']
initContainers:
- name: init-myservice
image: busybox:1.28
command: ['sh', '-c', 'mkdir /workdir; echo>/workdir/test.txt']
Run Code Online (Sandbox Code Playgroud)
当我尝试从 alpine 图像调试时,我使用命令来创建:
kubectl 运行高山 --rm -ti --image=alpine /bin/sh
If you don't see a command prompt, try pressing enter.
/ # if [ -e /workdir/test.txt ]; then sleep 3; fi
/ # mkdir /workdir; …Run Code Online (Sandbox Code Playgroud)