K8s YAML文件中command 执行多条命令
且在describe和kubelet日志中没有明确记录原因,基本都是因为command命令不合法导致如需要运行多条命令,使用;不要使用&&如下示例:command: ["/bin/sh"]args: ["-c","/usr/local/bin/redis_start;while true;do echo hello;sleep 1;done"]贴一个配置文件:apiVersion:
·
且在describe和kubelet日志中没有明确记录原因,基本都是因为command命令不合法导致
如需要运行多条命令,使用;
不要使用&&
如下示例:
command: ["/bin/sh"]
args: ["-c","/usr/local/bin/redis_start;while true;do echo hello;sleep 1;done"]
贴一个配置文件:
apiVersion: apps/v1
kind: Deployment
metadata:
name: alpine-test
# namespace: string #必选,Pod所属的命名空间
spec:
selector:
matchLabels:
app: alpine-test
replicas: 1
template:
metadata:
labels:
app: alpine-test
spec:
containers:
- name: alpine-test
image: alpine_nginx1.20-php7.3:v1
imagePullPolicy: IfNotPresent
command: [ "/bin/sh", "-c", "--" ]
args: [ "/usr/sbin/php-fpm7;/usr/local/nginx/sbin/nginx;while true; do sleep 30; done;" ]
securityContext:
privileged: true
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: alpine-test
spec:
type: NodePort
ports:
- name: web
port: 80
protocol: TCP
targetPort: 80
nodePort: 31002
selector:
app: alpine-test
更多推荐
已为社区贡献33条内容
所有评论(0)