kubernetesdeploymentdocker-imagekubernetes-secrets

Deployment not running due to ImagePullBackOff reason


I'm trying to create a deployment that is pulling a container image from a private registry.

My deployment.yaml file:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
  namespace: my-namespace
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
        - name: my-app
          image: my-repo/my-app:1.0
      imagePullSecrets:
        - name: regcred

I'm deploying with the following command: kubectl apply -f deployment.yaml -n my-namespace.

The deployment is not running due to the ImagePullBackOff.

I checked available resources to troubleshoot this issue and ruled out the following:

Pod description wasn't super helpful to me. I see the following:

state: waiting: message: Back-off pulling image "my-repo/my-app:tag" reason: ImagePullBackOff

I don't understand why in the pod description, namespace is listed as 'default'. This is my only remaining straw that I'm grasping to.

apiVersion: v1 kind: Pod metadata: annotations: ..org/containerID: ... ..org/podIP: ... ..org/podIPs: creationTimestamp: "" generateName: ... labels: app: my-app pod-template-hash: ... name: ... namespace: default

I would appreciate any suggestions how to troubleshoot this. Thank you!


Solution

  • Original deployment.yaml did not contain namespace, so the pod was attempting to deploy in the default namespace. The secret was created in a different namespace. Once I added namespace to the manifest, the pod deployed successfully in the specified namespace. My problem was that I was looking for pods in the default namespace and kept on seeing the originally failed deployment. Once I looked in the correct namespace kubectl get pods -n my-namespace, I saw that the pod is running and pulling the correct image.