pod报错"Back-off restarting failed container"解决办法

Fidelia ·
更新时间:2024-11-15
· 983 次阅读

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

解决办法:
参考网页:
https://serverfault.com/questions/924243/back-off-restarting-failed-container-error-syncing-pod-in-minikube
在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

作者:Mr_ZhangSan



back pod

需要 登录 后方可回复, 如果你还没有账号请 注册新账号