Successfully assigned default/myapp-nginx-deployment-67f4dfb444-9f8gl to node2
Pulling image "hub.bosssoft.com/library/nginx:v1.8"
Successfully pulled image "hub.bosssoft.com/library/nginx:v1.8"
Created container myapp-nginx
Started container myapp-nginx
Container image "hub.bosssoft.com/library/nginx:v1.8" already present on machine
Back-off restarting failed container

 command: [ "/bin/bash", "-c", "--" ]
 args: [ "while true; do sleep 30; done;" ]
     上面是命令下面是值,是key vlaue的格式
     这个的意思就是一直死循环的执行着进程,因为装的nginx没有成功安装

由于通过指定的镜像启动容器后,容器内部没有常驻进程,导致容器启动成功后即退出,从而进行了持续的重启。
可以看到container都创建好了,但是image镜像已经存在了,没有调起后面的进程,这时候只需要配合在后面创建个job或者创建一个
Job 负责批处理任务,即仅执行一次的任务,它保证批处理任务的一个或多个 Pod 成功结束
#configmap代替环境变量
apiVersion: v1
kind: Pod
metadata:
name: dapi-test-pod
spec:
containers:

  • name: test-container
    image: hub.bosssoft.com/library/nginx:v1.8
    command: [ "/bin/sh", "-c", "env" ]
    env:
    • name: SPECIAL_LEVEL_KEY
      valueFrom:
      configMapKeyRef:
      name: special-config
      key: special.how
      • name: SPECIAL_TYPE_KEY
        valueFrom:
        configMapKeyRef:
        name: special-config
        key: special.type
        envFrom:
      • configMapRef:
        name: env-config
        restartPolicy: Never
        k8s启动后容器总是重启Back-off restarting failed container_第1张图片
        两种方法都可以
        kubectl apply -f myapp-deploy.yaml

kubectl get pod
k8s启动后容器总是重启Back-off restarting failed container_第2张图片

起来了