我一添加,
spec:
containers:
- args:
- /bin/sh
- '-c'
- touch /tmp/healthy; touch /tmp/liveness
env:
对于部署文件,应用程序不会在描述日志中出现任何错误 . 部署成功,但没有输出 . 两个文件都在容器中创建 . 我可以在kubernetes部署中运行docker build吗?
下面是完整的部署yaml .
- apiVersion:apps / v1种类:部署元数据:标签:app:web name:web namespace:default spec:replicas:1 selector:matchLabels:app:web version:prod template:metadata:annotations:prometheus.io/scrape:'true'标签:app:web version:prod spec:containers: - args: - / bin / sh - '-c' - > - touch / tmp / healthy; touch / tmp / liveness;而真实;回声 . 睡1;完成env: - name:SUCCESS_RATE valueFrom:configMapKeyRef:key:SUCCESS_RATE name:web-config-prod image:busybox livenessProbe:exec:command: - cat - / tmp / liveness initialDelaySeconds:5 name:web ports: - containerPort:8080 - containerPort:8000
1 回答
问题出在你的情况下
container is not found
完成后's task. You told to execute a shell script to your conatainer. And after doing that the container is finished. That'为什么你可以't see whether the files were created or not. Also it didn'吨放任何日志 . 因此,您需要在创建文件后保持容器存活 . 你可以通过放置无限循环来做到这一点 . 它来了:将它保存到hello-deployment.yaml并运行,