pod报错"Back-off restarting failed container"

时间:2020-05-22
本文章向大家介绍pod报错"Back-off restarting failed container",主要包括pod报错"Back-off restarting failed container"使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
Events:
  Type     Reason          Age                  From                         Message
  ----     ------          ----                 ----                         -------
  Normal   Scheduled       3m                   default-scheduler            Successfully assigned default/jenkins-master-deploy-6694c4f497-r46fn to master.localdomain
  Normal   SandboxChanged  85s                  kubelet, master.localdomain  Pod sandbox changed, it will be killed and re-created.
  Normal   Pulled          83s (x5 over 2m59s)  kubelet, master.localdomain  Container image "drud/jenkins-master:v0.29.0" already present on machine
  Normal   Created         83s (x5 over 2m59s)  kubelet, master.localdomain  Created container jenkins-master
  Normal   Started         81s (x5 over 2m59s)  kubelet, master.localdomain  Started container jenkins-master
  Warning  BackOff         78s (x9 over 2m57s)  kubelet, master.localdomain  Back-off restarting failed container

解决办法:
在deployment申明镜像的后面加上命令

command: [ "/bin/bash", "-ce", "tail -f /dev/null" ]

此命令用于防止容器启动后退出

kind: Deployment
apiVersion: apps/v1beta2
metadata:
  labels:
    app: jenkins-master
  name: jenkins-master-deploy
spec:
  replicas: 1
  selector:
    matchLabels:
      app: jenkins-master
  template:
    metadata:
      labels:
        app: jenkins-master
    spec:
      containers:
      - name: jenkins-master
        image: drud/jenkins-master:v0.29.0
        imagePullPolicy: IfNotPresent
        command: [ "/bin/bash", "-ce", "tail -f /dev/null" ]
        volumeMounts:
        - mountPath: /var/jenkins_home/
          name: masterjkshome
        ports:
        - containerPort: 8080
      volumes:
      - name: masterjkshome
        persistentVolumeClaim:
          claimName: pvcjkshome

$flag 上一页 下一页