Tag Archives: back off restarting failed container

Solution to pod error “back off restarting failed container”

Solution to pod error “back off restarting failed container”

Phenomenon:

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

Solution.
Add the command to the end of the deployment affirmation image
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