且在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
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐